예제 #1
0
파일: test.py 프로젝트: cbw36/Tic-Tac-Toe
    def test_evaluate_board(self):
        player = ComputerPlayer(0, "cpu", "X")

        # Check a win state
        win_board = [["X", "O", "-"], ["O", "X", "O"], ["-", "X", "X"]]
        value = player.evaluate_board(win_board, 2)
        self.assertEqual(value, WINNER,
                         "Didnt recognize a won board configuration")

        # Check a win state with a full board
        win_board = [["X", "O", "X"], ["O", "X", "O"], ["O", "X", "X"]]
        value = player.evaluate_board(win_board, 0)
        self.assertEqual(value, WINNER,
                         "Didnt recognize a won board configuration")

        # Check a loss state
        loss_board = [["-", "X", "O"], ["-", "O", "X"], ["O", "X", "-"]]
        value = player.evaluate_board(loss_board, 3)
        self.assertEqual(value, LOSER,
                         "Didnt recognize a lost board configuration")

        # Check a loss state with full board
        loss_board = [["X", "X", "O"], ["O", "O", "X"], ["O", "X", "X"]]
        value = player.evaluate_board(loss_board, 0)
        self.assertEqual(value, LOSER,
                         "Didnt recognize a lost board configuration")

        # Check a tie state
        tie_board = [["X", "X", "O"], ["O", "O", "X"], ["X", "O", "X"]]
        value = player.evaluate_board(tie_board, 0)
        self.assertEqual(value, TIED,
                         "Didnt recognize a tied board configuration")

        # Check an in progress state
        in_progress_board = [["X", "X", "O"], ["O", "X", "X"], ["X", "O", "-"]]
        value = player.evaluate_board(in_progress_board, 1)
        self.assertEqual(value, IN_PROGRESS,
                         "Didnt recognize an in progress board configuration")