Exemplo n.º 1
0
        private void LoadFile(string fileName)
        {
            var gameFile = GameFile.Load(fileName);

            foreach (var moveCommand in gameFile.MoveCommands)
            {
                Assert.IsTrue(Game.TryPossibleMoveCommand(moveCommand));
            }
        }
Exemplo n.º 2
0
        public void TestGamePerformance()
        {
#if DEBUG
            Assert.Fail("Run this test in release configuration");
#endif
            var gameFile = GameFile.Load("TestGames\\performance1.txt");
            Game.Load(gameFile);
            var engine     = new Engine();
            var evaluation = engine.BestMoveDeepeningSearch(Game, TimeSpan.FromSeconds(10));
            Console.WriteLine(evaluation);
        }
Exemplo n.º 3
0
        public void TestDrawby50moverule()
        {
            var game = new Game();

            game.New();
            var gameFile = GameFile.Load("TestGames\\drawby50moverule.txt");

            game.Load(gameFile);
            Assert.IsTrue(game.Ended);
            game.UndoLastMove();
            Assert.IsFalse(game.Ended);
            Assert.IsTrue(game.TryStringMove("h8-g8"));
            Assert.IsTrue(game.Ended);
        }
Exemplo n.º 4
0
        public void TestCopyGame()
        {
            var game = new Game();

            game.New();
            var gameFile = GameFile.Load("TestGames\\mated.txt");

            foreach (var command in gameFile.MoveCommands)
            {
                Assert.IsTrue(game.TryPossibleMoveCommand(command));
            }

            var copy = game.Copy();

            Assert.AreNotSame(game, copy);
        }
Exemplo n.º 5
0
        public void TestSaveLoad()
        {
            var game = new Game();

            game.New();
            Assert.IsTrue(game.TryStringMove("e2-e4"));
            Assert.IsTrue(game.TryStringMove("e7-e5"));
            var gameFile = new GameFile(game);
            var fileName = @"gamefile.txt";

            gameFile.Save(fileName);

            var loaded = GameFile.Load(fileName);

            for (int i = 0; i < gameFile.MoveCommands.Count; i++)
            {
                Assert.AreEqual(gameFile.MoveCommands[i].ToString(), loaded.MoveCommands[i].ToString());
            }
        }