allow for rating single-rating teams

main
Alpha Chen 1 year ago
parent 3384461caa
commit ef8289c7f1
Signed by: alpha
SSH Key Fingerprint: SHA256:3fOT8fiYQG/aK9ntivV3Bqtg8AYQ7q4nV6ZgihOA20g

@ -13,7 +13,7 @@ module RankKing
ratings = combo.map {|item| Rating.first(axis:, item:) || OS.rating }
Math.sqrt(
[ratings, ratings.reverse]
.map {|game| [game, OS.rate(game.map {[_1]}).flatten] }
.map {|game| [game, OS.rate(game).flatten] }
.sum {|pre,post| pre.zip(post).sum { (_1.sigma - _2.sigma)**2 }}
)
}.last
@ -23,7 +23,7 @@ module RankKing
fail unless [winner, loser].all? { _1.pool == axis.pool }
game = [winner, loser].map { Rating.first(axis:, item: _1) || OS.rating }
result = OS.rate(game.map { [_1] }).flatten
result = OS.rate(game).flatten
DB.transaction do
Ranking.create(axis:, winner:, loser:)

@ -18,8 +18,10 @@ module RankKing
end
# TODO take an implicit array
# TODO array-ify elements
def rate(teams)
# allow for passing in single-rating teams
teams = teams.map { Array(_1) }
# tau keeps sigma from dropping too low so that ratings stay pliable
# after many games
tau_sq = @tau ** 2

Loading…
Cancel
Save