summaryrefslogtreecommitdiff
path: root/lib/scoring_algorithms/FibonacciPeerWithBlowout.rb
diff options
context:
space:
mode:
authorLuke Shumaker <shumakl@purdue.edu>2014-04-22 02:49:34 -0400
committerLuke Shumaker <shumakl@purdue.edu>2014-04-22 02:49:34 -0400
commit474a048ae4a4fae86e7fde93745f0ea79c7ed717 (patch)
tree63e87b93634d90c8236b09a02c19e37031d55304 /lib/scoring_algorithms/FibonacciPeerWithBlowout.rb
parent7d40d2ed8bd686b32ff9bc620936a72044a610bc (diff)
parent9531e27d6414ca1e3c9a81b1a98f0550d74fad1d (diff)
Merge remote-tracking branch 'origin/master'
Conflicts: app/models/match.rb
Diffstat (limited to 'lib/scoring_algorithms/FibonacciPeerWithBlowout.rb')
-rw-r--r--lib/scoring_algorithms/FibonacciPeerWithBlowout.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/scoring_algorithms/FibonacciPeerWithBlowout.rb b/lib/scoring_algorithms/FibonacciPeerWithBlowout.rb
new file mode 100644
index 0000000..19ac9a7
--- /dev/null
+++ b/lib/scoring_algorithms/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