Tommy Arnold
Tommy Arnold

Reputation: 3389

php percentage calculation

I am trying to calculate the number of hands required to activate a bonus in online poker.

As an example:

With betfair poker

so

100 Poker hands with an average pot of $1 generates $5 in rake 5 x 3.25 = 16.25 points

The bonus is released in increments of $5 foreach 40 points so I need to calculate how many hands it will take to generate 40 points.

Here is the code I have so far:

$average_pot = 1;
$points_required = 40;

//percentage of rake taken from pot
$rake_percentage = 5;
//number of points for every dollar generated
$points_per_dollar = 3.25;
$rake_to_generate = $points_required / $points_per_dollar; // 12.30
$hands_needed = $rake_to_generate * $rake_percentage; //Wrong?!?!

 echo $hands_needed;

I know its probably an easy one but for some reason my brain wont let me figure it out so any help would be much appreciated.

Upvotes: 1

Views: 2106

Answers (2)

PriestVallon
PriestVallon

Reputation: 1518

Try this:

$average_pot = 1;
$points_required = 40;

//percentage of rake taken from pot
$rake_percentage = 0.05;
//number of points for every dollar generated
$points_per_dollar = 3.25;
$rake_to_generate = $points_required / $points_per_dollar; // 12.30
$hands_needed = $rake_to_generate * $rake_percentage; //Wrong?!?!

 echo $hands_needed;

Upvotes: 0

eggyal
eggyal

Reputation: 125835

$points_per_hand = $rake_percentage/100 * $points_per_dollar * $average_pot;
$hands_needed    = ceil($points_required / $points_per_hand);

Using your example:

$points_per_hand = 5/100 * 3.25 * 1;
                 = 0.1625;

$hands_needed    = ceil(40 / 0.1625);
                 = ceil(246.1538...);
                 = 247;

Upvotes: 1

Related Questions