Given a representation of the board, returns reward and done.

def get_reward_and_done(board):
  """Given a representation of the board, returns reward and done."""
  # Returns (reward, done) where:
  # reward: -1 means lost, +1 means win, 0 means draw or continuing.
  # done: True if the game is over, i.e. someone won or it is a draw.

  # Sum all rows ...
  all_sums = [np.sum(board[i, :]) for i in range(3)]
  # ... all columns
  all_sums.extend([np.sum(board[:, i]) for i in range(3)])
  # and both diagonals.
  all_sums.append(np.sum([board[i, i] for i in range(3)]))
  all_sums.append(np.sum([board[i, 2 - i] for i in range(3)]))

  if -3 in all_sums:
    return -1, True

  if 3 in all_sums:
    return 1, True

  done = True
  if get_open_spaces(board):
    done = False

  return 0, done