glicko2.cr

A Crystal implementation of the Glicko-2 rating system

Glicko2

A Crystal implementation of the Glicko-2 rating system by Mark Glickman.

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      glicko2:
        github: seanyeh/glicko2.cr
    
  2. Run shards install

Usage

Basic Example

require "glicko2"

system = Glicko2::System.new(tau: 0.5)

# Create players
alice = Glicko2::Player.new(1500.0, 200.0, 0.06)
bob = Glicko2::Player.new(1400.0, 200.0, 0.06)
charlie = Glicko2::Player.new(1600.0, 200.0, 0.06)
dave = Glicko2::Player.new(1550.0, 200.0, 0.06)

# Create rating period with all players
period = Glicko2::RatingPeriod.new(system, [alice, bob, charlie, dave])

# Record all games from this period
# Note: Dave did not play any games, so his RD will increase due to inactivity
games = [
  Glicko2::Game.new(alice, bob, 1.0),     # Alice beats Bob
  Glicko2::Game.new(alice, charlie, 0.0), # Alice loses to Charlie
  Glicko2::Game.new(bob, charlie, 0.5),   # Bob draws Charlie
]

# Generate next period with updated ratings
next_period = period.generate_next(games)

next_period.players.each do |player|
  puts "Rating: #{player.rating}, RD: #{player.rating_deviation}"
end

Contributing

  1. Fork it (https://github.com/seanyeh/glicko2.cr/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request
Repository

glicko2.cr

Owner
Statistic
  • 0
  • 0
  • 0
  • 0
  • 1
  • about 1 month ago
  • December 25, 2025
License

MIT License

Links
Synced at

Sun, 25 Jan 2026 01:36:11 GMT

Languages