diff options
author | Luke Shumaker <shumakl@purdue.edu> | 2014-04-23 20:05:30 -0400 |
---|---|---|
committer | Luke Shumaker <shumakl@purdue.edu> | 2014-04-23 20:05:30 -0400 |
commit | ae97abc3f47a7209ef8367a5781ca72ada90ddec (patch) | |
tree | c95a6db509218f0c5119856d0e84faa6118b9617 /lib/scoring/fibonacci_peer_with_blowout.rb | |
parent | a55838983eb101e6f2d6dc3a4a03f5b0d4f36c04 (diff) |
clean up lib/scoring
Diffstat (limited to 'lib/scoring/fibonacci_peer_with_blowout.rb')
-rw-r--r-- | lib/scoring/fibonacci_peer_with_blowout.rb | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/lib/scoring/fibonacci_peer_with_blowout.rb b/lib/scoring/fibonacci_peer_with_blowout.rb index 19ac9a7..8043fb7 100644 --- a/lib/scoring/fibonacci_peer_with_blowout.rb +++ b/lib/scoring/fibonacci_peer_with_blowout.rb @@ -1,16 +1,21 @@ -require 'ScoringAlgorithm' - -class FibonacciPeerWithBlowout < ScoringAlgorithm +module Scoring + module FibonacciPeerWithBlowout + def stats_needed + return [:votes] + end - def self.score(match, interface) - match.players.each do |player| - scores[player.user_name] = scoreUser(interface.getStatistic(match, player, :votes), match.win?(player), match.blowout) + def score(match, interface) + scores = {} + match.players.each do |player| + scores[player.user_name] = score_user(interface.get_statistic(match, player, :votes), match.win?(player), match.blowout) + end + scores end - scores - end - def self.scoreUser(votes, win, blowout) - 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) + private + def score_user(votes, win, blowout) + 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 end -end
\ No newline at end of file +end |