Beispiel #1
0
        public void TestFindsSolution()
        {
            GameBoard gameBoard = new GameBoard(2, 5);

            GameBlockPlayer gameBlockPlayer1 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 0) as GameBlockPlayer;
            GameBlockNormal gameBlockNormal1 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 0, 1) as GameBlockNormal;
            GameBlockNormal gameBlockNormal2 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 0, 2) as GameBlockNormal;
            GameBlockNormal gameBlockNormal3 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 0, 3) as GameBlockNormal;
            GameBlockPlayer gameBlockPlayer2 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 4) as GameBlockPlayer;
            GameBlockNormal gameBlockNormal4 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 1, 2) as GameBlockNormal;
            GameBlockPlayer gameBlockPlayer3 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 1, 3) as GameBlockPlayer;

            gameBlockNormal1.SetAvailability(true);
            gameBlockNormal2.SetAvailability(true);
            gameBlockNormal3.SetAvailability(true);
            gameBlockNormal4.SetAvailability(true);
            gameBlockPlayer1.AvailableMoves = 1;
            gameBlockPlayer2.AvailableMoves = 2;
            gameBlockPlayer3.AvailableMoves = 1;

            int failures;
            int successes;

            GameBoardSolver.Solve(gameBoard, 30000, out failures, out successes);

            Assert.AreEqual(2, failures);
            Assert.AreEqual(3, successes);
        }
Beispiel #2
0
        public void SolverDoesNotChangeGameBoard()
        {
            GameBoard gameBoard = new GameBoard(2, 5);

            GameBlockPlayer gameBlockPlayer1 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 0) as GameBlockPlayer;
            GameBlockNormal gameBlockNormal1 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 0, 1) as GameBlockNormal;
            GameBlockNormal gameBlockNormal2 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 0, 2) as GameBlockNormal;
            GameBlockNormal gameBlockNormal3 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 0, 3) as GameBlockNormal;
            GameBlockPlayer gameBlockPlayer2 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 0, 4) as GameBlockPlayer;
            GameBlockNormal gameBlockNormal4 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Normal, 1, 2) as GameBlockNormal;
            GameBlockPlayer gameBlockPlayer3 = gameBoard.CreateGameBlock(GameBoard.GameBlockType.Player, 1, 3) as GameBlockPlayer;

            gameBlockNormal1.SetAvailability(true);
            gameBlockNormal2.SetAvailability(true);
            gameBlockNormal3.SetAvailability(true);
            gameBlockNormal4.SetAvailability(true);
            gameBlockPlayer1.AvailableMoves = 1;
            gameBlockPlayer2.AvailableMoves = 2;
            gameBlockPlayer3.AvailableMoves = 1;

            string originalBoardString = gameBoard.GetBoardStringFull();

            int failures;
            int successes;

            GameBoardSolver.Solve(gameBoard, 30000, out failures, out successes);

            string boardStringAfterSolving = gameBoard.GetBoardStringFull();

            Assert.AreEqual(originalBoardString, boardStringAfterSolving);
        }