summaryrefslogtreecommitdiff
path: root/lib/scoring
diff options
context:
space:
mode:
Diffstat (limited to 'lib/scoring')
-rw-r--r--lib/scoring/README.md2
-rw-r--r--lib/scoring/fibonacci_peer_with_blowout.rb16
-rw-r--r--lib/scoring/marginal_peer.rb2
-rw-r--r--lib/scoring/winner_takes_all.rb7
4 files changed, 16 insertions, 11 deletions
diff --git a/lib/scoring/README.md b/lib/scoring/README.md
index dce71d0..efdc3cc 100644
--- a/lib/scoring/README.md
+++ b/lib/scoring/README.md
@@ -4,7 +4,7 @@ Scoring interface
Files in this directory should be _modules_ implementing the following
interface:
- - `stats_needed(Match) => Array[]=Symbol`
+ - `stats_needed(Match) => Array[]=String`
Returns which statistics need to be collected for this scoring
algorithm.
diff --git a/lib/scoring/fibonacci_peer_with_blowout.rb b/lib/scoring/fibonacci_peer_with_blowout.rb
index 9d72643..a13d76c 100644
--- a/lib/scoring/fibonacci_peer_with_blowout.rb
+++ b/lib/scoring/fibonacci_peer_with_blowout.rb
@@ -1,15 +1,17 @@
module Scoring
module FibonacciPeerWithBlowout
- def self.stats_needed
- return ["votes", "win", "blowout"]
+ def self.stats_needed(match)
+ return ["votes", "win", "blowout"] + match.users.map{|u|"review_from_#{u.user_name}"}
end
def self.score(match)
scores = {}
match.users.each do |user|
- stats = Statistic.where(user: user, match: match)
-
- votes = stats.where(name: "votes" ).first.value
+ stats = user.statistics.where(match: match)
+ votes = 0
+ match.users.each do |u|
+ votes += convert_place_to_votes stats.where(name: "review_from_#{u.user_name}").first.value
+ end
win = stats.where(name: "win" ).first.value
blowout = stats.where(name: "blowout").first.value
scores[user] = self.score_user(votes, win, blowout)
@@ -23,5 +25,9 @@ module Scoring
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
+
+ def self.convert_place_to_votes(place)
+ (place == 0 or place == 1) ? 1 : 0
+ end
end
end
diff --git a/lib/scoring/marginal_peer.rb b/lib/scoring/marginal_peer.rb
index 8559b3d..f2c0272 100644
--- a/lib/scoring/marginal_peer.rb
+++ b/lib/scoring/marginal_peer.rb
@@ -1,6 +1,6 @@
module Scoring
module MarginalPeer
- def self.stats_needed
+ def self.stats_needed(match)
return ["rating", "win"]
end
diff --git a/lib/scoring/winner_takes_all.rb b/lib/scoring/winner_takes_all.rb
index 9c83fb9..db494c6 100644
--- a/lib/scoring/winner_takes_all.rb
+++ b/lib/scoring/winner_takes_all.rb
@@ -1,15 +1,14 @@
module Scoring
module WinnerTakesAll
- def self.stats_needed
- #return ["win"]
- ["win", "numDeaths", "turretsKilled", "championsKilled", "minionsKilled", "assists"]
+ def self.stats_needed(match)
+ return ["win"]
end
def self.score(match)
scores = {}
match.users.each do |user|
stats = Statistic.where(user: user, match: match)
- scores[user] = score_user(stats.where(name: "win").first.value)
+ scores[user] = score_user(stats.where(name: "win").first)
end
scores
end