diff --git a/lib/rank_king.rb b/lib/rank_king.rb index de7e0e4..384f916 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).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).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 5234be3..6487474 100644 --- a/lib/rank_king/open_skill.rb +++ b/lib/rank_king/open_skill.rb @@ -17,8 +17,7 @@ module RankKing @beta = @sigma / 2.0 end - # TODO take an implicit array - def rate(teams) + def rate(*teams) # allow for passing in single-rating teams teams = teams.map { Array(_1) } diff --git a/test/open_skill_test.rb b/test/open_skill_test.rb index 4d0c148..9481851 100644 --- a/test/open_skill_test.rb +++ b/test/open_skill_test.rb @@ -18,7 +18,7 @@ class TestRate < Minitest::Test end def test_rate - a2, b2, c2, d2 = @os.rate([[@a1], [@b1], [@c1], [@d1]]).flatten + a2, b2, c2, d2 = @os.rate([@a1], [@b1], [@c1], [@d1]).flatten assert_rating a2, OpenSkill::Rating.new(mu: 30.209971908310553, sigma: 4.764898977359521) assert_rating b2, OpenSkill::Rating.new(mu: 27.64460833689499, sigma: 4.882789305097372)