NetLogo banner

Home
Download
Help
Resources
Extensions
FAQ
NetLogo Publications
Contact Us
Donate

Models:
Library
Community
Modeling Commons

Beginners Interactive NetLogo Dictionary (BIND)
NetLogo Dictionary

User Manuals:
Web
Printable
Chinese
Czech
Farsi / Persian
Japanese
Spanish

  Donate

NetLogo User Community Models

(back to the NetLogo User Community Models)

[screen shot]

Download
If clicking does not initiate a download, try right clicking or control clicking and choosing "Save" or "Download".(The run link is disabled for this model because it was made in a version prior to NetLogo 6.0, which NetLogo Web requires.)

## 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
ball back into the urn, otherwise she returns one white ball into the urn.

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.
In the end, you will realize that the only initial condition that is enough to give a certain prediction of the final state of the system is whether the amount of white balls is even or odd.

## EXTENDING THE MODEL

Try experimenting different set of rules.
Improve the animation so that each "block" of balls generated in each cycle has a better visualization of the history of movements.

## 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.
The code is designed for testing. The "model verification" is devised by design rather than fighting with bugs.

## 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
Computer Science Through Urn Games: An Unified Framework
for a Hierarchy of Solvable and Unsolvable Problems
Sorin Istrail
Department of Computer Science
Brown University
Dedicated to Alan Turings 100th Birthday and to the memory of Professor Edsger W. Dijkstra

(back to the NetLogo User Community Models)