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# 220.127.116.11. 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# 18.104.22.168. 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