Пример #1
0
 def test_game_over_with_win(self):
     board = get_board(xes=[3, 5, 7], oes=[2, 4])
     player = ComputerPlayerO(board)
     next_move = player.play()
     self.assertEqual(next_move, 6)
     game_over, winning_squares = player.is_game_over()
     self.assertTrue(game_over)
     self.assertEqual(winning_squares, [2, 4, 6])
Пример #2
0
def computer_turn():
    board = request.args.get("board[]", "")
    board = json.loads(board)
    computer = ComputerPlayerO(board)
    move = computer.play()
    game_over, winning_squares = computer.is_game_over()
    return jsonify(
        square=move,
        game_over=game_over,
        winning_squares=winning_squares
    )
Пример #3
0
 def test_tie_game(self):
     board = get_board(xes=[0, 2, 5, 6, 7], oes=[1, 3, 4, 8])
     player = ComputerPlayerO(board)
     game_over, winning_squares = player.is_game_over()
     self.assertTrue(game_over)
     self.assertFalse(winning_squares)