示例#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

        uleft_bright = tictactoe_board.uleft_bright_diagonal()
        bleft_uright = tictactoe_board.bleft_uright_diagonal()

        self.assertEqual(evaluate_diagonal_win(uleft_bright), [])
        self.assertEqual(evaluate_diagonal_win(bleft_uright), [])

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

        uleft_bright = tictactoe_board.uleft_bright_diagonal()

        self.assertEqual(evaluate_diagonal_win(uleft_bright), [PLAYERX])

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

        bleft_uright = tictactoe_board.bleft_uright_diagonal()

        self.assertEqual(evaluate_diagonal_win(bleft_uright), [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.uleft_bright_diagonal(), [1, 0, 2, 0])
        self.assertEqual(tictactoe_board.bleft_uright_diagonal(), [0, 0, 2, 0])