[Live][site] [site]: http://thegospot.herokuapp.com/
GOSpot is a web application inspired by csgolounge, where users can bet their virtual in-game items on professional CS:GO matches.
- Single-page web application with a
RailsRESTful API serving anEmber.jsclient-side server via theactive_model_serializersgem - Secure user authentication with
ember-simple-authanddevisegem - Parimutuel Betting system determines payout odds based on the total pool of each team as opposed to
fixed-oddsbetting Bin-Packing/Coin-Changealgorithm efficiently and quickly distributes winning payouts to users after the site takes a 5% rake (see code spotlight below)- Users can
depositandwithdrawtheir items instantly through their profile page - Users can bet on matches of their choice, anytime between midnight and before the match starts
- View match score updates live when the match begins
- Custom scheduled
raketasks start matches, deposit winnings in the users profile, and re-seed random bets and items everyday.
- When a match is over, it starts by first creating
Payoutmodels for all the winners, initialized by returning the initial bets and items eachwinnermade - Along with the
Payoutmodels,profitsare calculated and sorted in descending order, ensuring that users with the highest bets are prioritized - All the items betted on the losing team are collected and placed into the
PayoutTablemodel, along withPayoutandprofitsof each user, and the siterakeamount.
- When the
PayoutTablemodel initializes, it generates the@skins_hash(a frequency hash), and the@bp_table.
Here is a preview of the @bp_table calculation.
- The
@bp_tabletakes the@maxprofit and iterates from 1..@max, and iterates through the keys from the@skins_hashas the available distributable items - Through dynamic programming, it generates values for two arrays, the
item_count, andlast_itemarray, where the indices of the arrays represent the $ amount, and the value of theitem_countandlast_itemarrays represent the optimal number of items, and the last item used to make change for that amount respectively - In the case that the
priceof the current item is between the currentamtandamt + 10%, anoverpayis allowed to allow other items to be distributed, and the winner to receive one item of high value - By sacrificing space for time, the average is an O(n*k) time complexity solution. Where
nrepresents the max profit amount, andkrepresents the unique number of items.
- For each of the winning profits,
cashoutis called.Cashoutfinds the optimal collection of items for the amount by reading the values generated in the@bp_tableand deducts the respective item from the@skins_hash - While iterating through the optimal payout, if the
@skins_hashdoesn't have the necessary item, the@bp_tableis recalculated, but not with the original@maxprofit. Every time an item is deducted from the current payout, the@maxgets updated to the maximum of the currentremainingamount, or thenextprofit, insuring that the the@bp_tabledoesn't compute values that have already been computed.
- Add projected payout amounts at the time of placing a bet
- Have the payout odds persist after the match is over
- Add match history





