TrueSkill in F#

Following the publication of the F# source code for the TrueSkill Through Time paper, we have used the same inference library code to demonstrate how the original TrueSkill algorithm can be coded. In the attached source code, only the program.fs file is different to the TrueSkill through Time blog post and it builds up the factor graph for an arbitrary N-player game with an arbitrary draw probability. Both these numbers can be entered on the command line when running the resulting sample. We tried to make sure to stay as close as possible to the description on page 3 of the TrueSkill technical report.

The attached ZIP file contains the entire source code which should compile without problems with F# You can either load the solution in Visual Studio 2008 or simply run build.bat form the command line - in either case you will end up with a trueskill.exe program.

Update: Following the release of the F# September 2008 CTP we have updated the source code to work with F# Also, we added one of the new features of F#, namely units-of-measure, which makes the TrueSkill update invocation calls now read as follows:

    let priorMu = 25.0<SkillPoints>

    let priorSigma = priorMu / 3.0

    let priorSkills = Array.init noPlayers (fun i -> Gaussian.Create (priorMu, priorSigma))

    let (posteriorSkills, logZ) =

        NPlayerTrueSkillUpdate (0.5*priorSigma, 0.01*priorSigma, drawProb / 100.0) priorSkills

Note that one can no longer accidentally pass the variance instead of the standard deviation because the former being of type float<SkillPoints^2>. Try yourself!

Update 2: We had some feedback from Andrew Kennedy that we exploited a current "bug" in the units-of-measure code where literals (such as 1.0) can have generic units. We removed the incorrect usages and re-posted the ZIP file. 

Update 3: We extended the example to work with draws. Thanks to Chih-Jen Lin for the suggestion! 


Ralf Herbrich & Thore Graepel

TrueSkill -

Comments (44)

Cancel reply

  1. Anonymous says:

    Some time ago, I speculated that F# should be the lingua-franca of BI . Well, had I done a little research,

  2. Anonymous says:

    Very nice sample program, but it doesn’t show how TrueSkill handles team games.

    Any hope of seeing how this works? The details page says that teams are compared using a sum of the players, but that doesn’t show how each of the players are updated after that comparison.  

    Is it just a comparison of each player on the other team after that?

  3. Josh Menke says:

    Hey thanks guys, this is great!

  4. nick says:

    Is it possible to go up in rank after you lose a match?

  5. J.Goodwin says:


    No.  Even in an absolutely lopsided situation where TrueSkill would avoid making the matchup if at all possible, the best you can do is remain at your current ranking.

    For instance, run a situation where the winning player has 100 mu, and 0.1 sigma, and the losing player has 1 mu and 0.1 sigma.  In this case, the system knows pretty much definitively that these two players are a very bad match (0.0% match quality), and the losing player still won’t gain anything by losing, even though he lost to a player who was much higher ranked.

    The same is going to pretty much hold true in a less theoretical situation, where a very good Halo player (rank 50) who has played a lot of games (and therefore has a low sigma) plays against a freshman player (rank 25, sigma 8.333).  The lower ranked player will lose very little mu for losing the match, but won’t gain any mu.  Their sigma will also not decrease very much because the match was so bad.

  6. wendys nutritional information canada says:

    <a href=’‘>wendys nutritional information canada</a> <a href="">wendys nutritional information canada</a> [link=]wendys nutritional information canada[/link]

  7. movie the wendell baker story says:

    movie the wendell baker story [URL=]movie the wendell baker story[/URL] [url=]movie the wendell baker story[/url] [url][/url]

  8. what other people think says:

    what other people think [URL=]what do you care what other people think[/URL] [url=]what other people think[/url] [url][/url]

  9. abilene city says:

    <a href=’‘>city of abilene employment</a> <a href="">city of abilene tx</a> [link=]abilene city jobs[/link]

  10. oxycontin crushed says:

    <a href=’‘>oxycontin crushed</a> <a href="">oxycontin crushed</a> [link=]oxycontin crushed[/link]

  11. winamp registration key generator says:

    winamp registration key generator [URL=]winamp registration key generator[/URL] [url=]winamp registration key generator[/url] [url][/url]

  12. keine lust video rammstein says:

    keine lust video rammstein [URL=]keine lust video rammstein[/URL] [url=]keine lust video rammstein[/url] [url][/url]

  13. cold purple feet from adderall xr says:

    <a href=’‘>cold purple feet from adderall xr</a> <a href="">cold purple feet from adderall xr</a> [link=]cold purple feet from adderall xr[/link]

  14. aid sleep wellbutrin xl says:

    aid sleep wellbutrin xl [URL=]aid sleep wellbutrin xl[/URL] [url=]aid sleep wellbutrin xl[/url] [url][/url]

  15. en language position report says:

    en language position report [URL=]en language position report[/URL] [url=]en language position report[/url] [url][/url]

  16. plate tectonics says:

    define plate tectonics [URL=]plate tectonics activity[/URL] [url=]continent plate tectonics theory[/url] [url][/url]

  17. movie of the year 1975 says:

    <a href=’‘>movie of the year 1975</a> <a href="">movie of the year 1975</a> [link=]movie of the year 1975[/link]

  18. walhalla sc county says:

    <a href=’‘>walhalla sc county</a> <a href="">walhalla sc county</a> [link=]walhalla sc county[/link]

  19. serenity the movie release date says:

    <a href=’‘>serenity the movie release date</a> <a href="">serenity the movie release date</a> [link=]serenity the movie release date[/link]

  20. history of martin luther king says:

    <a href=’‘>history of martin luther king</a> <a href="">history of martin luther king</a> [link=]history of martin luther king[/link]

  21. process portfolio management says:

    <a href=’‘>process portfolio management</a> <a href="">process portfolio management</a> [link=]business governance management portfolio process[/link]

  22. colorado revised statutes says:

    colorado revised statutes [URL=]colorado revised statutes[/URL] [url=]colorado revised statutes[/url] [url][/url]

  23. park audio and video altoona says:

    park audio and video altoona [URL=]park audio and video altoona[/URL] [url=]park audio and video altoona[/url] [url][/url]

  24. egon schiele says:

    <a href=’‘>egon schiele</a> <a href="">egon schiele</a> [link=]egon schiele[/link]

  25. lowest airfares online says:

    lowest airfares online [URL=]lowest airfares online[/URL] [url=]lowest airfares online[/url] [url][/url]

  26. Over says:

    OMG i’m playing gears 2, I get rank 4 then i played 6 matches, I won all of them and now I’m again rank 3!!

    mmmm…don’t trueskill estimate your skill looking the win/lost matches??

    I think not, come on this system can work for many games but not for gears!!

  27. kid rock tickets says:

    Some time ago, I speculated that F# should be the lingua-franca of BI . Well, had I done a little research,


  28. kid rock tickets says:

    Some time ago, I speculated that F# should be the lingua-franca of BI . Well, had I done a little research,


  29. kid rock tickets says:

    Some time ago, I speculated that F# should be the lingua-franca of BI . Well, had I done a little research,


  30. Jassim says:

    I don't know whether its the right forum to ask this. But then I don't know where else.

    I am planning to create a gaming website, and wanted to use Trueskill rating algorithm. But since it is a trademark by Microsoft, am I allowed to do so?

  31. purushottam says:

    "I like what you guys are usually up too. Such clever work and coverage! Keep up the wonderful works guys I’ve added you guys to blogroll. "

    If you love gaming for unity games kindly visit….> mobile app development

Skip to main content