Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(JSkill) Some calculations produce NaN #12

Open
micheljung opened this issue Apr 16, 2018 · 3 comments
Open

(JSkill) Some calculations produce NaN #12

micheljung opened this issue Apr 16, 2018 · 3 comments

Comments

@micheljung
Copy link

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

@jmichalc
Copy link

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.

@micheljung
Copy link
Author

Hi @jmichalc thanks a lot! It's a good start to know that it's not just a problem of the port :-)

@micheljung
Copy link
Author

@jmichalc @moserware Issue nsp#9 got resolved, in case you want to apply the fix to this project as well :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants