Module: EloRatingSystem
- Defined in:
- lib/elo_rating_system.rb
Overview
Elo rating system
Class Method Summary collapse
Class Method Details
.elo(old, exp, score, k_factor = 32) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/elo_rating_system.rb', line 15 def self.elo(old, exp, score, k_factor = 32) # @note Calculate the new Elo rating for a player. # # @param old [Integer] The previous Elo rating. # @param exp [Float] The expected score for this match. # @param score [Float] The actual score for this match. # @param k_factor [Integer] The k-factor for Elo (default: 32). old + k_factor * (score - exp) end |
.expected(player_a, player_b) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/elo_rating_system.rb', line 7 def self.expected(player_a, player_b) # @note Calculate expected score of A in a match against B. # # @param player_a [Integer] Elo rating for player a. # @param player_b [Integer] Elo rating for player b. 1 / (1 + 10**((player_b - player_a.to_f) / 400)) end |