Complex Adaptive Systems

Starlogo/Netlogo Programming Assignment



1.  Program Chris Langton’s “Virtual Ants.”  You only need to program one ant.  Its behavior will still be complex as it moves around.  The description of this simulation is found in your course pack.  The rules are very simple indeed:

            1.  If the ant is on a black square, the ant turns 90 degrees to the left.

            2.  If the ant is on a white square, the ant turns 90 degrees to the right.

            3.  On each time step, the ant moves forward one square.

            4.  As the ant moves forward, the square it is on changes from white to black, or from black to white.


Show the entire program.

            Hint 1: You’ll definitely want to use the “Stamp” command.  Read the manual to see what it does.

            Hint 2: The whole program doesn’t need to be more than 4 lines long.


2.  Your second assignment will be to program a physics model called alternatively “Ising model” or “Spin-glass.”  Here’s a description of the model, using a socio-political scenario:

            People start with random political affiliations (Democrat or Republican), and the people are spatially positioned in a grid.  Each person has 8 neighbors.  If a person has more Democratic neighbors than Republican neighbors, then the person buckles under the peer pressure, and becomes Democrat.  If a person has more Republican neighbors, they become Republican.  If a person has 4 of each kind of neighbor, they stay whatever they were before.

            Design a Starlogo simulation for this set of rules.  Given this rule set, if you start with the pattern at Time 1, then it should look like the pattern shown in Time 2 after applying the rules once:


All of the Democrats are shown by white squares, and all the republicans are shown by black squares.

            Hint 1:  You don’t need to use turtles at all for this simulation; you’ll only need to worry about patches.

            Hint 2:  Here is a set up routine you can use to randomly create         political affiliations:

            to setup


            ifelse (random 100) < density

               [setparty 1] [setparty 0]

             ifelse  party = 1 [setpc yellow] [setpc blue]


            This assumes that you have a slider called “density” that goes from 0 to 100.

            Hint 3: Each patch should own two variables: party and count.  Thus, you’ll want to include the statement: patches-own [party count].  “Party” says whether the patch is Democrat (1) or Republican (0).  “Count” says how many Democrat neighbors a cell has.

            Hint 4: You’ll probably want to use the “nsum” command, and you’ll probably need at least one “if” or “ifelse” statement.  The whole program will be about 4 lines long.


            Question 1: Show your whole Starlogo program

            Question 2: Given random configurations with 50% Democrat density, what happens over time?  Describe why, as a first pass, this is a reasonable model of how Democrats and Republicans are distributed across the country.

            Question 3: Now, allow your patches to assert their individuality.  Add some random noise to your simulation - so that even if all of one’s neighbors are Democrats, one still could be Republican.  So, instead of a statement like:

ifelse (count > 4) .... like you probably had earlier, use a command like:

ifelse (count > (4 + ((random noise) / 10) - (random noise) / 10)).... What this code does is it compares a patch’s count to 4 plus a bit of noise minus a bit of noise.  You’ll also need to create a slider called “noise” with a range from 0 to about 50.   Start with a random configuration with a density of 50%.  As you increase noise (individuality), how does the distribution of democrats and republicans change?  Do the party regions become larger or smaller as noise increases?  WHY?

            Question 4: With noise set moderately high, what happens over time if the initial density of democrats is 66%?  Repeat the simulation several times.  This behavior is reasonable for some situations, but it doesn’t seem like a good behavior for simulating political parties.  WHY NOT?