Class: Glicko2::Util

Inherits:
Object
  • Object
show all
Defined in:
lib/glicko2.rb

Overview

Collection of helper methods

Class Method Summary collapse

Class Method Details

.ranks_to_score(rank, other) ⇒ Numeric

Convert from a rank, where lower numbers win against higher numbers, into Glicko scores where wins are ‘1`, draws are `0.5` and losses are `0`.

Parameters:

  • rank (Integer)

    players rank

  • other (Integer)

    opponents rank

Returns:

  • (Numeric)

    Glicko score



18
19
20
21
22
23
24
25
26
# File 'lib/glicko2.rb', line 18

def self.ranks_to_score(rank, other)
  if rank < other
    1.0
  elsif rank == other
    0.5
  else
    0.0
  end
end