diff options
author | AndrewMurrell <amurrel@purdue.edu> | 2014-04-29 14:49:50 -0400 |
---|---|---|
committer | AndrewMurrell <amurrel@purdue.edu> | 2014-04-29 14:49:50 -0400 |
commit | 577f203243b1ac914a3ee3f4635005be06d637c6 (patch) | |
tree | 33cfa9e1a43598d22676a4c3f2f9afb8ae19b53c /lib/scoring/fibonacci_peer_with_blowout.rb | |
parent | 0d6f7a3bfbf4c87510a1bcf967b618f98e149d49 (diff) |
Fixed peer review sampling and scoring.
Diffstat (limited to 'lib/scoring/fibonacci_peer_with_blowout.rb')
-rw-r--r-- | lib/scoring/fibonacci_peer_with_blowout.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/scoring/fibonacci_peer_with_blowout.rb b/lib/scoring/fibonacci_peer_with_blowout.rb index 9d72643..ea4dec5 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"] + 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 |