diff options
author | nfoy <nfoy@purdue.edu> | 2014-04-22 18:17:47 -0400 |
---|---|---|
committer | nfoy <nfoy@purdue.edu> | 2014-04-22 18:17:47 -0400 |
commit | 7f452e8d99a86af2e3dc2f743158951092aedeb7 (patch) | |
tree | 103f3cb57b05c5a580c3a5152a2a97f5a8070d1e /lib/scoring/fibonacci_peer_with_blowout.rb | |
parent | 7fe1f6a809d68648bede431b84692bf7d8bb0c01 (diff) | |
parent | 7deb9c1c7acadf9a5b638313f51ba9dc60624672 (diff) |
Merge branch 'master' of https://github.com/LukeShu/leaguer
Diffstat (limited to 'lib/scoring/fibonacci_peer_with_blowout.rb')
-rw-r--r-- | lib/scoring/fibonacci_peer_with_blowout.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/scoring/fibonacci_peer_with_blowout.rb b/lib/scoring/fibonacci_peer_with_blowout.rb new file mode 100644 index 0000000..19ac9a7 --- /dev/null +++ b/lib/scoring/fibonacci_peer_with_blowout.rb @@ -0,0 +1,16 @@ +require 'ScoringAlgorithm' + +class FibonacciPeerWithBlowout < ScoringAlgorithm + + 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) + 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) + end +end
\ No newline at end of file |