示例#1
0
    def test(self):
        tictactoe_board = TicTacToeBoard(4, False, None)
        tictactoe_board.board[0][0] = 1
        tictactoe_board.board[1][2] = 2
        tictactoe_board.board[0][1] = 1

        column_grid = tictactoe_board.column_grid()
        row_grid = tictactoe_board.board

        self.assertEqual(evaluate_grid_win(column_grid), [])
        self.assertEqual(evaluate_grid_win(row_grid), [])

        tictactoe_board.board[1][1] = 1
        tictactoe_board.board[2][1] = 1
        tictactoe_board.board[2][2] = 2
        tictactoe_board.board[3][1] = 1
        tictactoe_board.board[2][3] = 2

        column_grid = tictactoe_board.column_grid()

        self.assertEqual(evaluate_grid_win(column_grid), [PLAYERX])

        tictactoe_board.board[2][1] = 2
        tictactoe_board.board[2][0] = 2

        row_grid = tictactoe_board.board

        self.assertEqual(evaluate_grid_win(row_grid), [PLAYERO])
示例#2
0
    def test(self):
        tictactoe_board = TicTacToeBoard(4, False, None)
        tictactoe_board.board[0][0] = 1
        tictactoe_board.board[1][2] = 2
        tictactoe_board.board[0][1] = 1
        tictactoe_board.board[2][2] = 2
        tictactoe_board.board[3][1] = 1
        tictactoe_board.board[2][3] = 2

        self.assertEqual(
            tictactoe_board.column_grid(),
            [[1, 0, 0, 0], [1, 0, 0, 1], [0, 2, 2, 0], [0, 0, 2, 0]])