コード例 #1
0
        public void Test1()
        {
            var ai    = new ConnectClosestMinesAi();
            var state = new State {
                punter = 0, punters = 1, map = MapLoader.LoadMap(Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\..\maps\sample.json")).Map
            };

            ai.Setup(state, new Services(state));
            var moveDecision = ai.GetNextMove(state, new Services(state));

            Assert.That(moveDecision.move, Is.EqualTo(Move.Claim(0, 5, 3)));
            state.map = state.map.ApplyMove(moveDecision.move);
            state.turns.Add(new TurnState());
            moveDecision = ai.GetNextMove(state, new Services(state));
            Assert.That(moveDecision.move, Is.EqualTo(Move.Claim(0, 1, 3)));
            state.map = state.map.ApplyMove(moveDecision.move);
            state.turns.Add(new TurnState());
            moveDecision = ai.GetNextMove(state, new Services(state));
            Assert.That(moveDecision.move, Is.EqualTo(Move.Claim(0, 0, 1)));
        }
コード例 #2
0
        public void Show()
        {
            var form    = new Form();
            var painter = new MapPainter();
            var map     = MapLoader.LoadMap(Path.Combine(TestContext.CurrentContext.TestDirectory, @"..\..\..\..\maps\sample.json"));

            var ai        = new ConnectClosestMinesAi();
            var simulator = new GameSimulator(map.Map, new Settings());

            simulator.StartGame(new List <IAi> {
                ai
            });
            var gameState = simulator.NextMove();

            painter.Map = gameState.CurrentMap;

            var panel = new ScaledViewPanel(painter)
            {
                Dock = DockStyle.Fill
            };

            form.Controls.Add(panel);
            form.ShowDialog();
        }