Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. def get_best_move(board, scores):
  2. """
  3. Return best move [tuple (row, column)] for the given board,
  4. based on the given list of scores.
  5. """
  6. best_moves = []
  7. for empty_sq in board.get_empty_squares():
  8. if best_moves:
  9. if scores[empty_sq[0]][empty_sq[1]] > scores[best_moves[0][0]][best_moves[0][1]]:
  10. best_moves = []
  11. best_moves.append(empty_sq)
  12. elif scores[empty_sq[0]][empty_sq[1]] == scores[best_moves[0][0]][best_moves[0][1]]:
  13. best_moves.append(empty_sq)
  14. else:
  15. best_moves.append(empty_sq)
  16.  
  17. if best_moves:
  18. return random.choice(best_moves)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement