diff options
Diffstat (limited to 'lib/scoring')
-rw-r--r-- | lib/scoring/.FibonacciPeerWithBlowout.rb.swp | bin | 0 -> 12288 bytes | |||
-rw-r--r-- | lib/scoring/fibonacci_peer_with_blowout.rb | 16 | ||||
-rw-r--r-- | lib/scoring/marginal_peer.rb | 15 | ||||
-rw-r--r-- | lib/scoring/scoring_algorithm.rb | 6 | ||||
-rw-r--r-- | lib/scoring/winner_takes_all.rb | 16 |
5 files changed, 53 insertions, 0 deletions
diff --git a/lib/scoring/.FibonacciPeerWithBlowout.rb.swp b/lib/scoring/.FibonacciPeerWithBlowout.rb.swp Binary files differnew file mode 100644 index 0000000..49504ab --- /dev/null +++ b/lib/scoring/.FibonacciPeerWithBlowout.rb.swp 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 diff --git a/lib/scoring/marginal_peer.rb b/lib/scoring/marginal_peer.rb new file mode 100644 index 0000000..0e1cfa8 --- /dev/null +++ b/lib/scoring/marginal_peer.rb @@ -0,0 +1,15 @@ +require 'ScoringAlgorithm' + +class MarginalPeer < ScoringAlgorithm + + def self.score(match, interface) + match.players.each do |player| + scores[player.user_name] = scoreUser(interface.getStatistic(match, player, rating)) + end + scores + end + + def self.score(rating) + rating + end +end
\ No newline at end of file diff --git a/lib/scoring/scoring_algorithm.rb b/lib/scoring/scoring_algorithm.rb new file mode 100644 index 0000000..f2afa6f --- /dev/null +++ b/lib/scoring/scoring_algorithm.rb @@ -0,0 +1,6 @@ +module Scoring + class ScoringAlgorithm + def self.score(match, interface) + 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..ad2471b --- /dev/null +++ b/lib/scoring/winner_takes_all.rb @@ -0,0 +1,16 @@ +require 'ScoringAlgorithm' + +class WinnerTakesAll < ScoringAlgorithm + + def self.score(match, interface) + match.players.each do |player| + scores[player.user_name] = scoreUser(match.win?(player)) + end + scores + end + + + def self.score(win) + win.nil? ? 0.5 : win ? 1 : 0 + end +end
\ No newline at end of file |