Payout System
Schemes for selecting winners and their prizes in a pool betting application.
This is used at Picklive. See also: Picklive tech blog.
Example:
class Entry
attr_accessor :points
def initialize(points)
self.points = points
end
end
entries = [34, 61, 73, 17, 45, 18, 93, 102, 46].map{ |points| Entry.new(points) }
pot_amount = 1000
payouts = PayoutSystem.calculate(pot_amount, entries, :podium_split, :points)
# It returns a collection of [Entry, prize_amount]:
# => [[#<Entry:0x1019a9a00 @points=102>, 700],
# [#<Entry:0x1019a99d8 @points=99>, 200],
# [#<Entry:0x1019a99b0 @points=84>, 100]]
Available payout systems
- winner_takes_all - 1st place wins the pot
- podium_split - 1st, 2nd, 3nd place win 70%, 20%, 10% of the pot
- minimum_to_fraction - first 25% of players get back a minimum (this can be their stake), and the top 3 splits the remaining sum according to podium_split rules