diff options
author | tkimia <tkimia@purdue.edu> | 2014-04-22 17:43:02 -0400 |
---|---|---|
committer | tkimia <tkimia@purdue.edu> | 2014-04-22 17:43:02 -0400 |
commit | 27ed02ceaafe466307fc5a5d584aa329ea147be5 (patch) | |
tree | 0a54bb2c9c8cfb7d82eeea8cf4fca9283e0b27d5 /lib/scoring/FibonacciPeerWithBlowout.rb | |
parent | bb53f8ac2ab52301b32fe65ddc10a32f6bc730e8 (diff) | |
parent | 42aa0fe7fdfc51f79cda90c4d71621a797995a6c (diff) |
Merge branch 'master' of https://github.com/LukeShu/leaguer
Diffstat (limited to 'lib/scoring/FibonacciPeerWithBlowout.rb')
-rw-r--r-- | lib/scoring/FibonacciPeerWithBlowout.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/scoring/FibonacciPeerWithBlowout.rb b/lib/scoring/FibonacciPeerWithBlowout.rb new file mode 100644 index 0000000..19ac9a7 --- /dev/null +++ b/lib/scoring/FibonacciPeerWithBlowout.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 |