Class: ActiveGenie::Ranker::Elo

Inherits:
Object
  • Object
show all
Defined in:
lib/active_genie/ranker/elo.rb

Constant Summary collapse

DEBATE_PER_PLAYER =
3
K =
32

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(players, criteria, config: nil) ⇒ Elo

Returns a new instance of Elo.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/active_genie/ranker/elo.rb', line 10

def initialize(players, criteria, config: nil)
  @players = players
  @higher_tier = players.calc_higher_tier
  @lower_tier = players.calc_lower_tier
  @criteria = criteria
  @initial_config = config
  @tmp_highers = []
  @total_tokens = 0
  @previous_elo = @players.to_h { |player| [player.id, player.elo] }
  @previous_highest_elo = @higher_tier.max_by(&:elo).elo
end

Class Method Details

.callObject



6
7
8
# File 'lib/active_genie/ranker/elo.rb', line 6

def self.call(...)
  new(...).call
end

Instance Method Details

#callObject



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/active_genie/ranker/elo.rb', line 22

def call
  config.log.add_observer(observers: ->(log) { log_observer(log) })
  config.log.additional_context = { elo_id: }

  ActiveGenie::FiberByBatch.call(matches, config:) do |player_a, player_b|
    winner, loser = debate(player_a, player_b)

    update_players_elo(winner, loser)
  end

  elo_result
end