Exemple #1
0
        public void Invalid_Move_Test(int rows, int columns)
        {
            ConnectFour connectFour = new ConnectFour(rows, columns);

            bool invalidMove = false;

            for (int i = 0; i < rows; i++)
            {
                connectFour.Drop('y', 0);
                connectFour.Drop('r', 0);
            }

            invalidMove = connectFour.Drop('y', 0);
            Assert.False(invalidMove);
        }
Exemple #2
0
        public void Vertical_Red_windCheck(int rows, int columns)
        {
            ConnectFour connectFour = new ConnectFour(rows, columns);

            for (int i = 0; i < 4; i++)
            {
                connectFour.Drop('r', 0);
            }

            var result = connectFour.CheckWin('r');

            Assert.True(result);
        }
Exemple #3
0
        public void Horizontal_Yellow_WinCheck(int rows, int columns)
        {
            ConnectFour connectFour = new ConnectFour(rows, columns);

            for (int i = 0; i < 4; i++)
            {
                connectFour.Drop('y', i);
            }

            var result = connectFour.CheckWin('y');

            Assert.True(result);
        }
Exemple #4
0
    // Does the move for this board in a specific column.
    // If this returns true, the move resulted in a win and we should stop constructing the board deeper than this point
    public bool DoMove(int column)
    {
        if (!ConnectFour.IsPlayerValid(move.playerId))
        {
            Debug.LogError("BoardState : Set valid playerId first!");
            return(false);
        }

        move.column = column;
        board.Drop(move.playerId, column, out move.row);
        UpdateScore();

        // Return true if the column is now occupied, or the move won, or if it was a stalemate
        return(board.IsSpaceOccupied(column, 0) || board.CheckForWinIncremental(move.playerId, move.coord) || board.CheckForStalemate());
    }
        public static ConnectFour Get_CF_TopLeftToBottomRight_Diagonal_Yellow_Win_Check(int rows, int columns)
        {
            ConnectFour connectFour = new ConnectFour(rows, columns);

            // Column 0
            connectFour.Drop('y', 0);

            // Column 1
            connectFour.Drop('r', 1);
            connectFour.Drop('y', 1);

            // Column 2
            connectFour.Drop('r', 2);
            connectFour.Drop('y', 2);
            connectFour.Drop('y', 2);

            // Column 3
            connectFour.Drop('r', 3);
            connectFour.Drop('y', 3);
            connectFour.Drop('r', 3);
            connectFour.Drop('y', 3);

            return(connectFour);
        }
        public static ConnectFour Get_CF_Game_Draw_6Rows_6Columns()
        {
            ConnectFour connectFour = new ConnectFour(6, 6);

            // Column 0
            connectFour.Drop('y', 0);
            connectFour.Drop('r', 0);
            connectFour.Drop('y', 0);
            connectFour.Drop('r', 0);
            connectFour.Drop('y', 0);
            connectFour.Drop('r', 0);

            // Column 1
            connectFour.Drop('y', 1);
            connectFour.Drop('r', 1);
            connectFour.Drop('y', 1);
            connectFour.Drop('r', 1);
            connectFour.Drop('y', 1);
            connectFour.Drop('r', 1);

            // Column 2
            connectFour.Drop('r', 2);
            connectFour.Drop('y', 2);
            connectFour.Drop('r', 2);
            connectFour.Drop('y', 2);
            connectFour.Drop('r', 2);
            connectFour.Drop('y', 2);

            // Column 3
            connectFour.Drop('r', 3);
            connectFour.Drop('y', 3);
            connectFour.Drop('r', 3);
            connectFour.Drop('y', 3);
            connectFour.Drop('r', 3);
            connectFour.Drop('y', 3);
            connectFour.Drop('r', 3);
            connectFour.Drop('y', 3);

            // Column 4
            connectFour.Drop('y', 4);
            connectFour.Drop('r', 4);
            connectFour.Drop('y', 4);
            connectFour.Drop('r', 4);
            connectFour.Drop('y', 4);
            connectFour.Drop('r', 4);

            // Column 5
            connectFour.Drop('y', 5);
            connectFour.Drop('r', 5);
            connectFour.Drop('y', 5);
            connectFour.Drop('r', 5);
            connectFour.Drop('y', 5);
            connectFour.Drop('r', 5);

            return(connectFour);
        }