[image of digits] Borland C++ Builder - Segregation & Assimilation

Segregation & Assimilation Models

Some inspiration from the intelligence community:

Robert McNamara, "Seeing and believing are both often wrong..." (5m30s)
Robert McNamara, "On three separate occasions..." (1m27s)
Robert McNamara, "We lucked out!" (0m49s)
CIA (The Recruit Bonus), "You've got to get it right..." (1m49s)
CIA (The Recuit Bonus), "The complexities arise..." (2m32s)

Can you deduce the local processes from the global patterns?
Segratation implies that the agents move but do not change.
Assimilation implies that the agents change but do not move.
The applications below incorporate both of these functionalities.

The application proceeds as follows:

At random, it picks a cell designated as an agent (cyan, magenta, yellow or silver). This cell is called "home."
At random, it then picks a cell designated as empty (black) at a distance no further than the "mobility" away from "home." This cell is called "destination."
Walls or barriers (white) are never picked and serve only as environmental constraints.

If it cannot find a valid "home" / "destination" pair, it picks again.
After several thousand tries, it gives up and the program stops.

Once a valid "home" and "destination" pair is found, the agent can check a variety of neighborhoods of these two locations and either:
move from "home" to "destination" by calling moveMe()
or
change to another agent type by calling changeMeTo()

More than one function may be called for any single rule yielding the following results:
One moveMe() or one changeMeTo() will not change the total population.
The sequence changeMeTo()followed by moveMe()will not change the total population.
The sequence moveMe()followed by changeMeTo() will add an individual.
The sequence moveMe()followed by moveMe()will delete an individual.

XE6 upgraded versions

XE6 Segregation & Assimilation 200 x 200 - Version 1
17 March 2015
The user interface and code have been further simplified.
Rule 29 (Agitators and Cops) has been enhanced.
Note: The choice of Moore, Tong or Von Neumann neighborhoods is only valid for ...8Neighborhood counts.

  • NEW: Notes organized according to a Sense-Think-Act (STA) architecture.

XE6 Segregation & Assimilation Sluis - 492 x 563 DEM - Version 1
Using the SLUIS ditigal elevation model (DEM)
17 March 2015
The world has been expanded to the size of the Sluis DEM. which can be opened from a file.
This adds a third importable data-set in addition to RGB bitmapped variables and CMYKW initial agent conditions.
The application has been speeded up by drawing to an internal TImage object instead of directly to the PaintBox.
A first rule (44) tells Magenta to climb, Cyan to descend, and Yellow to seek a middle elevation of 450.
Cyan descends, somewhat like rain, but since the current application only allows only one agent type per cell, the "rain" cannot accumulate.

  • NEW: Notes organized according to a Sense-Think-Act (STA) architecture.
RadStudio2010 and older versions

Segregation & Assimilation - 492 x 563 - version 31
Using the SLUIS ditigal elevation model (DEM)
18 March 2013

The world has been expanded to the size of the Sluis DEM. which can be opened from a file.
This adds a third importable data-set in addition to RGB bitmapped variables and CMYKW initial agent conditions.
The application has been speeded up by drawing to an internal TImage object instead of directly to the PaintBox.
A first rule (44) tells Magenta to climb, Cyan to descend, and Yellow to seek a middle elevation of 450.
Cyan descends, somewhat like rain, but since the current application only allows only one agent type per cell, the "rain" cannot accumulate.

  • NEW: Notes organized according to a Sense-Think-Act (STA) architecture.

Segregation & Assimilation - 492 x 563 - version 30
Using the SLUIS ditigal elevation model (DEM)
10 March 2013

The world has been expanded to the size of the Sluis DEM. which can be opened from a file.
This adds a third importable data-set in addition to RGB bitmapped variables and CMYKW initial agent conditions.
The application could be speeded up by drawing to an internal TImage object instead of directly to the PaintBox.
A first rule might simply tell M to climb and C to descend, but never too steeply.
The current application only allows one agent type per cell. For rain or snow, "agents" should be alowed to pile up.

  • NEW: Notes organized according to a Sense-Think-Act (STA) architecture.

Segregation & Assimilation 200 x 200 - Version 28a
25 October 2012
The user interface and code have been further simplified.
Rule 29 (Agitators and Cops) has been enhanced.
Note: The choice of Moore, Tong or Von Neumann neighborhoods is only valid for ...8Neighborhood counts.

  • NEW: Notes organized according to a Sense-Think-Act (STA) architecture.

Segregation & Assimilation - Version 28 - 17 October 2012
The user interface and code have been further simplified.
Note: The choice of Moore, Tong or Von Neumann neighborhoods is only valid for ...8Neighborhood counts.

  • NEW: Notes organized according to a Sense-Think-Act (STA) architecture.

Importable 200 x 200 pixel bitmaps:
These are thumbnails only; they link to the full-sized images.
Right-click and "Save Target as" or simply click and save the larger image that then appears...

These bitmap images will fill the "visible" PaintBox array with 5 cell types: CMY and/or Silver agents, and/or 2 environmental variables: Black empty space and/or White barriers:
xx xx xx xx xx xx xx xx xx x

These bitmap images will fill the "invisible" hidden array with RGB color gradients to be used as added environmental constraints:
x x x xx xx x
xx xx xx xx xx x

 

Segregation & Assimilation - Version 27 - 13 March 2012
The user interface has been somewhat simplified.

Segregation & Assimilation - Version 26 - 25 October 2011
The user interface has been somewhat simplified.

Segregation & Assimilation - Version 25 - 21 March 2011
Has the ability to zoom into the top-left corner of the world as well as to track the progress of one or more individual agant cells.
Run may be set to a single frame to facilitate tracking.
Remembered world has been modified.
Contains the "Preference or Prejudice" rules, 37 & 38.
Contains the "Chase with Delays" rules,
Contains the "Target Seeking" rules, 35 & 36,

Segregation & Assimilation - Version 24 - 17 March 2011
Contains the "Preference or Prejudice" and "Chase with delays" rules.

Segregation & Assimilation - Version 23a - 19 October 2010
Contains the two "target-seeking" rules. Otherwise the same a Version 23.

Segregation & Assimilation - Version 23 - 16 February 2010
Rule 30: Different Mobilities for Different Agent Types
Screen shot at left grew from mobilities of Magenta = 200, Cyan = 10 and Yellow = 2 (despite what the ComboBox says).
(Note: A mobility of 1 is deceptive, since the 8-cell destination will always have one neighbor of type myType, specifically itself, since the home position is only one cell away.)

This version was modified to accommodate more complex agents:

A makeValid() function call to wrap out-of-bounds array indices has been added.

The world[][] array has been made into a class structure to accommodate additional "agent" characteristics which are developed as the program runs. In this sense they may be considered "memories".
World[][] now has a ".type" and an ".excitedness". Others may be added as long as you take care of the "housekeeping" such as resetting and showing their values.

The bmpRed[][], bmpGreen[][], and bmpBlue[][] arrays have been separated from the world[][] arrays.
These arrays are for the import of "environments" created in PhotoShop.

Segregation & Assimilation - Version 22 - 14 February 2010
Rule 29: Riot Dynamics with Cops & Agitators
This version was modified to accommodate more complex agents:


A makeValid() function call to wrap out-of-bounds array indices has been added.

The world[][] array has been made into a class structure to accommodate additional "agent" characteristics which are developed as the program runs. In this sense they may be considered "memories".
World[][] now has a ".type" and an ".excitedness". Others may be added as long as you take care of the "housekeeping" such as resetting and showing their values.

The bmpRed[][], bmpGreen[][], and bmpBlue[][] arrays have been separated from the world[][] arrays.
These arrays are for the import of "environments" created in PhotoShop.

Segregation & Assimilation - Version 21 - 11 February 2010
Rule 29: Riot Dynamics with Cops & Agitators
This version was modified to accommodate more complex agents. Agents in previous versions only have four states (cyan, magenta, yellow and silver) and are represented in a raster/cellular world along with empty (black) and barrier (white) cells. There are no sub-types of any of these agent-cells. Consequently we could only represent the type of agent and type of cell. In this version, the red, blue and green arrays are used to hold additional agent data

The code will be cleaned up with:
the addition of a makeValid() function call to wrap out-of-bounds array indices.
variable and function names will be shortened.
collisions between segregation and assimilation will be managed.

In this version, we've represented the state of excitedness of a crowd (yellow) infiltrated by both cops (cyan) and agitators (magenta). Initialize the simulation with lots of crowd agents and only a few cops and agitators and set mobility quite low. Cops and agitators wander at random; the crowd agents tend to move away from them. The crowd agents take on a state of excitedness as a function of both their neighbors in the crowd (at a distance) and the proximity of cops and agitators (at a lesser distance). The levels of influence were modified to produce an ongoing dynamic. The standard visualization of agent-type (CMY) is dominant, and the state of excitedness of the crowd can be visualized by pressing the "Show Red Array" button. There are two rendering choices for the state of excitedness: "B/R" or blue and red for calm and aggitated, or "Color" with cool colors representing calm and warm colors representing excitedness. The neutral excitedness color is green but it shifts as the simulation progresses. The agent's memory (the agent's state of excitedness) is stored in the bmpRed array and is moved when the agent is moved.

Segregation & Assimilation - Version 20a - Riot Dynamics with Cops & Agitators
October 20, 2009
(zeroizing the bmpRed array has been fixed)
Modified from Version 19 to accommodate more complex agents. Agents in previous versions only have four states (cyan, magenta, yellow and silver) and are represented in a raster/cellular world along with empty (black) and barrier (white) cells. There are no sub-types of any of these agent-cells. Consequently we can only represent the type of agent and type of cell.

The framework was originally designed with agent simplicity in mind. Thus to add a sub-state of an agent is a bit of a kludge, so you probably don't want to continue in this direction with this framework. In this version, we've tried to represent the state of excitedness of a crowd (yellow) infiltrated by both cops (cyan) and agitators (magenta). Initialize the simulation with lots of crowd agents and only a few cops and agitators and set mobility quite low. Cops and agitators wander at random; the crowd agents tend to move away from them. The crowd agents take on a state of excitedness as a function of both their neighbors in the crowd (at a distance) and the proximity of cops and agitators (at a lesser distance). The levels of influence were modified to produce an ongoing dynamic. The standard visualization of agent-type (CMY) is dominant, although the state of excitedness of the crowd can be visualized by pressing the Render/bmp button. Hot colors represent excitedness; cool colors represent calm. The neutral excitedness color is green. With the .bmp rendering, the original cops and agitators are also shown in cyan and magenta. Memory (the agent's state of excitedness) is stored in the bmpRed array and is moved when the agent is moved. Count neighbor functions have been created for the bmpRed array.

Segregation & Assimilation - Version 19
October 6, 2009
Modified from Version 17, the world in Version 18 has been cleaned up. The statistics count both agent moves or changes in agent type and the graph displays the relative number of moves or changes (the percentage of the moves or changes of each type divided by the total moves or changes). In adition, the pen draw function can render either as a solid block or a stippled block (resembling spray). The program will automatically stop when the total number of moves or changes drops to zero.

Ideas to implement:
Make some agents move or change more slowly, i.e. if (myType == CYAN && frames % 2 == 0)

Use the bmpR, G, and B arrays for environmental data or other agent attributes. If you do the latter, be sure to move that attribute when you move the agent.

Let agents have access to global information, e.g. if(cyanPop > magentaPop &&...

Create a few Police and Activist agents to rouse or dampen the spirits of a crowd of other agents. the agents' spirit would have to be stored in another array, e.g. bmpR.

Segregation & Assimilation - High Definition - Version 18
October 6, 2009
Modified from Version 17, the world in Version 18 has been expanded from 200x200 to 492x562 to accommodate the SLUIS Digital Elevation Model (DEM). Consequently, the mapping from the array to the PaintBox is 1:1. The statistics count both agent moves or changes in agent type and the graph displays the relative number of moves or changes (the percentage of the moves or changes of each type divided by the total moves or changes). In adition, the pen draw function can render either as a solid block or a stippled block (resembling spray). The program will automatically stop when the total number of moves or changes drops to zero.

The last rule operates on the SLUIS DEM with Yellow ascending the topographic surface and Cyan descending. The tolerance for determining an ascent or descent can be varied by the TrackBar. Mobility is also a useful variable. Cyan thus simulates rainfall. There is no code for Magenta or Silver. I will leave that up to you...

sluis-data.txt

Sluis-Netherlands-Ferraris-Map.jpg

Pronunciation: "Slaus"

Segregation & Assimilation
Version 17
March 10, 2008
Rules #19 & 20 have been added to have agents move N, S, E and/or W and rule #21 has been added to have agents climb the gradients in the color channels in a bitmap image. With mobility set low, the CMY agents can be seen to wander towards the higher values in the .bmp RGB channels respectively. The bitmap can be used to provide environmental data. Two bitmap images have been included here for you to experiment with. Using the Taj-Mahal or Jennifer Connelly bitmap and rule 21 you can achieve the "magic wand" effect of the opening credits to the legacy Disney TV series.

Try Rule #21 on any 200x200 pixel bitmap. Vary the initial population and the mobility for some interesting effects. Try killing the entire population and then "painting in" colors using nib size 3 and mobility 5.

             
             
             
             
             
             
             
8-Cell Neighborhood in White
             
             
             
             
             
             
             
24-Cell Neighborhood in White
             
             
             
             
             
             
             
48-Cell Neighborhood in White
             
             
             
             
             
             
             
24-Cell Ring Neighborhood
16-Cell Ring Neighborhood

Classical Definitions:
Segregation - an agent may move, but it may not change type.
Assimilation - an agent may change type, but it may not move.

Segregation & Assimilation
Version 16
Octoberl 2008
The code now accommodates assimilation rules. Note than in addition to calling the changeMeTo() function, a modification must be made to allow the simulation to run even though no moves have been made (see notes in source code). Also, a 48-cell neighborhood has been created as well as a 24-cell ring neighborhood.

Segregation & Assimilation
Version 15 -April 2008
A changeTo() function has been added to allow agents to change type. You need to keep pressing RUN since the simulation shuts down when there are no moves, and no moves are specified.

Segregation-Version 14 -April 2008
You can draw Cyan, Magenta, Yellow and Silver agents as well as Black empty space and White barriers with pen Nibs of up to 10 pixels in size. Also, you can save and open any current demographic pattern to and from a file. The six neighborhood functions (8, 24 & 16 cell) report on all six cell types (4 agents, empty & barrier).

Note: As with version 10, you can import one bitmap to set up the
initial population and another to set up geographic characteristics.

Segregation-Version 11 -2008
Same as version 10 except that a provision has been made for four different agent types: Cyan, Magenta, Yellow and Red. The last item in the "Initial Population ComboBox sets up a random population of 20% of each type including empty cells. The statistical EditBoxes at the bottom have been corrected to show both the population at any time AND the moves per frame. Notice that the caption changes. The graph also shows the activity of Red agents. The TrackBar, drawing and BitMap functions that setup the initial population demographics have not been changed to accommodate Red.

None of the changes that we made in class are included in Version 11 (i.e. no sounds, no new rules, etc.).

Segregation-Version 10 -2007
You may now create any initial condition using PhotoShop to draw a 200 x 200 pixel bitmap image in PURE Cyan, Magenta, Yellow, Black and White. You may also draw individual pixels by picking up the agents' colors from the TShape boxes and clicking or dragging on the PaintBox. Some .bmp configurations are included below:

Boxes:

Segregation-Tweaked-2007
Explanation and Notes
The code has been cleaned up. Functions have been added to calculate a 24-cell neighborhood and a 16-cell "ring" neighborhood by subtracting the 8-cell neighborhood from the 24-cell neighborhood. Several new rules have been added to implement these new functions.

Assimilation - B
This basic application is modified from Conway's Game of Life to provide cinematic polling in contrast to the random polling for the segregation models. Functions provide the number of CYAN, MATENTA and YELLOW neighbors, as well as the number of EMPTY cells. Functions also provide the types of neighbors who are the most and the least prevalent. Ties are not dealt with in functions. Only a few rather unimaginative rules have been implemented.

Saeid Atoofi's Language Evolution
(on the assimilation of language elements)

Segregation-Tweaked-October-2006
The statistics panel, run-to-frame panel and mobility of 5 bug have been fixed. Functions have been added to calculate a 24-cell neighborhood and a "ring" neighborhood by subtracting the 8-cell neighborhood from the 24-cell neighborhood. Several new rules have been added to test these functions.

xxxxxxxxxx
Some of the patterned move rules in the version of segregation below. Patterned perceptions are based upon agents being in a specific loaction (in this instance diagonal, vertical or horizontal) relative to the perceiving agent. The coding is a kludge since it does not wrap around.
xxxxxxxxxx
Some of the totalizing move rules with different home and destination parameters in the version of segregation below. Totalizing perceptions are based upon the total number of agents of different types irrespective of exactly where they are located.

Schelling's
"Segregation with Statistics
-April-2006"
A "frame" has been accurately redefined as an average of one opportunity to move for each member of the population. The number of moves made per frame is displayed and plotted. A "happiness" statistic should also be added. More rule options have been added, some as kludges. The TrackBar event handler has been deactivated...

Schelling's
"Segregation-April-2006"
Some small bugs have been worked out since the previous version. Add two or three more complex rule sets that produce interesting results and don't forget that "historical" changes can make a difference to the final pattern, as the screenshot at the left illustrates.

Schelling's "Segregation IV"
At present, this version contains only one additional rule which you will find it relatively easy to modify to your needs. The rule allows for complex conditionals to be set and ignores the "Home & Destination" option. It is "Case 5:". The window has been enlarged to allow for longer rule names and statistics...

Schelling's "Segregation III"
February 2006
Enhanced with different relative populations, different neighborhood types, different move distances, rules applied to destination only or both home and destination, and geographically applied rules including preference, move distance and neighborhood type encoded in the Red, Green, and Blue channels of a 200x200 pixel bitmap image.

Darryl Jung's Enhanced Segregation Model
HCS Bragin Prize Winner

Schelling's Segregation Enhanced
January 2005
Try enhancing the model further by adding your own options to the selections. You might add more choices to the choice of the initial population or the distances agents may move. But the most interesting results will probably result from adding more elaborate rules or more involved geographies...

Segregation Twice - 2004
Two simulations of Schelling's segregation run in two separate Windows. A third Window called "Control" enables you to run side-by-side experiments in sync. Three Forms and three Units are required.

Segregation 2004 - Incomplete
This is as far as we got at our first class meeting. We will continue to code this example by hand at our second meeting.

An outline for coding the complete version of this simulation which will fit on one page. The details have been omitted and the code will not run.

Segregation 2004
A simplified introductory version of Schelling's segregation model. The source code is well annotated and more complex preferences may be introduced into the code.

Segregation
An example of how preferences for having neighbors like yourself can lead to segregated population distributions.

Note: Open the .bmp files and save them to a new folder. Then run the application, open either .bmp, render, transfer it to the array, and click "Enable BMP Rule."

Project Files Zipped

1 ..... 2 ..... 3 ..... 4 ..... 5 ..... 6
Segregation patterns produced by holding the number of preferred neighbors like oneself constant through 999 frames.

3 then 4 .....3 then 4 then 5
Segregation patterns produced by historically increasing the number of preferred neighbors like oneself evenly through 999 frames.

Segregation Tweaked
Some enhancements in the rules are included, which are commented out. You will have to uncomment them and comment out the previous rules to observe the effects.

Note: This was a classroom exercise in which we tried a number of different twists on the general program

Project Files Zipped

Segregation Three
In this version, the user may select different initial ratios of Red, Green and Blue individuals and empty spaces. The user may also select preference rules that apply differently to each type of individual. Several buttons have been consolidated.

Note: Open the .bmp files and save them to a folder. The "Import Bitmap" button will load the images into the application.

Project Files Zipped

..... ..... .....
Segregation patterns produced with an initial population ration of 1 Red : 2 Blue : 4 Green : 3 empty. With a preference of two neighbors like oneself, the pattern to the left emerges. Beginning with that pattern, changing the preference rules to Reds like at least 3 Reds, Blues like at least 2 Reds, and Greens like any Greens, the pattern on the right emerges.

Naoko's Segregation Model
Lots of things going on here. We'll let Naoko explain them...

Simone's "Population Distribution"
Simulates population movement in a city based on ethnic preference, educational funding and level of education.

Executable

Kevin's Segregated and Iterated Prisoner's Dilemma (IPD)
Agents play IPD with a user-selected neighborhood and then move based upon their preferences for neighbors who cooperate or defect.

Executable

Gwen's Segregation based upon Age, Sex and Status
Preferences can be selected for these three factors.

Executable

Bridget's Segregation based upon Los Angeles Census Data.
Census data from Los Angeles in 1990 and 2000 forms the basis for this simulation.

Executable

Dave's Deterrence Model after Mark Kleiman-2007

segregation