Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_best_move(board, scores):
- """
- Return best move [tuple (row, column)] for the given board,
- based on the given list of scores.
- """
- best_moves = []
- for empty_sq in board.get_empty_squares():
- if best_moves:
- if scores[empty_sq[0]][empty_sq[1]] > scores[best_moves[0][0]][best_moves[0][1]]:
- best_moves = []
- best_moves.append(empty_sq)
- elif scores[empty_sq[0]][empty_sq[1]] == scores[best_moves[0][0]][best_moves[0][1]]:
- best_moves.append(empty_sq)
- else:
- best_moves.append(empty_sq)
- if best_moves:
- return random.choice(best_moves)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement