NetLogo User Community Models
by jose costas (Submitted: 07/09/2013)
## WHAT IS IT?
Consider the following silly game to be played by a single person with an urn and as many white balls and black balls as he needs. To begin with an arbitrary positive number of balls is put into the urn, and as long as the urn contains two or more balls, the player repeats the following move: she shakes the urn and, without looking, she takes two balls from the urn; if those two balls have the same color she throws one black
Because each move decreases the total number of balls in the urn by 1, the game is guaranteed to terminate after a finite number of moves, and it is not difficult to see that the game ends with exactly 1 ball in the urn.
The question is: "What can we say about the color of that final ball when we are given the initial contents of the urn?"
## HOW IT WORKS
An agent scribe (breed mechanism) takes care of applying the rules to the urn; this agent works in a series of steps: checks if the game is over, extracts a pair of balls, decides the color of the ball tha must be entered to the urn, and ejects the stuff of the problem-world to a sink area so to have a basic animation about what is going on.
Besides, the command center shows a log of what the system is doing.
## HOW TO USE IT
Just use the sliders to decide how many white and red balls do you want for the initial composition of the urn (system initial conditions).
## THINGS TO NOTICE
You will see the extraction at the righ side of the urn, with a pair of colored circles that represents the extracted balls.
You will see on the left side of the urn the ball about to enter the urn as a consequence of applying the rules. This ball is cloned for the animation purpose. Its clone will join the pair of balls fo the extraction with a flag shape to distinguish.
The history of 3-ball set generated at each cycle can be seen at the right side in the sink area. They move to north each time whenever there is still space.
## THINGS TO TRY
Experiment different urn compositions and try to identify a pattern of system behavior.
## EXTENDING THE MODEL
Try experimenting different set of rules.
## NETLOGO FEATURES
Realize the application of the "jidoka" principle of lean manufacturing: the code has lot of "self-control", so to have early detection of mistakes when doing the model.
## RELATED MODELS
There is plenty of literature about urns and probability; see, for instance: http://www.math.tamu.edu/~jlewis/ProbII.htm
Simulation is a very nice approach to get insights in many of such type of problems; the one modeled here is one example.
## CREDITS AND REFERENCES
(back to the NetLogo User Community Models)