4b3c8b874641c3398f7aae0be9873163

So I don't currently have any code for this, I'm just having a hard time on how to implement it. Below is some pseudo code...

Obviously it needs A LOT of work...

Thanks!

<?php
$player_1_bet = 12; // ALL IN
$player_2_bet = 30; // CALLED
$player_3_bet = 7; // ALL IN
$player_4_bet = 30; // CALLED

$total_pot = $player_1_bet + $player_2_bet + $player_3_bet + $player_4_bet;

// Main Pot
$main_pot = $player_3_bet * 4; // smallest all in bet * number entered at that price...needs to be more "dynamic" (ALL PLAYERS)

$left_over = $total_pot - $main_pot;
$side_pot_1 = $left_over * 3; // 3 = number players in for that amount (PLAYERS 1, 2 AND 4)

$left_over = $total_pot - $side_pot_1;
$side_pot_2 = $left_over * 2; // 2 = number players in for that amount (PLAYERS 2 AND 4)
?>

Refactorings

No refactoring yet !

330555fba743b009765f9d38d7137e6f

Scott Reynen

October 28, 2008, October 28, 2008 17:31, permalink

1 rating. Login to rate!

You'll have to work out class definitions for player and pot, and define the by_bet function to get this working. Each pot should end up with the correct balance and all of the involved players.

$players = array();
$pots = array();

$players[] = new player( 1 , 12 ); // identifier , bet
$players[] = new player( 2 , 30 );
$players[] = new player( 3 , 7 );
$players[] = new player( 4 , 30 );

usort( $players , 'by_bet' ); // sort by bet

while ( count( $players ) > 0 ) // go until all money is in a pot
{

    $pots[] = new pot; // make another pot
    $smallest_bet = $players[0] -> bet; // get the common bet for this pot

    foreach ( $players as $index => $player )
    {

        $player -> bet -= $smallest_bet; // take away player's money
        $pot -> total += $smallest_bet; // add money to the pot
        $pot -> players[] = $player; // add player to the pot
        if ( $player -> bet == 0 ) unset( $players[ $index ] ); // remove players with no more money

    }

}
4b3c8b874641c3398f7aae0be9873163

extjspoker

October 28, 2008, October 28, 2008 18:00, permalink

No rating. Login to rate!

Awesome! Thank you very much!!!

E197a0ca8c57bdf83449e8dd23b06794

geoge

July 31, 2011, July 31, 2011 01:52, permalink

No rating. Login to rate!
C0IluD http://qnY82mcNxdOpl24gj.biz
E197a0ca8c57bdf83449e8dd23b06794

geoge

July 31, 2011, July 31, 2011 01:53, permalink

No rating. Login to rate!
C0IluD http://qnY82mcNxdOpl24gj.biz
4061dba59a6e05e3022660d4fa582686

crysty

July 30, 2011, July 30, 2011 16:06, permalink

No rating. Login to rate!
aOoo8z http://ueNx8wqkk3Mnd.com
4061dba59a6e05e3022660d4fa582686

crysty

July 30, 2011, July 30, 2011 16:06, permalink

No rating. Login to rate!
aOoo8z http://ueNx8wqkk3Mnd.com
4061dba59a6e05e3022660d4fa582686

crysty

July 30, 2011, July 30, 2011 16:06, permalink

No rating. Login to rate!
aOoo8z http://ueNx8wqkk3Mnd.com
4061dba59a6e05e3022660d4fa582686

crysty

July 30, 2011, July 30, 2011 16:06, permalink

No rating. Login to rate!
aOoo8z http://ueNx8wqkk3Mnd.com
4061dba59a6e05e3022660d4fa582686

crysty

July 30, 2011, July 30, 2011 16:06, permalink

No rating. Login to rate!
aOoo8z http://ueNx8wqkk3Mnd.com
E660965cf4296b9081ed500252e77b86

trinity

July 30, 2011, July 30, 2011 20:58, permalink

No rating. Login to rate!
Bpf59T http://www.tdHn2o99genVcoe.net
E197a0ca8c57bdf83449e8dd23b06794

geoge

July 31, 2011, July 31, 2011 01:51, permalink

No rating. Login to rate!
C0IluD http://qnY82mcNxdOpl24gj.biz

Your refactoring





Format Copy from initial code

or Cancel