WHAT IS IT?
------------
This project models the behavior of two types of turtles in
a mythical pond. The red turtles and green turtles get along
with one another. But each turtle wants to make sure that it
lives near some of "its own." That is, each red turtle wants
to live near at least some red turtles, and each green
turtle wants to live near at least some green turtles. The
simulation shows how these individual preferences ripple
through the pond, leading to large-scale patterns.

This project was inspired by Thomas Schelling's writings
about social systems (such as housing patterns in cities). 

HOW TO USE IT
--------------
Click the SETUP button to set up the turtles. There are
equal numbers of red and green turtles. The turtles move
around until there is at most one turtle on a patch. 
Click GO to start the simulation. If turtles don't have
enough same-color neighbors, they jump to a nearby patch.

The NUMBER slider controls the total number of turtles. (It
takes effect the next time you click SETUP.) 
The %SIMWANT slider controls the percentage of same-color turtles that
each turtle wants among its neighbors. For example, if the
slider is set at 30, each green turtle wants at least 30% of
its neighbors to be green turtles. 

The %-SIMILAR-OVERALL monitor shows the average percentage
of same-color neighbors for each turtle. It starts at about
0.5, since each turtle starts (on average) with an equal
number of red and green turtles as neighbors. The UNHAPPY-TURTLES monitor
shows the number of turtles that have fewer same-color 
neighbors than they want (and thus they want to move).
The monitor values are also dynamically graphed.

THINGS TO NOTICE
----------------
When you execute SETUP, the red and green turtles are 
randomly distributed throughout the pond. But many turtles
are "unhappy" since they don't have enough same-color
neighbors. The unhappy turtles jump to new locations. But in
the new locations, they might tip the balance of the local
population, prompting other turtles to leave. If a few red
turtles move into an area, the local green turtles might
leave. But when the green turtles move to a new area, they
might prompt red turtles to leave that area. 

Over time, the number of unhappy turtles decreases. But the
pond becomes more segregated, with clusters of red turtles
and clusters of green turtles.  

In the case where each turtle wants at least 30% same-color 
neighbors, the turtles end up with (on average) 70%
same-color neighbors. So relatively small individual 
preferences can lead to significant overall segregation.  

THINGS TO TRY
------------
Try different values for %-SIMILAR. How does the overall
degree of segregation change?

If each turtle wants at least 
40% same-color neighbors, what percentage (on average) do
they end up with?  

STARLOGOT FEATURES
-----------------
To calculate global statistics, each patch does a PSET on
the global variables (SIMILAR-NEIGHBORS and DIFF-NEIGHBORS).
Since the actual execution of the PSET commands is
sequential, not parallel, the patch calculations accumulate,
rather than conflicting with one another. 

Patches can not handle numbers larger than 32767. So some of
the calculation (e.g., in the the UPDATE-GLOBALS procedure)
are scaled (multiplied by 0.1) to prevent numbers from
growing too big. 

CREDITS AND REFERENCES
----------------------

Schelling, T. (1978). Micromotives and Macrobehavior. New York: Norton.

This model was adapted from the pond model at the MIT Media Lab. Adapted to StarLogoT, 1997, as part of the Connected Mathematics Project.