diff options
author | tkimia <tkimia@purdue.edu> | 2014-04-29 16:45:01 -0400 |
---|---|---|
committer | tkimia <tkimia@purdue.edu> | 2014-04-29 16:45:01 -0400 |
commit | a3392e334f15dd852f550411394c27b3327db1e9 (patch) | |
tree | 46b67d2c5fd004d81b936e4d6a68f80f9cc8ff32 /lib/scoring/fibonacci_peer_with_blowout.rb | |
parent | 42d6e3b1cc05ef5172081682b53675e4827254d3 (diff) | |
parent | d2da4866962e69fda4f3078afd19dbaf3d245882 (diff) |
Merge branch 'master' of https://github.com/LukeShu/leaguer
Conflicts:
app/models/match.rb
lib/scoring/winner_takes_all.rb
Diffstat (limited to 'lib/scoring/fibonacci_peer_with_blowout.rb')
-rw-r--r-- | lib/scoring/fibonacci_peer_with_blowout.rb | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/scoring/fibonacci_peer_with_blowout.rb b/lib/scoring/fibonacci_peer_with_blowout.rb index 9d72643..a13d76c 100644 --- a/lib/scoring/fibonacci_peer_with_blowout.rb +++ b/lib/scoring/fibonacci_peer_with_blowout.rb @@ -1,15 +1,17 @@ module Scoring module FibonacciPeerWithBlowout - def self.stats_needed - return ["votes", "win", "blowout"] + def self.stats_needed(match) + return ["votes", "win", "blowout"] + match.users.map{|u|"review_from_#{u.user_name}"} end def self.score(match) scores = {} match.users.each do |user| - stats = Statistic.where(user: user, match: match) - - votes = stats.where(name: "votes" ).first.value + stats = user.statistics.where(match: match) + votes = 0 + match.users.each do |u| + votes += convert_place_to_votes stats.where(name: "review_from_#{u.user_name}").first.value + end win = stats.where(name: "win" ).first.value blowout = stats.where(name: "blowout").first.value scores[user] = self.score_user(votes, win, blowout) @@ -23,5 +25,9 @@ module Scoring fibonacci = Hash.new { |h,k| h[k] = k < 2 ? k : h[k-1] + h[k-2] } fibonacci[votes+3] + (win ? blowout ? 12 : 10 : blowout ? 5 : 7) end + + def self.convert_place_to_votes(place) + (place == 0 or place == 1) ? 1 : 0 + end end end |