455,168 Members | 1,487 Online
Need help? Post your question and get tips & solutions from a community of 455,168 IT Pros & Developers. It's quick & easy.

# General Opinion on a how to?

 P: n/a Hi guys I have a requirment to calculate a prize pool for a competiton similar to a poker tournament. But i am stuck on best ways or even if i have the right ideas, so: Players pay to play, total paid is prize pool and is distributed to top 3 or so winners. Variables are number of players who will win, if a lot enter i increase number of winners. i think a standard top 30% rounded off would work for calculating paid positions? So 10 players. 30% would be 3 of them (rounded) Now to calculate the actual amount of prize each gets i'd like to be able to vary it. So i could offer or be versatile enough to offer different distribtuions. Such as, a winner takes all, a top 2 get the most and then 3rd gets a fair bit less, or a 4 out of 10 get prizes.....etc Also i'd like to be able to offer prizes where say first place can get cash AND a car for example. But other 2 places just cash etc etc This is where i am stuck, do i go for a hard coded table in database and read off it when my prog loads into a struct and just reference that when doing calculations? One way forward, but then if a number of players enters that i havent accounted for, then what? Alternatively as i said above i calculate winning positions based on a % but then how do idecide which of those positions wins what? Very stuck and confused, i keep thinking this must be simple. any ideas or pointers welcome? Thanks Jan 29 '07 #1
6 Replies

 P: n/a Daniel, You could create an interface that defines a winnings calculator and then uses a factory to dynamically load and instantiate the named interface from an external assembly. This would allow you to be flexible enough to add new calculations to the system down the road. Jamey "Daniel"

 P: n/a Seems to me you need to do some analysis. Some obvious objects are: Game Player Prize PrizePool Now, can you say what state variables and methods these objects should have? Does thinking about that suggest to you that you may want an inheritance hierarchy, or an interface for some of these objects? E.g. Could there be different types of Games (Pool, Poker, Darts, Domines, Cribbage)? Would they have extra/different state and behaviour? What about prizes? Would an interface work best here? Then a PrizePool could hold objects that implement the interface? Will a Game hold a collection of players? Presumably a PrizePool will hold a collection of Prizes. Since the Prizes may be different, will they be different in an inheritance sense, or in an interface sense? Will a PrizePool need a reference to a Game (i.e. need to know which Game it is the PrizePool for)? Will a Prize need a reference to a Game, too? Or could the same Prize be used for many Games. There's no substitute for good analysis. HTH, IMHO, YMMV, Just my 2c etc etc Peter "Daniel"

 P: n/a That part is already done and complete. The issue is more the back end storage of the prize pool break dowm to hard code in code as your method suggests or not? If i have a database table that reads the variables out then that to be is the only way forward. As Jamey said, a interface and a factory sounds a good plan and i can instatiate each from the database in advamce choosing the one needed at run time. The way i see my calculation working with the aid of Jameys tips is this: - load a game - Retrieve Tournament placed winning positions from database as a %, top 30%, top 1% (winner takes all), etc - Load into a prize pool object instance for that game My biggest issue is the distribution of that prize pool. Rather than hard code, "if 3 prize positions then break down as follows", "if 4 etc". I would rather some form of algorithm for or setting in my database to say that for this game use this ditribution, for this one use another one, and eaxh distribution be stored in a back end db table. But how do you store a 'distribution'? I guess its an algorithm, if so i could store in the db which algorithm to use etc? this is where i am stuck.... Any ideas? "Peter Bradley" Hi guysI have a requirment to calculate a prize pool for a competiton similar toa poker tournament. But i am stuck on best ways or even if i have theright ideas, so:Players pay to play, total paid is prize pool and is distributed to top 3or so winners.Variables are number of players who will win, if a lot enter i increasenumber of winners. i think a standard top 30% rounded off would work forcalculating paid positions? So 10 players. 30% would be 3 of them(rounded)Now to calculate the actual amount of prize each gets i'd like to be ableto vary it. So i could offer or be versatile enough to offer differentdistribtuions. Such as, a winner takes all, a top 2 get the most and then3rd gets a fair bit less, or a 4 out of 10 get prizes.....etcAlso i'd like to be able to offer prizes where say first place can getcash AND a car for example. But other 2 places just cash etc etcThis is where i am stuck, do i go for a hard coded table in database andread off it when my prog loads into a struct and just reference that whendoing calculations? One way forward, but then if a number of playersenters that i havent accounted for, then what?Alternatively as i said above i calculate winning positions based on a %but then how do idecide which of those positions wins what?Very stuck and confused, i keep thinking this must be simple. any ideasor pointers welcome?Thanks Jan 29 '07 #4

 P: n/a If it were me, I'd implement a rules engine for the project. Your design must define the general rules of how the payout behavior will operate based on the number of players. Check out the book "MDA Explained: The Model Driven Architecture--Practice and Promise" for an excellent example of how to implement an object-oriented rules engines. For the varying behavior you describe, I would just use the random number generator seeded with the current second when the payout is calculated. Your algorithm's in the rules engine will have to be able to use this value somehow to calculate the varying payouts. On Jan 29, 6:48 am, "Daniel"

 P: n/a You could store the name of the algorithm in the database along with some params for it. I have done this two ways in the past successfully. First, you could store the params in a TEXT field as xml. Second you can create another detail table with key value pairs. Either way you would not have to change the database as you add new algorithm to the system. We used a system similar to this for calculating holidays for a calendar. Almost all holidays on the calendar could be calculated with a few basic algorithms. however easter was different so we had create a special algorithm for it. All in all we have arround 5 algorithms and almost 100 holidays. This came in very usefull this year because with daylight savings time changing we had to only change the xml file. Hope this helps Jamey "Daniel" Seems to me you need to do some analysis.Some obvious objects are:GamePlayerPrizePrizePoolNow, can you say what state variables and methods these objects shouldhave? Does thinking about that suggest to you that you may want aninheritance hierarchy, or an interface for some of these objects? E.g.Could there be different types of Games (Pool, Poker, Darts, Domines,Cribbage)? Would they have extra/different state and behaviour?What about prizes? Would an interface work best here? Then a PrizePoolcould hold objects that implement the interface?Will a Game hold a collection of players? Presumably a PrizePool willhold a collection of Prizes. Since the Prizes may be different, willthey be different in an inheritance sense, or in an interface sense?Will a PrizePool need a reference to a Game (i.e. need to know which Gameit is the PrizePool for)? Will a Prize need a reference to a Game, too?Or could the same Prize be used for many Games.There's no substitute for good analysis.HTH, IMHO, YMMV, Just my 2c etc etc Peter "Daniel" >Hi guysI have a requirment to calculate a prize pool for a competiton similarto a poker tournament. But i am stuck on best ways or even if i have theright ideas, so:Players pay to play, total paid is prize pool and is distributed to top3 or so winners.Variables are number of players who will win, if a lot enter i increasenumber of winners. i think a standard top 30% rounded off would work forcalculating paid positions? So 10 players. 30% would be 3 of them(rounded)Now to calculate the actual amount of prize each gets i'd like to beable to vary it. So i could offer or be versatile enough to offerdifferent distribtuions. Such as, a winner takes all, a top 2 get themost and then 3rd gets a fair bit less, or a 4 out of 10 getprizes.....etcAlso i'd like to be able to offer prizes where say first place can getcash AND a car for example. But other 2 places just cash etc etcThis is where i am stuck, do i go for a hard coded table in database andread off it when my prog loads into a struct and just reference thatwhen doing calculations? One way forward, but then if a number ofplayers enters that i havent accounted for, then what?Alternatively as i said above i calculate winning positions based on a %but then how do idecide which of those positions wins what?Very stuck and confused, i keep thinking this must be simple. any ideasor pointers welcome?Thanks Jan 30 '07 #6