Merge pull request #671 from OutThisLife/patch-1
ELO snippet formatting + performance
This commit is contained in:
@ -17,13 +17,12 @@ const elo = ([...ratings], kFactor = 32, selfRating) => {
|
||||
(selfRating || rating) + kFactor * (i - expectedScore(i ? a : b, i ? b : a));
|
||||
if (ratings.length === 2) {
|
||||
return [newRating(a, 1), newRating(b, 0)];
|
||||
} else {
|
||||
for (let i = 0; i < ratings.length; i++) {
|
||||
let j = i;
|
||||
while (j < ratings.length - 1) {
|
||||
[ratings[i], ratings[j + 1]] = elo([ratings[i], ratings[j + 1]], kFactor);
|
||||
j++;
|
||||
}
|
||||
}
|
||||
for (let i = 0, len = ratings.length; i < len; i++) {
|
||||
let j = i;
|
||||
while (j < len - 1) {
|
||||
j++;
|
||||
[ratings[i], ratings[j]] = elo([ratings[i], ratings[j]], kFactor);
|
||||
}
|
||||
}
|
||||
return ratings;
|
||||
|
||||
Reference in New Issue
Block a user