def imperative_move
      # if we can win *this turn*, then take it because
      # it rates winning next turn the same as winning in 3 turns
      game.available_moves.each do |move|
        new_game = game.pristine_mark move
        return move if new_game.over? && new_game.winner == player_number
      end
      
      # if we can block the opponent from winning *this turn*, then take it, because
      # it rates losing this turn the same as losing in 3 turns
      if moves_by_rating.all? { |move, rating, game| rating == -1 }
        Game.winning_states do |position1, position2, position3|
          a, b, c = board[position1-1, 1].to_i, board[position2-1, 1].to_i, board[position3-1, 1].to_i
          if a + b + c == opponent_number * 2
            return a.zero? ? position1 : b.zero? ? position2 : position3
          end
        end
      end
    end
def imperative_move
      # if we can win *this turn*, then take it because
      # it rates winning next turn the same as winning in 3 turns
      game.available_moves.each do |move|
        new_game = game.pristine_mark move
        return move if new_game.over? && new_game.winner == player_number
      end
      
      # if we can block the opponent from winning *this turn*, then take it, because
      # it rates losing this turn the same as losing in 3 turns
      if moves_by_rating.all? { |move, rating, game| rating == -1 }
        Game.winning_states do |position1, position2, position3|
          a, b, c = board[position1-1, 1].to_i, board[position2-1, 1].to_i, board[position3-1, 1].to_i
          if a + b + c == opponent_number * 2
            return a.zero? ? position1 : b.zero? ? position2 : position3
          end
        end
      end
    end
allows us to override ratings in cases where they make the robot look stupid