Пример #1
0
        public void TestInfiniteGameEvaluation()
        {
            string[] map = new string[]
            {
                "", "h", "AE", "h", "hAC", "hADGH", "hCE", "CEG", "BEG"
            };

            var game = new NimCity2Game(map);
            var ge   = new GameEvaluation();

            int[] expected = new[] { 0, 1, 0, 1, 2, -1, 2, -1, 1 };
            int   ix       = 0;

            foreach (IGameState state in game.AllStates())
            {
                int res = ge.EvaluateInfiniteGame(game, state);
                Assert.AreEqual(expected[ix++], res);
            }

            var cgs    = new CombinedGameState(new[] { game.states[2], game.states[4], game.states[8] });
            int cgsRes = ge.EvaluateInfiniteGame(game, cgs);

            Assert.IsTrue(cgsRes > 0);

            cgs    = new CombinedGameState(new[] { game.states[7] });
            cgsRes = ge.EvaluateInfiniteGame(game, cgs);
            Assert.IsTrue(cgsRes < 0);

            cgs    = new CombinedGameState(new[] { game.states[5] });
            cgsRes = ge.EvaluateInfiniteGame(game, cgs);
            Assert.IsTrue(cgsRes > 0);

            cgs    = new CombinedGameState(new[] { game.states[5], game.states[3] });
            cgsRes = ge.EvaluateInfiniteGame(game, cgs);
            Assert.IsTrue(cgsRes > 0);

            cgs    = new CombinedGameState(new[] { game.states[5], game.states[3], game.states[4] });
            cgsRes = ge.EvaluateInfiniteGame(game, cgs);
            Assert.IsTrue(cgsRes < 0);
        }
Пример #2
0
 public NimCity2State(NimCity2Game game, int city, List <int> edges)
 {
     _game  = game;
     _city  = city;
     _edges = edges;
 }