diff --git a/lib/rank_king.rb b/lib/rank_king.rb index 858bfa2..de7e0e4 100644 --- a/lib/rank_king.rb +++ b/lib/rank_king.rb @@ -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:) diff --git a/lib/rank_king/open_skill.rb b/lib/rank_king/open_skill.rb index 5598e5b..5234be3 100644 --- a/lib/rank_king/open_skill.rb +++ b/lib/rank_king/open_skill.rb @@ -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