Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions OpenSkillSharp.Tests/Models/Data/plackettluce.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,21 @@
],
"team_2": [
{
"mu": 23.083700519022745,
"mu": 20.599656070925114,
"sigma": 8.222674397835641
},
{
"mu": 21.717476072569045,
"mu": 20.47545384852023,
"sigma": 8.277466291367071
}
],
"team_3": [
{
"mu": 21.717476072569045,
"mu": 20.47545384852023,
"sigma": 8.277466291367071
},
{
"mu": 23.083700519022745,
"mu": 20.599656070925114,
"sigma": 8.222674397835641
}
],
Expand Down Expand Up @@ -160,7 +160,7 @@
"ties": {
"team_1": [
{
"mu": 23.241111866333558,
"mu": 21.63766806988004,
"sigma": 8.310709773172306
}
],
Expand All @@ -176,15 +176,15 @@
],
"team_3": [
{
"mu": 21.479966996534408,
"mu": 19.87652320008089,
"sigma": 8.237522411103104
},
{
"mu": 21.479966996534408,
"mu": 19.87652320008089,
"sigma": 8.237522411103104
},
{
"mu": 21.479966996534408,
"mu": 19.87652320008089,
"sigma": 8.237522411103104
}
]
Expand Down Expand Up @@ -261,4 +261,4 @@
}
]
}
}
}
12 changes: 12 additions & 0 deletions OpenSkillSharp.Tests/Models/PlackettLuceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,16 @@ public void Rate_Balance()
// Assert
Assertions.RatingResultsEqual(expectedRatings, results);
}

[Fact]
public void Rate_AllScoresTied()
{
PlackettLuce model = new PlackettLuce { Mu = 30, Sigma = 30.0 / 3 };

ITeam[] teams = [new Team { Players = [model.Rating()] }, new Team { Players = [model.Rating()] }];
ITeam[] result = model.Rate(teams, scores: [0, 0]).ToArray();

Assert.Equal(30, result[0].Players.Single().Mu);
Assert.Equal(30, result[1].Players.Single().Mu);
}
}
2 changes: 1 addition & 1 deletion OpenSkillSharp/Models/PlackettLuce.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected override IEnumerable<ITeam> Compute(
return (
sumOmega: acc.sumOmega + (
iTeamIndex == qTeamIndex
? 1 - (iMuOverCeOverSumQ / rankOccurrences[qTeamIndex])
? (1 - iMuOverCeOverSumQ) / rankOccurrences[qTeamIndex]
: -1 * iMuOverCeOverSumQ / rankOccurrences[qTeamIndex]
),
sumDelta: acc.sumDelta +
Expand Down
1 change: 1 addition & 0 deletions OpenSkillSharp/OpenSkillModelBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ protected IEnumerable<double> CalculateMarginAdjustedMu(
double sign = qTeamScore > iTeamScore ? 1D : -1D;
return (qTeam.Mu - iTeam.Mu) * (marginFactor - 1) * sign;
})
.DefaultIfEmpty(0)
.Average();

return qTeam.Mu + muAdjustment;
Expand Down