mardi 9 février 2016

(Java) Split up a range into smaller ranges

I'm working on a project where i need to split up a pot of "money"(or credits if you will) into different sizes, depending on the amount of money a player bets.

It's a kind of jackpot system where you as a player should get a "win-range" as large as your contribution to the pot.

let me try to explain this:

I have an array of players named player[] and every player have the variable winRange.

If player[1] bets 150, player[2] bets 600 and player[3] bets 250(pot size is 1000 in total)

i want to give player[1] the range between 0-15 since he bet 15% of the pot, i want player[2] to get the range 15-75 since he bet 60% of the pot, and i want to give player[3] the range 75-100 since he bet 25% of the pot.

When every player have their own range between 0-100 i will do a random double between 0-100, and the range the random double lands in, will decide the winner.

How do i make my program divide a range(100 for me) into several smaller ranges? Thanks alot //Alfred




Aucun commentaire:

Enregistrer un commentaire