summaryrefslogtreecommitdiff
path: root/lib/scoring_algorithms/ScoringAlgorithms.rb
blob: 7f8ec128b532b833ec3adc3e09760bd9351bc806 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class ScoringAlgorithm
	def self.score(*args)
	end
end

class FibonacciPeerWithBlowout < ScoringAlgorithm
	def self.score(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

class WinnerTakesAll < ScoringAlgorithm
	def self.score(win)
		win.nil? ? 0.5 : win ? 1 : 0
	end
end

class MarginalPeer < ScoringAlgorithm
	def self.score(rating)
		rating
	end
end


#puts Recommended.score(4, true, false)
#puts WinnerTakesAll.score(nil)
#puts WinnerTakesAll.score(true)