Skip to content

For calculating the Elo ratings of chess players from their tournament results

License

Notifications You must be signed in to change notification settings

ninkibah/icu_ratings

 
 

Repository files navigation

ICU Chess Ratings

For calculating the Elo ratings of players in a chess tournament. The software is a port the Irish Chess Union’s existing rating software written in Microsoft Visual Basic and intended to replace it in the near future.

The rating calculations are the same as FIDE’s for tournaments that consist entirely of established players with the exception of player bonuses (which can be turned off) and different rules for assigning K-factors. However, the ICU has it’s own peculiar way of dealing with unrated players (players with only a provisional rating or without any prior rating) which is different to FIDE’s.

Install

sudo gem install icu_ratings

Tested on Ruby 1.9.2, 1.9.3, 2.2.0 and 2.2.0. Version 1.0.5 was the last to support Ruby 1.8.7.

Usage

First, create a new ICU::RatedTournament object:

t = ICU::RatedTournament.new(:desc => "Irish Championships 2008")

Then add players (see ICU::RatedPlayer for details):

t.add_player(1, :rating => 2534, :desc => 'Alexander Baburin (7085)', :kfactor => 16)
t.add_player(2, :rating => 2525, :desc => 'Alon Greenfeld')  # foreign (non-ICU) rated player
t.add_player(8, :rating => 2084, :desc => 'Anthony Fox (456)', :kfactor => 24)
# ...

Then add results (see ICU::RatedResult for details):

t.add_result(1, 1, 8, 'W')    # players 1 and 8 played in round 1, player 1 won
t.add_result(4, 2, 1, 'D')    # players 1 and 2 drew in round 4
# ...

Then call the rate! method using the recommended version of the algorithm (see ICU::RatedTournament).

t.rate!(version: 2)

If no exceptions have been raised yet, the tournament is now rated and the main results of the rating calculations can be extracted by querying the previously created player objects:

(1..32).each do |num|
  player = t.player(num)
  puts "Name: #{t.desc}"
  puts "Score: #{p.score}/#{p.results.size}"
  puts "New Rating: #{p.new_rating.round}"
  puts "Performance Rating: #{p.performance.round}"
end

# Name: Alexander Baburin (7085)
# Score: 8.0/9
# New Rating: 2558
# Performance Rating: 2607
# ...

See ICU::RatedPlayer for further details. Further breakdown of the rating calculations are available, if desired, from the results belonging to each player. See ICU::RatedResult for more details.

Author

Mark Orr, Irish Chess Union (ICU) rating officer.

About

For calculating the Elo ratings of chess players from their tournament results

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%