Let's Make a Deal?

The old television show, Let's Make a Deal, often played the following game with contestants: A new car is behind on of three doors. The contestant picks one of the doors at random. Monty Hall would then open one of the doors the contestant didn't pick and offer the contestant the choice of staying with his original guess or switching to the remaining door. So, the question is, should the contestant go with his original guess or should he switch doors?

This game is of course older than the TV show. Martin Gardner mentioned it as a card game in his column in Scientific American in the 1950s. More recently it caused a flurry of letters from all sorts of people, some of them mathematicians, when it appeared in Marilyn vos Savant's newspaper column. Martin and Marilyn gave the correct answer: change your guess but many people still do not believe it. So, I decided to run this little game as a computer simulation. Since this is a little game we only need a little program and I therefore chose a little computer on which to run it. Specifically, I wrote a program for a 1k Timex/Sinclair-1000 (ZX81) computer which plays this game and gives the percent correct for players who stick with their original guess and those who switch when given the chance. The commented source code follows.

10 GOTO 200 ; jump to the program start

20 LET S=1 ; Constants for the LCG random number generator, S is the seed
30 LET A=82669 ; Multiplier
40 LET M=131072 ; Modulo: F = A*F MOD M
55 RETURN

60 LET F=S*A ; Implement the random number generator, answer in F
65 LET F=F-M*INT(F/M)
70 LET S=F
75 LET F=S/M ; F = [0,1)
80 RETURN

100 GOSUB 60 ; Get a random integer: 0, 1, 2
105 LET F=INT(3*F)
110 RETURN

200 GOSUB 20 ; intialize random number generator
210 LET C=0 ; Counts number of trials
215 LET R=0 ; Number of correct initial guesses
220 LET W=0 ; Number correct after changing guess
225 GOSUB 100 ; Get a random integer, 0-2
230 LET G=F ; And make it the door with the car, G
235 GOSUB 100 ; Get another integer, 0-2
240 LET B=F ; This is the player's original guess, B
245 IF B=G THEN LET R=R+1 ; Did they get it on the first try?
250 GOSUB 100 ; Get another random integer, 0-2
255 IF G=F OR B=F THEN GOTO 250 ; Until it is neither the car nor the guess
260 LET B=3-(F+B) ; Set the guess to the remaining door (i.e. change the guess)
270 IF G=B THEN LET W=W+1 ; If player is now right, count it
275 LET C=C+1 ; This trial is over
280 GOSUB 500 ; So update the screen
285 GOTO 225 ; And do it again

500 PRINT AT 1,0;"RUN ";C ; Print the results of a run
505 PRINT AT 5,0;"INIT ";R;", ";100*R/C
510 PRINT AT 9,0;"CHANGE ";W;", ";100*W/C
515 RETURN

Line 260 might seem a little mysterious. It is a way of making the value of B, the player's guess, the door that isn't already open (which is in F) or the one the player has already picked. It works because the sum of 0+1+2 = 3 so subtracting the sum of any two doors, 0, 1, or 2, will necessarily leave the number of the door that wasn't in the sum.

When this program is run the percent of guesses correct initially and after switching doors will begin to settle down as the number of trials increases. As expected, the chance of guessing correctly from among the three doors will approach 1/3 or 33 percent. However, the odds of getting the correct door when the player changes his guess is not 33 percent but 2/3 or 66 percent, which is what Martin and Marilyn said it should be. Running the program for a long time will cause the percents to "drift" from their mathematical values of 1/3 and 2/3 respectively. This is due to the not-so-hot choice of constants for the random number generator. I didn't use the generator built into the machine because I wanted to control the generation of random numbers. There are better choices of constants available but unfortunately they exceed the precision of the T/S-1000. Still, the numbers are obviously close to the expected percentages to be convincing.

Wanna Try It Yourself?

If you have a real T/S-1000 or ZX-81 machine then simply type the program in and run it. Since most people don't have these machines around anymore the next best thing is to use an emulator. Emulators for the PC do exist though the TS-1000 emulator dies on Pentium class PCs in MS-DOS under W95. It will work on older machines: I ran it on a Mac emulating a 80286 PC with MS-DOS 5.0 and it worked fine. I wrote the program using the Mac ZX-81 emulator which can be found, along with many excellent Mac emulators, here. (Naturally, I did verify the program on a real T/S-1000!)

Download MONTY.81, a tape image of the above program for T/S-1000 and ZX-81 emulators.

More information, including extensions of the problem to n doors, can be found here on Dennis Donovan's page.



Last update: 30-Jan-00
Back 1