Patchbay for an old analog computer.

Scientific Computing (P05 Spring, 2004)
[Grades] [Compilers] [Links] [Syllabus]
[Examples] [Exams] [Reference]

 

Using C++ Programs to
Answer Questions About
The Game of Craps.

Craps is centered around the roll of a pair of dice by the "shooter".  Players can place various bets on the table, and win or lose those bets based on the outcome of the shooter's rolls.  The shooter's first roll can produce 3 outcomes, the most likely outcome is that the rolled value becomes the "point:"

  • 'a natural' (7 or 11);                                win         pr = 8/36 = 2/9

  • 'Craps' (2, 3, or 12); or                           →lose        pr = 4/36 = 1/9

  • 'a point' (4, 5, 6, 8, 9, or 10), ie the rest. →continue  pr = 2/3

Now a nice starting bet in Craps, is a bet on the PASS LINE.  This is done by placing your chips on the Craps table on the area marked PASS LINE before the shooter's first roll.  Now with a pass line bet, if the shooter rolls a natural you win.  If the shooter rolls Craps you lose, and if the shooter rolls the point, your bet remains and you win if the shooter rolls the point again before he rolls 7, and lose if and when 7 is rolled before the point.

You can also bet on the DON'T PASS LINE.  This is pretty much the reverse of the above - except you don't win on a 12 for the first roll...the bet is pushed--which (I think) means that it's called off.

You can also bet on the COME LINE after the shooter has had their first roll and already has the point.  This is pretty much the same as a pass line bet, in that you win if the point is rolled before 7, and lose if 7 is rolled before the point.

Anyway, here are all the bets summarized:

  • pass line
    1 to 1 pay-out, if the first roll of the dice adds up to 7 or 11, you win. 2, 3, or 12 loses the bet. Any other number becomes the 'point' and if the point is rolled again, you win, if 7 is rolled first you lose. 
    House edge: 1.4%
     

  • don't pass
    1 to 1 payout, if the first roll of the dice adds up to 7 or 11, you lose. 2, 3, you win. 12 is a stand off. Any other number becomes the 'point' and if the point is rolled again, you lose, if 7 is rolled first you win.
    House edge: 1.4%
     

  • come bets 
    1 to 1 pay-out, basically the same as the PASS LINE except that you must bet after the point. 
    House edge: 1.4%
     

  • don’t come 
    1 to 1 pay-out, the reverse of the COME BET, except that a first roll of 2 or 3 wins, and 12 is a stand off. 
    House edge: 1.4%

some other bets...

  • odds 
    'taking the odds'
    Once a ‘point’ or a ‘come point’ has been thrown and you have a pass line bet you may bet up to some multiple, usually 2 times, your pass line bet on the 'odds'.  You may take the odds and win if the point or the come point is made before a 7. Pay off is 2 to 1 for a point of 10's or 4's, 3 to 2 for a point of 9's or 5's, 6 to 5 for a point of 8's or 6's. 
    'laying the odds'
    This is the opposite of taking odds, in other words betting that a 7 will be rolled before the point, once the point or come point has been established. Pay off is 1 to 2 for a point of 10's or 4's, 2 to 3 for a point of 9's or 5's, 5 to 6 for a point of 8's or 6's.
    House edge on odds bets are very low - 0.5 to 1% depending on bet
     

  • big 6 or 8 
    Here you are betting that either a 6 or 8 will be rolled before the 7, for a 1 to 1 pay-out.  This represents a high house edge bet and is not recommended.
    House edge: 9.1%
     

  • place bets
    In craps 4,5,6,8,9, and 10 are known as the "place numbers."  In a place bet, you are betting that your place number is rolled before the 7.  No pass line or other bet on the point is required.  Place bets on 6 or 8 offer the lowest house edge and are recommended (note that odds bets are still a better bet though)
    House edge for 4 or 10: 6.7%
    House edge for 5 or 9:   4.0%
    House edge for 6 or 8:   1.5%
     

  • proposition bets
    This is simply a bet on the outcome of the next roll. Proposition bets have a high house edge and are not a recommended play.  Odds are as follows:
    2 or 12 pays 30 to 1, House edge: 13.9%
    3 or 11 pays 15 to 1, House edge: 11.1%
    7 pays 4 to 1, House edge: 16.7%
    Any craps (2, 3 or 12) pays 7 to 1, House edge: 11.1%
    Field ( 2,3,4,9,10,11, or 12), even money for (3,4,9,10,11), 2 to 1 for (2 or 12) House edge: 5.5%

 

In response to questions 4.19a,b, we can simulate a million rolls of the dice and look at how many wins and losses we get in the first twenty rolls and tabulate how many wins and and losses accumulate on the first 20 rolls and then after multiples of 20000 rolls up to a million.  Here is the result of one such simulation:


After 0 rolls, there are 0 wins and 0 losses.
After 1 rolls, there are 1 wins and 0 losses.
After 3 rolls, there are 1 wins and 0 losses.
After 4 rolls, there are 1 wins and 0 losses.
After 5 rolls, there are 1 wins and 0 losses.
After 6 rolls, there are 1 wins and 0 losses.
After 7 rolls, there are 1 wins and 0 losses.
After 7 rolls, there are 1 wins and 1 losses.
After 8 rolls, there are 1 wins and 2 losses.
After 9 rolls, there are 2 wins and 2 losses.
After 11 rolls, there are 2 wins and 2 losses.
After 12 rolls, there are 2 wins and 2 losses.
After 13 rolls, there are 2 wins and 2 losses.
After 13 rolls, there are 2 wins and 3 losses.
After 14 rolls, there are 3 wins and 3 losses.
After 16 rolls, there are 3 wins and 3 losses.
After 17 rolls, there are 3 wins and 3 losses.
After 18 rolls, there are 3 wins and 3 losses.
After 18 rolls, there are 4 wins and 3 losses.
After 20 rolls, there are 4 wins and 3 losses.
After 20000 rolls, there are 2871 wins and 3021 losses.
After 100000 rolls, there are 14646 wins and 15295 losses.
After 120000 rolls, there are 17489 wins and 18277 losses.
After 120000 rolls, there are 17490 wins and 18277 losses.
After 140000 rolls, there are 20369 wins and 21332 losses.
After 160000 rolls, there are 23258 wins and 24338 losses.
After 160000 rolls, there are 23259 wins and 24338 losses.
After 180000 rolls, there are 26059 wins and 27322 losses.
After 200000 rolls, there are 28934 wins and 30377 losses.
After 240000 rolls, there are 34791 wins and 36307 losses.
After 240000 rolls, there are 34791 wins and 36308 losses.
After 260000 rolls, there are 37806 wins and 39380 losses.
After 280000 rolls, there are 40758 wins and 42386 losses.
After 280000 rolls, there are 40758 wins and 42387 losses.
After 300000 rolls, there are 43689 wins and 45393 losses.
After 320000 rolls, there are 46616 wins and 48349 losses.
After 340000 rolls, there are 49559 wins and 51334 losses.
After 340000 rolls, there are 49559 wins and 51335 losses.
After 360000 rolls, there are 52477 wins and 54358 losses.
After 380000 rolls, there are 55427 wins and 57266 losses.
After 400000 rolls, there are 58263 wins and 60337 losses.
After 420000 rolls, there are 61160 wins and 63337 losses.
After 440000 rolls, there are 64045 wins and 66357 losses.
After 460000 rolls, there are 66970 wins and 69375 losses.
After 480000 rolls, there are 69901 wins and 72373 losses.
After 500000 rolls, there are 72807 wins and 75332 losses.
After 520000 rolls, there are 75656 wins and 78343 losses.
After 540000 rolls, there are 78491 wins and 81374 losses.
After 540000 rolls, there are 78491 wins and 81375 losses.
After 560000 rolls, there are 81442 wins and 84389 losses.
After 580000 rolls, there are 84385 wins and 87341 losses.
After 600000 rolls, there are 87372 wins and 90380 losses.
After 600000 rolls, there are 87372 wins and 90381 losses.
After 620000 rolls, there are 90231 wins and 93365 losses.
After 620000 rolls, there are 90231 wins and 93366 losses.
After 640000 rolls, there are 93126 wins and 96304 losses.
After 660000 rolls, there are 95978 wins and 99220 losses.
After 680000 rolls, there are 98885 wins and 102252 losses.
After 700000 rolls, there are 101763 wins and 105237 losses.
After 700000 rolls, there are 101763 wins and 105238 losses.
After 720000 rolls, there are 104629 wins and 108280 losses.
After 740000 rolls, there are 107524 wins and 111267 losses.
After 760000 rolls, there are 110493 wins and 114320 losses.
After 800000 rolls, there are 116392 wins and 120436 losses.
After 820000 rolls, there are 119460 wins and 123428 losses.
After 900000 rolls, there are 131132 wins and 135461 losses.
After 920000 rolls, there are 133981 wins and 138486 losses.
After 920000 rolls, there are 133981 wins and 138487 losses.
After 940000 rolls, there are 136905 wins and 141461 losses.
After 960000 rolls, there are 139811 wins and 144549 losses.
After 960000 rolls, there are 139811 wins and 144550 losses.
After 980000 rolls, there are 142784 wins and 147500 losses.
After 1000000 rolls, there are 145648 wins and 150570 losses.

From this we can glean a few interesting inferential statistics.  The total number of wins and losses is 296218 which means there are about 3.376 rolls per game (this is my answer for question 4.19d).  The empirical probability of winning is 145648/296218 ~ 0.4917 which gives the house an edge of 2*0.0083 = 1.66%.  In fact, simulating a hundred million rolls, I consistently get an edge of at least 1.5%, contradicting the assertion in the game description above...

As to the last question: "Do the chances of winning improve with the length of the game?"  This question may be somewhat ambiguous--it's meaning certainly could use clarification. The rewording, "Does the probability of winning in exactly n games increase with n?" is a legitimate interpretation. The theoretical values are
P(1) = 8/36 = 2/9 ~ .222222
P(2) = (p(x=4))^2+(p(x=5))^2+(p(x=6))^2+(p(x=8))^2+(p(x=9))^2+(p(x=10))^2
     =  (3/36)^2 + (4/36)^2 + (5/36)^2 + (5/36)^2 + (4/36)^2 + (3/36)^2
     =  1/72 + 2/81 + 25/648 = 25/324 ~ 0.07716

These two theoretical computation provide a good basis to t
est the results of simulating this process using C++ code.  Simulating game play 100,000,000 times (where one play means you keep rolling until you win or lose) and counting the number of wins in a fixed number of rolls we get an empirical answer to the question by tabulating wins and losses with the length of the game. Note that the first two values are closely in line with the theoretical values.

rolls    won     lost
  1   22168890 11113383
  2    7676104 11136997
  3    5520509  7989994
  4    3939763  5727807
  5    2817545  4127076
  6    2015569  2972787
  7    1435159  2134027
  8    1033831  1519846
  9     721139  1118062
 10     533291   811232
 11     384689   585277
 12     273185   419087
 13     195514   299100
 14     142121   223298
 15     102784   162647
 16      73255   115700
 17      53083    84851
 18      39307    63245
 19      27732    45038
 20      20092    32646
 21      14815    24124
 22      10794    17628
 23       7829    13134
 24       5545     9375
 25       4301     6890
 26       3069     4928
 27       2161     3652
 28       1604     2628
 29       1135     2061
 30        844     1521
 31        625     1077
 32        425      767
 33        366      597
 34        221      395
 35        202      314
 36        120      197
 37         88      159
 38         66      120
 39         63      104
 40         39       50
 41         33       55
 42         18       43
 43         28       22
 44         13       18
 45          7       11
 46          3        5
 47          4        7
 48          0        8
 49          4        5
 50          0        4
 51          0        2    
 52          2        2
 53          0        4
 54          0        2
 55          0        0
 56          0        0
 57          1        1
 58          1        0
 59          0        1