globals [ done? ; indicates whether the race is over or not yet ] turtles-own [ guess ; what each turtle guesses to be the right door prize ; where the prize is located other ; the number of the door that the host or hostess does NOT open choice hunch ; the bias each turtle has to switch or not to switch doors ] to setup ca ask patches [ set pcolor green ] cct number [ ifelse (gradation?) [ set hunch (random 101) ] ; gradation is on, so give a hunch BETWEEN 0 and 100 [ set hunch ((random 2) * 100 )] ; gradation is off, so give a hunch of 0 or 100 set color scale-color gray hunch 0 100 ; set the color based on the hunch of the turtles set heading 0 ; spread the turtles out across the bottom of the screen setxy (random screen-size-x) (0 - screen-edge-y) ] set done? false ; the race is not over yet end to go if done? [ stop ] ask turtles [ make-choices ; choose a door that the turtles will choose, a door for the prize, and set the other door do-switch? ; should each turtle switch to the other door? award-prizes ; make the winning turtles go forward and don't do anything if the race has been won ] end ; choose a door that the turtles will choose (guess), a door for the prize (prize), and set the other door that is not opened (other) to make-choices set prize (random 5) set guess (random 5) if (prize = 0) ; the prize is behind door number 0 [ ifelse (guess = 0) ; the turtle guessed door 0 [ set choice ((random 4) + 1) ] ; since the prize is in the door the turtle picked, pick door 1 or 2 to not be opened by the host or hostess ; the turtle guessed door 1 or 2 ; it doesn't matter which door is picked to be not opened since both doors 1 and 2 have the junk behind them [ set choice 0 ] set other choice ] if (prize = 1) ; the prize is behind door number 1 [ ifelse (guess = 1) ; the turtle guessed door 0- a door with junk behind it [ set choice (random 5) if (choice = 1) [set choice (choice + 1)] ] ; so set the door not to be opened to door 1, the door with the prize behind it. now door 2- with junk behind it- can be opened. [ set choice 1 ] ; so set the door not to be opened to door 1, the door with the prize behind it. now door 0- with junk behind it- can be opened. set other choice ] if (prize = 2) ; the prize is behind door number 2 [ ifelse (guess = 2) [ set choice (random 5) if (choice = 2) [set choice (choice + 1)] ] ; so set the door not to be opened to door 2, the door with the prize behind it. now door 2- with junk behind it- can be opened. [ set choice 2 ] ; so set the door not to be opened to door 2, the door with the prize behind it. now door 0- with junk behind it- can be opened. set other choice ] if (prize = 3) ; the prize is behind door number 2 [ ifelse (guess = 3) [ set choice (random 5) if (choice = 3) [set choice (choice + 1)] ] ; so set the door not to be opened to door 2, the door with the prize behind it. now door 2- with junk behind it- can be opened. [ set choice 3 ] ; so set the door not to be opened to door 2, the door with the prize behind it. now door 0- with junk behind it- can be opened. set other choice ] if (prize = 4) ; the prize is behind door number 2 [ ifelse (guess = 4) [ set choice (random 5) if (choice = 4) [set choice (choice - 1)] ] ; so set the door not to be opened to door 2, the door with the prize behind it. now door 2- with junk behind it- can be opened. [ set choice 4 ] ; so set the door not to be opened to door 2, the door with the prize behind it. now door 0- with junk behind it- can be opened. set other choice ] end ; should each turtle switch to the other door? this is based on the hunch in each turtle to do-switch? if (random 100 < hunch) [ set guess other ] end ; make the winning turtles go forward and don't do anything if the race has been won to award-prizes if (guess = prize) [ if (not done?) ; if the race is not done, move the winners forward by 1 patch [ fd 1 ] ] ; if a turtle has reached the top of the screen, set done? to be true if (ycor = screen-edge-y) [ set done? true ] end ; This model was created as part of the project: CONNECTED MATHEMATICS: ; MAKING SENSE OF COMPLEX PHENOMENA THROUGH BUILDING OBJECT-BASED PARALLEL ; MODELS (OBPML). The project gratefully acknowledges the support of the ; National Science Foundation (Applications of Advanced Technologies ; Program) -- grant numbers RED #9552950 and REC #9632612. ; Copyright 1998 by Uri Wilensky. All rights reserved. ; This model was converted to NetLogo as part of the project: ; PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN ; CLASSROOMS. The project gratefully acknowledges the support of the ; National Science Foundation ( REPP program ) -- grant number REC #9814682. ; Converted from StarLogoT to NetLogo, 2001. @#$#@#$#@ GRAPHICS-WINDOW 203 19 629 445 35 35 6.0 1 13 0 0 CC-WINDOW 4 320 200 461 Command Center SLIDER 7 76 197 109 number number 1 1000 500 1 1 NIL BUTTON 30 18 96 51 setup setup NIL 1 T OBSERVER BUTTON 108 18 177 51 go go T 1 T OBSERVER SWITCH 49 142 174 175 gradation? gradation? 1 1 -1000 TEXTBOX 313 454 557 497 Lighter turtles switch doors more often.\nDarker turtles switch doors less often. TEXTBOX 29 190 184 307 if Gradation is off, all turtles stick with one strategy, either the "stick" or the "switch" strategy. If Gradation is on, they do mixed strategies. @#$#@#$#@ WHAT IS IT? ----------- You are a contestant on a game show. You, of all people, have made it to the final round, where you have the chance to win some fabulous prize -- a car, a million dollars, eternal youth, etc... The host or hostess of the game show takes you up on stage, where you stand before three doors, marked "0", "1", and "2". "Your prize is behind one of these three doors. Behind the other two are goats, and you don't want these goats. So, which one will you pick?" she or he says. You make your selection, and reach for the door -- but before you open it, the hostess or host says to you: "All right, now I'm going to give you a choice." She or he opens another one of the doors, one you didn't pick. And sure enough, there's an ugly old goat. The hostess or host then points to the other door, saying: "If you want, you can change your mind, and pick the last door; the door you didn't pick that I didn't open. So now, which will it be? Your first selection? Or the other door?" You think for a brief moment... Which will it be? Will you stick with your first choice, or switch to the other door? Does it matter? Do you have better odds of winning the prize by switching or sticking? Or is it even odds either way? (We're assuming here that you want the prize and have an aversion to goats. If you really would prefer the goat, then the prize is the goat, and the two other doors are empty, or contain mulch, whatever...) This is a classic puzzle in thinking about probability. It has several other names: the 'Monty Hall' puzzle (named after the host of the game show this is taken from: "Let's Make a Deal") and 'Goats-and-Car' being the two most common. The puzzle is based around the questions being asked above, which really boil down to one question at the heart of the matter: which is it better to do, stick or switch? This project is called Three Doors. Essentially what goes on is this: an arbitrary number of turtles (around several hundred, usually) gather together at the bottom of the screen. They then begin to play this three-doors game over and over again. The prize they can win is a turtle-command: 'fd 1'. If they lose, nothing happens. Thus, the turtles are having a race to the top of the screen, and they can only advance in the race if they win a prize. Turtles determine the results of each round of the contest by themselves, alternately acting as contestant and host or hostess. Also, each turtle has a 'hunch' - a percentage chance that it will switch to the other door. The value of 'hunch' determines a turtle's color. A turtle that always sticks with its original choice of doors has a hunch of 0 and is colored black. A turtle that always switches its choice of doors has a hunch of 100 and is colored white. HOW THIS MODEL HAS BEEN EXTENDED --------------------------------- Originally the model had only 3 doors. I wondered if this was a limitation and if the system would respond differenly if the number of options was increased. This proved to be tougher than I originally thought it would because the system was designed to handle only 3 doors. I thought I would include a slider so that the user could decide how many doors to use but I realised that this did not help understand the model in any particular way and was only adding to the complexity of the code so i decided to keep the number of doors constant at 5. This addition of 2 more doors to the original model is sufficient to observe the changes that occur. I had guessed that if i added more doors, this would cancel the effect of helping the turtles that choise to swith doors and so they would not win everytime. But when I implented the changes I was surprised to see that the very opposite of this happened. The turtles which chose to switch reached the finish line even faster than they did initially. This model really interested me and I am still trying to understand why it does what it does. @#$#@#$#@ default true 0 Polygon -7566196 true true 150 5 40 250 150 205 260 250 @#$#@#$#@ NetLogo 1.1 (Rev F) @#$#@#$#@ @#$#@#$#@ @#$#@#$#@