0, 0, 5 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), array(2 => 0, 0, 5 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), array(2 => 0, 0, 5 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), array(2 => 0, 0, 5 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), array(2 => 0, 0, 5 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) ); $sWinners = array(1 => array(2 => array(0,0), array(0,0), 5 => array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0)), array(2 => array(0,0), array(0,0), 5 => array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0)), array(2 => array(0,0), array(0,0), 5 => array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0)), array(2 => array(0,0), array(0,0), 5 => array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0)), array(2 => array(0,0), array(0,0), 5 => array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0)) ); $wWinners = array(1 => array(2 => array(0,0), array(0,0), 5 => array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0)), array(2 => array(0,0), array(0,0), 5 => array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0)), array(2 => array(0,0), array(0,0), 5 => array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0)), array(2 => array(0,0), array(0,0), 5 => array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0)), array(2 => array(0,0), array(0,0), 5 => array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0)) ); $nWinners = array(1 => array(2 => array(0,0), array(0,0), 5 => array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0)), array(2 => array(0,0), array(0,0), 5 => array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0)), array(2 => array(0,0), array(0,0), 5 => array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0)), array(2 => array(0,0), array(0,0), 5 => array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0)), array(2 => array(0,0), array(0,0), 5 => array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0), array(0,0)) ); srand((float)microtime()*1000000); function shuffleDeck() { global $deck; $deck = array (2,2,2,2,3,3,3,3,5,5,5,5,6,6,6,6,7,7,7,7,8,8,8,8,9,9,9,9, 10,10,10,10,11,11,11,11,12,12,12,12,13,13,13,13,14,14,14,14,15,15,15,15); } function dealCard() { global $deck; $card = array_splice($deck, array_rand($deck), 1); return $card[0]; } function printCard($card) { switch ($card) { case 15: return '4'; case 14: return 'A'; case 13: return 'K'; case 12: return 'Q'; case 11: return 'J'; default: return $card; } } function printHands() { global $hands; global $NUM_PLAYERS; for ($i = 0; $i < $NUM_PLAYERS; $i++) { echo " in ? ' class=in' : '').">"; echo printCard($hands[$i]->c[0])." "; echo printCard($hands[$i]->c[1])." "; echo printCard($hands[$i]->c[2])." "; echo printCard($hands[$i]->c[3])."\n"; } } ?>

A 442 simulation with players and trials

inOut($p); } // for each player if ($g < $PRINT_HANDS) { printHands(); echo " \n \n"; } $totalIn = 0; for ($p = 0; $p < $NUM_PLAYERS; $p++) { if ($hands[$p]->in) { $profit[$p][0]++; $profit[$p][1] -= min($MAX_BURN, $pot); $bets[$p] += min($MAX_BURN, $pot); $totalIn++; $hands[$p]->updateHand( array( $hands[$p]->c[0], $hands[$p]->c[1], ($hands[$p]->d[2] ? dealCard() : $hands[$p]->c[2]), ($hands[$p]->d[3] ? dealCard() : $hands[$p]->c[3]) ) ); } // if the person is in } // for each player if ($g < $PRINT_HANDS) { printHands(); } $maxRank = 0; $maxCard = 0; $maxCard2 = 0; $maxCard3 = 0; $maxCard4 = 0; $potentialTie = -1; $tempTie = 0; $wp = -1; for ($p = 0; $p < $NUM_PLAYERS; $p++) { if ($hands[$p]->in && $hands[$p]->rank >= $maxRank) { switch ($hands[$p]->rank) { case 1: if ($hands[$p]->c[0] > $maxCard || $hands[$p]->c[0] == $maxCard && $hands[$p]->c[1] > $maxCard2 || $hands[$p]->c[0] == $maxCard && $hands[$p]->c[1] == $maxCard2 && $hands[$p]->c[2] > $maxCard3 || $hands[$p]->c[0] == $maxCard && $hands[$p]->c[1] == $maxCard2 && $hands[$p]->c[2] == $maxCard3 && $hands[$p]->c[3] > $maxCard3) { $wp = $p; $maxRank = 1; $maxCard = $hands[$p]->c[0]; $maxCard2 = $hands[$p]->c[1]; $maxCard3 = $hands[$p]->c[2]; $maxCard4 = $hands[$p]->c[3]; } break; case 2: case 3: if ($hands[$p]->rank > $maxRank || $hands[$p]->c[1] > $maxCard || $hands[$p]->c[1] == $maxCard && $hands[$p]->c[2] > $maxCard2 || $hands[$p]->c[1] == $maxCard && $hands[$p]->c[2] == $maxCard2 && $hands[$p]->c[3] > $maxCard3) { $wp = $p; $maxRank = $hands[$p]->rank; $maxCard = $hands[$p]->c[1]; $maxCard2 = $hands[$p]->c[2]; $maxCard3 = $hands[$p]->c[3]; } elseif ($hands[$p]->rank == $maxRank && $hands[$p]->c[1] == $maxCard && $hands[$p]->c[2] == $maxCard2 && $hands[$p]->c[3] == $maxCard3) { $potentialTie = $wp; $tempTie++; } break; case 4: if (4 > $maxRank || $hands[$p]->c[2] > $maxCard || $hands[$p]->c[2] == $maxCard && $hands[$p]->c[3] > $maxCard2) { $wp = $p; $maxRank = 4; $maxCard = $hands[$p]->c[2]; $maxCard2 = $hands[$p]->c[3]; } elseif (4 == $maxRank && $hands[$p]->c[2] == $maxCard && $hands[$p]->c[3] == $maxCard2) { $potentialTie = $wp; $tempTie++; } break; case 5: // hack four 4s to be three 4s and an Ace if ($hands[$p]->c[3] == 15) { $hands[$p]->c[3] = 14; } // Now do the comparisons if (5 > $maxRank || $hands[$p]->c[3] > $maxCard) { $wp = $p; $maxRank = 5; $maxCard = $hands[$p]->c[3]; } elseif (5 == $maxRank && $hands[$p]->c[3] == $maxCard) { $potentialTie = $wp; $tempTie++; } break; default: break; // we should never get here } // switch } // if the player is in } // for each player $winners[$maxRank][$maxCard]++; if ($wp > -1) { if ($potentialTie == $wp) { $tie += $tempTie; if ($tempTie > 1) { echo "A ".($tempTie+1)."-way tie occurred!"; } $profit[$wp][1] += min($MAX_BURN, $pot) + 0.5*$pot; $profit[$potentialTie][1] += min($MAX_BURN, $pot) + 0.5*$pot; $pot = min($MAX_BURN, $pot) * ($totalIn-2); } else { $profit[$wp][1] += min($MAX_BURN, $pot) + $pot; $pot = min($MAX_BURN, $pot) * ($totalIn-1); } } if ($pot > $maxPot) { $maxPot = $pot; } $stayIn[$totalIn]++; for ($p = 0; $p < $NUM_PLAYERS; $p++) { $rank = $hands[$p]->orank; switch ($hands[$p]->orank) { case 1: $card = $hands[$p]->oc[0]; break; case 2: case 3: $card = $hands[$p]->oc[1]; break; case 4: $card = $hands[$p]->oc[2]; break; case 5: $card = $hands[$p]->oc[3]; // four 4s should be treated like three 4s and an A if ($card == 15) { $card = 14; } break; default: break; // we should never get here } // switch // with at least two wilds if ($hands[$p]->oc[1] == 15) { $sWinners[$rank][$card][0]++; if ($p == $wp || $wp == -1) { $sWinners[$rank][$card][1]++; } } // with 1 wild elseif ($hands[$p]->oc[0] == 15) { $wWinners[$rank][$card][0]++; if ($p == $wp || $wp == -1) { $wWinners[$rank][$card][1]++; } } else { $nWinners[$rank][$card][0]++; if ($p == $wp || $wp == -1) { $nWinners[$rank][$card][1]++; } } } ?> 0) { for ($p = 0; $p < $NUM_PLAYERS; $p++) { $profit[$p][1] += $pot / $NUM_PLAYERS; } } ?>
Game Players
1
1

The largest pot was .

  Player
1
Games Played
Change in Money
Total Bets Made

  Number of People who stayed in
Hands

Hand Starting Hands without a Wild
Wins / Occurrances
2 3 5 6 7 8 9 10 J Q K A Total
4 of a Kind / /
3 of a Kind / /
Two Pair / /
1 Pair / /
High Card / /

Hand Starting Hands with 1 Wild
Wins / Occurrances
2 3 5 6 7 8 9 10 J Q K A Total
4 of a Kind / /
3 of a Kind / /
Two Pair / /
1 Pair / /
High Card / /

Hand Starting Hands with 2 or more Wilds
Wins / Occurrances
2 3 5 6 7 8 9 10 J Q K A Total
4 of a Kind / /
3 of a Kind / /
Two Pair / /
1 Pair / /
High Card / /

Hand Number of Wins after the Draw
2 3 5 6 7 8 9 10 J Q K A Total
4 of a Kind
3 of a Kind
2 Pair
1 Pair
High Card
No Winner

c = $a; $this->d = array(true, true, true, true); $this->rankHand(); $this->oc = $this->c; $this->orank = $this->rank; } function updateHand ($a) { $this->oc = $this->c; $this->orank = $this->rank; rsort($a, SORT_NUMERIC); reset($a); $this->c = $a; $this->rankHand(); } function rankHand() { // 3 or more wild cards if ($this->c[2] == 15) { if ($this->c[3] > 8) { $this->d = array(false,false,false,false); } else { $this->d = array(false,false,false,true); } $this->rank = 5; } // 2 wild cards elseif ($this->c[1] == 15) { // 4 of a kind if ($this->c[2] == $this->c[3]) { $this->rank = 5; $this->d = array(false,false,false,false); } // 3 of a kind, but less than Jacks, draw both elseif ($this->c[2] < 11) { $this->rank = 4; $this->d = array(false,false,true,true); } // 3 of a kind, jacks or better, draw one else { $this->rank = 4; $this->d = array(false,false,false,true); } } // 2 wild cards // 1 wild card elseif ($this->c[0] == 15) { // 4 of a kind if ($this->c[1] == $this->c[3]) { $this->rank = 5; $this->d = array(false,false,false,false); } // 3 of a kind elseif ($this->c[1] == $this->c[2]) { $this->rank = 4; $this->d = array(false,false,false,true); } // 3 of a kind elseif ($this->c[2] == $this->c[3]) { $this->rank = 4; // ensure that the 3 of a kind is always first in the hand $tempCard = $this->c[3]; $this->c[3] = $this->c[1]; $this->c[1] = $tempCard; $this->d = array(false,false,false,true); } // 1 pair else { $this->rank = 2; $this->d = array(false,false,true,true); } } // 1 wild card // 0 wild cards else { // 4 of a kind if ($this->c[0] == $this->c[3]) { $this->rank = 5; $this->d = array(false,false,false,false); } // 3 of a kind elseif ($this->c[0] == $this->c[2]) { $this->rank = 4; $this->d = array(false,false,false,true); } // 3 of a kind elseif ($this->c[1] == $this->c[3]) { $this->rank = 4; // ensure that the 3 of a kind is always first in the hand $tempCard = $this->c[3]; $this->c[3] = $this->c[0]; $this->c[0] = $tempCard; $this->d = array(false,false,false,true); } // 2 pair elseif ($this->c[0] == $this->c[1] && $this->c[2] == $this->c[3]) { $this->rank = 3; $this->d = array(false,false,false,false); } // 1 pair elseif ($this->c[0] == $this->c[1]) { $this->rank = 2; $this->d = array(false,false,true,true); } // 1 pair elseif ($this->c[1] == $this->c[2]) { $this->rank = 2; // ensure that the pair is always first in the hand to ease in/out check $tempCard = $this->c[2]; $this->c[2] = $this->c[0]; $this->c[0] = $tempCard; $this->d = array(false,false,true,true); } // 1 pair elseif ($this->c[2] == $this->c[3]) { $this->rank = 2; // ensure that the pair is always first in the hand to ease in/out check $tempCard = $this->c[2]; $this->c[2] = $this->c[0]; $this->c[0] = $tempCard; $tempCard = $this->c[3]; $this->c[3] = $this->c[1]; $this->c[1] = $tempCard; $this->d = array(false,false,true,true); } // 0 pair else { $this->rank = 1; $this->d = array(false,false,true,true); } } // 0 wild cards } // rankHand() function inOut($p) { global $pot; global $MAX_BURN; switch ($p+1) { case 1: $this->in = $this->rank > 2 || $this->rank == 2 && $this->c[1] > 10; break; /* case 2: $this->in = $this->rank > 2 || $this->rank == 2 && $this->c[1] > 13 || $pot < 20 && $this->rank == 2 && $this->c[1] > 12 || $pot < 10 && $this->rank == 2 && $this->c[1] > 11; break; */ case 2: case 3: case 4: case 5: case 6: $this->in = $this->rank > 3 || $this->rank == 3 && $this->c[1] > 9 || $this->rank == 2 && $this->c[1] > 13 || ($pot < 10 || $pot > $MAX_BURN * 1.5) && ($this->rank == 3 || $this->rank == 2 && $this->c[1] > 12); break; /* case 5: $this->in = $this->rank > 3 || $this->rank == 3 && $this->c[1] > 12 || $this->rank == 2 && $this->c[1] > 13 || ($pot < 10 || $pot > $MAX_BURN * 1.5) && ($this->rank == 3 && $this->c[1] > 12); break; */ case 7: $this->in = $this->rank == 5 || $this->rank == 4 && $this->c[0] > 9 || $this->rank == 2 && $this->c[0] == 15 && $this->c[1] == 14 || $pot > $MAX_BURN * 1.5 && ($this->c[1] == 14 || $this->rank == 4) || $pot > $MAX_BURN * 2.5 && $this->c[0] == 15 && $this->c[1] == 13; break; default: $this->in = $this->rank > 3 || $this->rank == 3 && $this->c[1] > 9 || $this->rank == 2 && $this->c[1] > 13 || ($pot < 10 || $pot > $MAX_BURN * 1.5) && ($this->rank == 3 || $this->rank == 2 && $this->c[1] > 12); break; } } //inOut } // Hand class ?>