|
|
@ -5,14 +5,17 @@ module RankKing
|
|
|
|
OS = OpenSkill.new
|
|
|
|
OS = OpenSkill.new
|
|
|
|
Match = Data.define(:a, :b)
|
|
|
|
Match = Data.define(:a, :b)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# rates all possible 1v1 games to find which generally decreases sigma
|
|
|
|
|
|
|
|
# regardless of the winner/loser - is this mathematically sound? I have
|
|
|
|
|
|
|
|
# no idea
|
|
|
|
def self.suggest_game(axis)
|
|
|
|
def self.suggest_game(axis)
|
|
|
|
items = axis.pool.items
|
|
|
|
items = axis.pool.items
|
|
|
|
|
|
|
|
ratings = items.to_h { [_1.id, Rating.first(axis:, item: _1) || OS.rating] }
|
|
|
|
|
|
|
|
|
|
|
|
items.combination(2).sort_by {|combo|
|
|
|
|
items.combination(2).sort_by {|combo|
|
|
|
|
# TODO get all the ratings at once
|
|
|
|
game = combo.map { ratings.fetch(_1.id) }
|
|
|
|
ratings = combo.map {|item| Rating.first(axis:, item:) || OS.rating }
|
|
|
|
|
|
|
|
Math.sqrt(
|
|
|
|
Math.sqrt(
|
|
|
|
[ratings, ratings.reverse]
|
|
|
|
[game, game.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 }}
|
|
|
|
.sum {|pre,post| pre.zip(post).sum { (_1.sigma - _2.sigma)**2 }}
|
|
|
|
)
|
|
|
|
)
|
|
|
|