예제 #1
0
        public void GetFood()
        {
            using (var consoleOutput = new ConsoleOutput())
            {
                var state = new GameState(32, 32, int.MaxValue, 100, 25, 5, 1);
                var bot   = new MyBot();


                state.StartNewTurn();
                state.AddAnt(16, 16, 0);
                state.AddFood(17, 16);

                Func <Location, Ant> test = x => state.MyAnts.Select(ant => (x.Row == ant.Row && x.Col == ant.Col) ? ant : null).Where(y => y != null).FirstOrDefault();

                Assert.NotNull(test(state.MyAnts[0]));
                Assert.NotNull(test(new Ant(16, 16, 0)));
                Assert.NotNull(test(new Location(16, 16)));

                var result = MyBot.FindClosest(state, state.FoodTiles[0], test);
                Assert.NotNull(result);


                bot.DoTurn(state);

                Assert.AreEqual("o 16 16 s\r\n", consoleOutput.GetOuput());

                consoleOutput.Clear();


                state.StartNewTurn();
                state.AddAnt(16, 16, 0);
                state.AddFood(15, 16);

                bot.DoTurn(state);

                Assert.AreEqual("o 16 16 n\r\n", consoleOutput.GetOuput());
            }
        }
예제 #2
0
 public void Restore(GameState state)
 {
     state.StartNewTurn();
     foreach (var loc in Ants)
     {
         state.AddAnt(loc.Row, loc.Col, loc.Team);
     }
     foreach (var loc in Hills)
     {
         state.AntHill(loc.Row, loc.Col, loc.Team);
     }
     foreach (var loc in Food)
     {
         state.AddFood(loc.Row, loc.Col);
     }
 }