diff options
Diffstat (limited to 'lib/scoring')
-rw-r--r-- | lib/scoring/fibonacci_peer_with_blowout.rb | 21 | ||||
-rw-r--r-- | lib/scoring/marginal_peer.rb | 15 | ||||
-rw-r--r-- | lib/scoring/winner_takes_all.rb | 20 |
3 files changed, 56 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..8043fb7 --- /dev/null +++ b/lib/scoring/fibonacci_peer_with_blowout.rb @@ -0,0 +1,21 @@ +module Scoring + module FibonacciPeerWithBlowout + def stats_needed + return [:votes] + end + + 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 + + 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 diff --git a/lib/scoring/marginal_peer.rb b/lib/scoring/marginal_peer.rb new file mode 100644 index 0000000..13e1796 --- /dev/null +++ b/lib/scoring/marginal_peer.rb @@ -0,0 +1,15 @@ +module Scoring + module MarginalPeer + def stats_needed + return [:rating] + end + + def score(match, interface) + scores = {} + match.players.each do |player| + scores[player.user_name] = interface.get_statistic(match, player, :rating) + end + scores + end + end +end diff --git a/lib/scoring/winner_takes_all.rb b/lib/scoring/winner_takes_all.rb new file mode 100644 index 0000000..517dfd6 --- /dev/null +++ b/lib/scoring/winner_takes_all.rb @@ -0,0 +1,20 @@ +module Scoring + module WinnerTakesAll + def stats_needed + return [] + end + + def score(match, interface) + scores = {} + match.players.each do |player| + scores[player.user_name] = score_user(match.win?(player)) + end + scores + end + + private + def score_user(win) + win.nil? ? 0.5 : win ? 1 : 0 + end + end +end |