A combo card drawing simulation with trials
0 && $deck[0] == 1) {
array_splice($deck, 0, 1);
return true;
}
else {
return false;
}
}
function dealCard() {
global $deck;
global $decksize;
$card = array_splice($deck, array_rand($deck), 1);
return $card[0];
}
function printGames ($startingCard, $numGames) {
global $winners;
global $decksize;
global $sumWinners;
// if we've requested x games, but less are left
if ($startingCard + $numGames  1 > $decksize) {
// print out however many we can
$numGames = $decksize  $startingCard + 1;
}
// rough error checking
if ($startingCard < 1 
$startingCard > $decksize 
$numGames < 1) {
return;
}
if ($numGames == 1) {
$sumWinners += $winners[$startingCard];
echo " \n";
echo " ".$startingCard."\n";
echo " ".$winners[$startingCard]."\n";
echo " ".$sumWinners."\n";
echo " \n";
return;
}
// print out multiple games at a time
$tempGames = 0;
for ($i = 0; $i < $numGames; $i++) {
$tempGames += $winners[$startingCard + $i];
}
$sumWinners += $tempGames;
echo " \n";
echo " ".$startingCard."  ".($startingCard+$numGames1)."\n";
echo " ".$tempGames."\n";
echo " ".$sumWinners."\n";
echo " \n";
return;
}
for ($g = 0; $g < $GAMES; $g++) {
shuffleDeck();
$numt1 = 0;
$numt2 = 0;
$numfound = 0;
// while we haven't found enough matches
// there are cards left in the deck, keep searching
while ($numfound < $targetmatches && count($deck) > 0) {
$card = dealCard();
switch($card) {
// 1 is a target card
case 1: $numt1++;
break;
// 2 is a target2 card
case 2: $numt2++;
break;
// didn't find anything special
default: break;
} // switch
// we have a match in our hand
if ($numt1 > 0 && $numt2 > 0) {
$numfound++;
$numt1;
$numt2;
}
// if we have too many of card 1 in our hand, discard it
if ($numt1 > $hold) {
$numt1;
}
// if we have too many of card 2 in our hand, discard it
if ($numt2 > $hold) {
$numt2;
}
} // while
// how many cards did I use?
$winners[$decksize  count($deck)]++;
} // for each game
// Calculate the average number of cards needed to hit
// the desired number
$averageWinner = 0;
for ($i = 1; $i <= $decksize; $i++) {
$averageWinner += $winners[$i] * $i;
}
$averageWinner /= $GAMES;
?>
The average number of cards required to find
matches of
the two cards is 0.

= 12 && $decksize <= 30) {
$openingDraw = $winners[1] + $winners[2] + $winners[3] + $winners[4];
$openingDraw /= $GAMES;
$openingDraw = round(100*$openingDraw);
?>
Since your deck size is cryptlike, you might like to
know that the experimental chance of having at least
one combo in your opening crypt is
%, though you can figure out the exact
chance mathematically.

Examples
I have 8 Concealed Weapons and 8 .44 Magnums in my deck;
when should I expect to draw at least 1 of each?
Decksize = 90, Target1 = 8, Target2 = 8, Desired = 1
...When should I expect to draw at least 2 of each?
Decksize = 90, Target1 = 8, Target2 = 8, Desired = 2
I have 12 Raptors and 10 Pack Alphas in my 90 card
deck; when should I expect to draw at least 7 of each?
Decksize = 90, Target1 = 12, Target2 = 10, Desired = 7
I have 3 Edith Blount and 3 Enid Blount in my 12
card crypt; when should I expect to draw at least 1 of
each?
Decksize = 12, Target1 = 3, Target2 = 3, Desired = 1
(For this result, I recommend printing 4 lines together,
so you can easily notice if the match will be in your
opening crypt draw.)