Пример #1
0
        public void TestFindTwoTurnCompultionWinForTile4()
        {
            //setup the initial condition
            var player1 = "Player 1";
            var player2 = "Player 2";
            var game    = new GameCore(player1, player2);
            var board   = game.Board;

            // x x x
            // t t t
            // t t t
            // t t t x
            // t t t x . . .
            /////////////////

            board[0][0].OwningPlayer = player2;
            board[0][1].OwningPlayer = player2;
            board[0][2].OwningPlayer = player2;
            board[0][3].OwningPlayer = player1;
            board[0][4].OwningPlayer = player1;

            board[1][0].OwningPlayer = player1;
            board[1][1].OwningPlayer = player1;
            board[1][2].OwningPlayer = player1;
            board[1][3].OwningPlayer = player2;
            board[1][4].OwningPlayer = player1;

            board[2][0].OwningPlayer = player2;
            board[2][1].OwningPlayer = player1;
            board[2][2].OwningPlayer = player2;
            board[2][3].OwningPlayer = player1;
            board[2][4].OwningPlayer = player1;

            board[3][0].OwningPlayer = player1;
            board[3][1].OwningPlayer = player1;

            List <Tile> compulsionWin = AIHelper.FindTwoTurnCompulsionWin(game, player1);

            Assert.AreEqual(1, compulsionWin.Count);
            Assert.AreEqual(board[3][2], compulsionWin[0]);
        }
Пример #2
0
        public void TestFindTwoTurnCompultionWinForTile_DoesntThrowGame()
        {
            //setup the initial condition
            var player1 = "Player 1";
            var player2 = "Player 2";
            var game    = new GameCore(player1, player2);
            var board   = game.Board;

            //If player one, x tries to play on 4,0 to start a compulsion
            //it would backfire, giving player two the win via a positive diagonal
            //connection. So make sure that option isn't considered

            // . . . . . x t
            // . . . . . t x
            // . . x x . x t
            // . . x t . t x
            ////////////////////

            board[2][0].OwningPlayer = player1;
            board[2][1].OwningPlayer = player1;

            board[3][0].OwningPlayer = player2;
            board[3][1].OwningPlayer = player1;

            //column four is empty

            board[5][0].OwningPlayer = player2;
            board[5][1].OwningPlayer = player1;
            board[5][2].OwningPlayer = player2;
            board[5][3].OwningPlayer = player1;

            board[6][0].OwningPlayer = player1;
            board[6][1].OwningPlayer = player2;
            board[6][2].OwningPlayer = player1;
            board[6][3].OwningPlayer = player2;

            List <Tile> compulsionWin = AIHelper.FindTwoTurnCompulsionWin(game, player1);

            Assert.AreEqual(0, compulsionWin.Count);
        }
Пример #3
0
        public void TestFindTwoTurnCompultionWinForTile1()
        {
            //setup the initial condition
            var player1 = "Player 1";
            var player2 = "Player 2";
            var game    = new GameCore(player1, player2);
            var board   = game.Board;

            // . . . . . x
            // . . . . . t
            // . . x x . x
            // . . x t . t .
            ////////////////////

            board[2][0].OwningPlayer = player1;
            board[2][1].OwningPlayer = player1;

            board[3][0].OwningPlayer = player2;
            board[3][1].OwningPlayer = player1;

            //column 4 is empty, with which we can create a compulsion.
            //If player one places a tile in column four, it will cause a potential
            //win if they place another one (4 horizontally) so player 2 will have to
            //block it. But that will let player 1 place a tile there to win
            //via a diagonal.

            board[5][0].OwningPlayer = player2;
            board[5][1].OwningPlayer = player1;
            board[5][2].OwningPlayer = player2;
            board[5][3].OwningPlayer = player1;

            List <Tile> compulsionWin = AIHelper.FindTwoTurnCompulsionWin(game, player1);

            Assert.AreEqual(1, compulsionWin.Count);
            Assert.AreEqual(board[4][0], compulsionWin[0]);
        }