<commit_before>module TicTacToe
  class Player
    attr_reader :token
    
    def initialize(token)
      @token = token
      @knowledge = Hash.new {|hash, key| hash[key] = []} 
    end
    
    def next_move(status)
      @last_status = status
      @last_move = has_knowledge? ? educated_guess : next_sequential
    end
    
    def good_move
      record_score 1
    end

    def bad_move
      record_score -1
    end
    
    def educated_guess
      next_m = []
      known_moves.inject(0) do |high_score, hash|
        next_m = hash.keys[0] if hash.values[0] > high_score
        high_score
      end
      next_m
    end
    
    def known_moves
      @knowledge[@last_status]
    end
    
    def has_knowledge?
      @knowledge.has_key? @last_status
    end
    
  private
  
    def record_score(value)
      @knowledge[@last_status] << {@last_move => value}
    end
    
    def next_sequential
      (0..2).each do |r|
        (0..2).each do |c|
          return [r, c] if @last_status[r][c].nil?
        end
      end
    end
  end
end<commit_msg>renamed educated_guess<commit_after>module TicTacToe
  class Player
    attr_reader :token
    
    def initialize(token)
      @token = token
      @knowledge = Hash.new {|hash, key| hash[key] = []} 
    end
    
    def next_move(status)
      @last_status = status
      @last_move = has_knowledge? ? highest_score_move : next_sequential_move
    end
    
    def good_move
      record_score 1
    end

    def bad_move
      record_score -1
    end
    
    def highest_score_move
      next_m = []
      known_moves.inject(0) do |high_score, hash|
        next_m = hash.keys[0] if hash.values[0] > high_score
        high_score
      end
      next_m
    end
    
    def known_moves
      @knowledge[@last_status]
    end
    
    def has_knowledge?
      @knowledge.has_key? @last_status
    end
    
  private
  
    def record_score(value)
      @knowledge[@last_status] << {@last_move => value}
    end
    
    def next_sequential_move
      (0..2).each do |r|
        (0..2).each do |c|
          return [r, c] if @last_status[r][c].nil?
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.08732001857872736, 'fraction_numerical': 0.008360427310729215, 'mean_word_length': 1.9029649595687332, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '631056', 'n_tokens_mistral': 758, 'n_tokens_neox': 739, 'n_words': 170}