# A tile drawing simulation with trials

\$decksize + 1) { // print out however many we can \$numlines = \$decksize - \$startingCard + 1; } // rough error checking if (\$startingCard < 0 || \$startingCard > \$decksize || \$numlines < 1) { return; } if (\$numlines == 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 < \$numlines; \$i++) { \$tempGames += \$winners[\$startingCard + \$i]; } \$sumWinners += \$tempGames; echo " \n"; echo " ".\$startingCard." - ".(\$startingCard+\$numlines-1)."\n"; echo " ".\$tempGames."\n"; echo " ".\$sumWinners."\n"; echo " \n"; return; } for (\$g = 0; \$g < \$GAMES; \$g++) { shuffleDeck(); \$numfound = 0; \$numdrawn = 0; // while we haven't drawn enough cards yet and // there are cards left in the deck, keep searching while (\$numdrawn++ < \$numtodraw && count(\$deck) > 0) { \$card = dealCard(); switch(\$card) { // 1 is a target card case 1: \$numfound++; break; // didn't find anything special default: break; } // switch } // while // how many target cards did I find? \$winners[\$numfound]++; } // for each game // Calculate the average number of target cards found \$averageWinner = 0; for (\$i = 1; \$i <= \$decksize; \$i++) { \$averageWinner += \$winners[\$i] * \$i; } \$averageWinner /= \$GAMES; ?> The average number of target tiles found in draws is 0.

Target Tiles Found Games Sum
 Number of tiles in deck: Number of target tiles: Number of tiles to draw: Number of trials: Number of lines to print together: