Code Monkey home page Code Monkey logo

trueskill's Introduction

trueskill

trueskill is a rating-system for games with an arbitrary number of teams and players developed by Microsoft Research. It is based on the Glicko rating system and solves some major flaws of the ELO system.

Usage

Factor Graph

Example:

require 'rubygems'
require 'saulabs/trueskill'

include Saulabs::TrueSkill

# team 1 has just one player with a mean skill of 27.1, a skill-deviation of 2.13
# and an play activity of 100 %
team1 = [Rating.new(27.1, 2.13, 1.0)]

# team 2 has two players
team2 = [Rating.new(22.0, 0.98, 0.8), Rating.new(31.1, 5.33, 0.9)]

# team 1 finished first and team 2 second
graph = FactorGraph.new(team1 => 1, team2 => 2)

# update the Ratings
graph.update_skills

Score Based Bayesian Rating

As an extension of the basic TrueSkill algorithm, a score based Bayesian rating method is implemented. Similar to the standard approach, the actual skill is updated based on the outcome of the game. Instead of ranks, the score difference of playes determines the skill updates.

The approach implemented is a generalization of the Gaussian Score Difference model as proposed in Score-based Bayesian Skill Learning.

Example:

require 'rubygems'
require 'saulabs/trueskill'

include Saulabs::TrueSkill

# team 1 has just one player with a mean skill of 27.1, a skill-deviation of 2.13
# and an play activity of 100 %
team1 = [Rating.new(27.1, 2.13, 1.0)]

# team 2 has two players
team2 = [Rating.new(22.0, 0.98, 0.8), Rating.new(31.1, 5.33, 0.9)]

# team 1 wins by 10 points against team 2
graph = ScoreBasedBayesianRating.new(team1 => 10.0, team2 => -10.0)

# update the Ratings
graph.update_skills

Installation

To install the TrueSkill gem, simply run

[sudo] gem install trueskill

Add the following to your script:

require 'saulabs/trueskill'

Known issues

  • The calculation of the ranking probability is not yet implemented

Plans

  • Generalize the method from the team vs team case to a general case with arbitrary number of teams

Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.

Copyright

© 2010 Lars Kuhnt (http://saulabs.net).

See LICENSE for details.

trueskill's People

Contributors

chrislundquist avatar duett avatar larskuhnt avatar mk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

trueskill's Issues

the order of teams appears to change after 'update_skills'

Hi,

Thanks for going through the trouble of creating this code!

When I set team ranks in some arbitrary order, say, [3, 1, 2], I am not sure how to match the updated scores to the original teams. E.g. starting from equal mean assumptions, the above ordering of game ranks, leads to the first team on the list having the highest posterior mean.

I made a spec that is a reshuffle of one of your specs. I would think it should pass.

describe 'standard rating and reverse order of wins' do

before :each do
  TrueSkill::FactorGraph.new(@teams, [2,1]).update_skills
end

it "should change second player's rating to [29.395832, 7.1714755]" do
  @teams[1][0].should eql_rating(29.395832, 7.1714755)
end

it "should change first player's rating to [20.6041679, 7.1714755]" do
  @teams[0][0].should eql_rating(20.6041679, 7.1714755)
end

end

Thanks,
Mike.

update_skills can result in an infinite loop

Hi,

There is a bug in the class FactorGraph. For some inputs, the method update_skills goes into an infinite loop.

Here is a simple example to reproduce the problem

require 'saulabs/trueskill'
include Saulabs::TrueSkill

scores = [[45, 0.5, 0.6],[9, 0.9, 0.8],[54, 0.1, 0.7]]
graph = FactorGraph.new(scores, (1..scores.size).to_a)
graph.update_skills

Same problem happens with the triplets:

[52, 0.0, 0.9],[52, 0.9, 0.9],[86, 0.6, 0.9]
[9, 0.1, 0.6],[6, 0.0, 0.4],[47, 1.0, 0.3]
[63, 0.3, 0.5],[40, 0.9, 0.7],[70, 0.7, 0.7]
[95, 0.8, 0.1],[58, 0.0, 0.3],[11, 0.9, 0.8]
[83, 0.8, 0.8],[91, 0.7, 0.7],[86, 0.4, 1.0]
[17, 6, 0.1],[26, 9, 0.2],[74, 9, 0.3]
[15, 3, 0.1],[5, 2, 0.4],[53, 7, 0.5]
[40, 8, 0.4],[94, 5, 0.4],[88, 7, 0.9]
[43, 7, 0.5],[74, 3, 0.6],[87, 8, 0.5]
[26, 2, 0.6],[3, 3, 0.7],[64, 8, 0.9]
[4, 1, 0.5],[12, 1, 0.5],[39, 1, 0.5]
[10, 1, 1],[15, 1, 1],[67, 2, 0.5]

Thanks

Order of hash matters

graph = FactorGraph.new(team1 => 1, team2 => 2)
graph.update_skills

returns a different result than

graph = FactorGraph.new(team2 => 2, team1 => 1)
graph.update_skills

Publish a new gem with the latest changes

Please publish a new gem with the latest changes.

The documentation is updated and reciprocates the code.
But, the last published gem is the older one and does not have the new changes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.