Skills
Skills copied to clipboard
(JSkill) Some calculations produce NaN
Hi, I'm a Java developer so I'm using the fork/port of this project, JSkills.
Unfortunately, the project doesn't seem to be active anymore and I ran into a blocker (nsp/JSkills#9) so my question is; does the same thing happen in Skills? Do you have any idea what could cause it?
I tried debugging the code but it's too complicated for my limited brain capacity. Any help is much appreciated.
Hi @micheljung , I'm not a developer on the project, and considering that it was last updated in 2013 I would assume this project is not active anymore either.
I was able to reproduce the results of the issue you linked from JSkills:
private static void TestOK()
{
var gameInfo = new GameInfo(1500, 500, 240, 10, 0.1);
var player1 = new Player(1);
var player1Rating = new Rating(3453, 74);
var team1 = new Team();
team1.AddPlayer(player1, player1Rating);
var player2 = new Player(2);
var player2Rating = new Rating(38, 181);
var team2 = new Team();
team2.AddPlayer(player2, player2Rating);
IEnumerable<IDictionary<Player, Rating>> teams = new List<IDictionary<Player, Rating>>()
{
team1.AsDictionary(),
team2.AsDictionary()
};
var newRatings = TrueSkillCalculator.CalculateNewRatings(gameInfo, teams, 1, 2);
foreach (var newRating in newRatings)
{
Console.WriteLine(newRating);
}
}
This method produced this output:
[1, µ=3453.0000, σ=74.6726]
[2, µ=38.0000, σ=181.2760]
Here is the NaN function:
private static void TestNaN()
{
GameInfo gameInfo = new GameInfo(1500, 500, 240, 10, 0.1);
var player1 = new Player(1);
var player1Rating = new Rating(3453, 74);
var team1 = new Team();
team1.AddPlayer(player1, player1Rating);
var player2 = new Player(2);
var player2Rating = new Rating(38, 180);
var team2 = new Team();
team2.AddPlayer(player2, player2Rating);
IEnumerable<IDictionary<Player, Rating>> teams = new List<IDictionary<Player, Rating>>()
{
team1.AsDictionary(),
team2.AsDictionary()
};
var newRatings = TrueSkillCalculator.CalculateNewRatings(gameInfo, teams, 1, 2);
foreach (var newRating in newRatings)
{
Console.WriteLine(newRating);
}
}
And it produces the NaN result like you were seeing:
[1, µ=NaN, σ=74.6726]
[2, µ=38.0000, σ=180.2776]
I won't be able to provide any help beyond this, but the problem seems to be with the calculations in Skills and the fact that JSkills is a direct fork means they reproduced the problem there too. Good luck in your investigations and hope you can get your issue resolved.
Hi @jmichalc thanks a lot! It's a good start to know that it's not just a problem of the port :-)
@jmichalc @moserware Issue nsp/JSkills#9 got resolved, in case you want to apply the fix to this project as well :)