Remote Ready Biology Learning Activities has 50 remote-ready activities, which work for either your classroom or remote teaching.
Serendip is an independent site partnering with faculty at multiple colleges and universities around the world. Happy exploring!
![]() | Emergence Course 2006 Forum |
Comments are posted in the order in which they are received, with earlier postings appearing first below on this page. To see the latest postings, click on "Go to last comment" below.
Evolving Neural Network Weights: Hunters & Prey Name: Kathleen M Date: 2006-04-27 13:15:40 Link to this Comment: 19161 |
I find evolutionary algorithms fascinating, so I wanted to evolve something. I decided to use Pyrobot because it provides a nice graphical interface in which results can be seen. I was interested in competition to compare not only a traditional program with something evolved, but also to compare different evolved robots. The predator / prey situation is a straightforward way in which success could be tested and in which two different evolved robots could compete.
The Plot
Since robots have color sensors, it made sense to create prey and predators of different colors to help them identify one another. I used blue for prey and green for predators because the color sensors return values for red, green, and blue and I wanted the detection to be as clear as possible rather than distributed across two or more color values (like, say, purple). I started with a simple world, chaseWorld.py, with two robots positioned to start at diagonally-opposed corners.
Basic Brains
First I wrote two basic robot brains in python code, brainAvoid.py and brainChase.py. Both robots needed to avoid getting stuck in corners and colliding with the walls. After handling walls and corners, the chase robot needed to head for the prey and the avoid robot needed to head away from the predator. At first I thought the chase robot would be harder to program, since - unlike the avoid robot - it needed to perform two types of tasks: avoid one thing (walls) but aim for another (prey). I soon discovered that the avoid robot was more challenging; once it avoided walls, it had to decide on a direction to go based on a snapshot of the world that only tells it where the predator is, but not which direction it's heading. Real quarry might decide on an escape route based on the predator's course. (Of course, some more complex programming can surmount this issue; the robot could spread out decision-making and take readings across several steps, but this slows down the response time and wasn't necessary for this brain.) After a fair amount of tweaking, I had two reasonably well-performing robots.
To run them, download the chaseWorld.py, brainAvoid.py, and brainChase.py files. Type "pyrobot &" from a terminal window. Click the Server button, select "PyrobotSimulator" and click OK, click the Home button, and then navigate to where you saved the chaseWorld.py file; the Simulator window will pop up with the chase world. Click the Robot button, select "PyrobotRobot60000.py" and click OK. Click the Brain button and click Home to navigate to where you saved the brainAvoid.py file and click OK. Back in your terminal window, type in "pyrobot &" again. This time skip the Server button but click the Robot button to select "PyrobotRobot60001.py" and click OK. Click the Brain button and click Home to navigate to where you saved the brainChase.py file and click OK. Now you have both robots connected to their chase world. You can click run on each Pyrobot interface to get the robots started. Notice that the behavior is eventually predictable. After they run awhile, click File->Reset on the Simulator window to reset their positions. Under the same conditions and allowing for some variation due to sensor noise, the robots perform exactly the same moves.
(More information on running Pyrobot)
Evolving a Neural Network Brain
There are two more files involved in evolving a neural network brain. The first is a neural network brain, brainNN.py, to control a robot. It creates a neural network with 14 input layers that correspond to the sensor values I used with the basic brains: 8 range sensors and 6 color sensors (red, green, and blue on each side). The output layer produces two values, translate and rotate values to control the robot's movement. On each step, the neural network brain grabs sensor data, feeds it into the network, propagates the network for an output, and uses the two output values to move the robot. All of the work of determining the robot's movement is done by the network.
The second file is a genetic algorithm. I created two of these, GAChaseNN.py to evolve a predator and GAAvoidNN.py to evolve prey. Each file opens a Pyrobot engine and sets up the robots – one with the neural network brain and one as an opponent. In evolving a predator, I used my brainAvoid.py as the opponent. In evolving prey, I used my brainChase.py as the opponent. Each genetic algorithm is designed to evolve a set of weights for the neural network brain to use.
In a Genetic Algorithm, solutions to a problem are encoded as a list of data (genes) and a population of them is created with random data. During each generation, they are each tested for fitness, selected to survive (based on a preference for high fitness), mated to fill out the population again, and then randomly mutated. In my GA programs, the genes are sets of network weights. The fitness function sends the weights to the neural network brain, runs the two robots for awhile, tests to see how well the neural network robot has done, and awards it a fitness value. The early generations of weights produce some very odd behavior because the algorithm begins with random numbers. By the sixteenth generation, there is some very reasonable and even effective behavior.
To run a genetic algorithm, make sure that you have all the necessary files (the Pyrobot world file chaseWorld.py, the neural network brain brainNN.py, the genetic algorithm GAChaseNN.py or GAAvoidNN.py, and the opponent brain brainAvoid.py or brainChase.py) in the same folder. At a terminal window from that folder, type
The weights for each generation are saved into files named try1.wts, try2.wts, etc. Any of these can be renamed to save it for testing and comparing later. If you do not rename a weight file, it will be overwritten the next time you run one of these GAs.
Competition
To test the results and compare brains, I created a python program runtrial.py that takes 3 arguments: the name of a chase robot neural network weight file, the name of an avoid robot neural network weight file, and the number of trials you want to run. If you do not supply a weight file name with ".wts" at the end, the runtrial program will use the simple brain counterpart (brainAvoid.py or brainChase.py) instead.
To run this program, save it to the same folder as the other programs. At a terminal window from that folder, type
Surprises
One thing I noticed is that evolved brains seemed to be less predictable than traditionally programmed brains. When they are reset into positions for trial after trial, they do not perform the same behavior as consistently.
One of the avoid brains that I evolved came up with what seemed to me to be an interesting solution. It spent most of the time traveling in tight circles. Since my simple chase brain, brainChase.py, didn't make any sharp turns, the evolved brain was able to avoid it completely with its tight circles and a periodic short reverse whenever the green got somewhat close.
In fact, my evolved avoid brains turned out better than my evolved chase brains. I supposed this had to do with the quality of the opponents used to test their fitness; perhaps my traditionally programmed chase brain was better than my traditionally programmed avoid brain. On the contrary, in a 20 trial comparison between the two traditionally programmed brains, the avoid brain won 15 times. Maybe chasing is just a harder job after all.
* Note: Although GAChaseNN.py, GAAvoidNN.py, and runtrial.py all include the line
Evolving Rulesets for the Game of Life Name: Julia Ferr Date: 2006-05-01 17:46:17 Link to this Comment: 19202 |
Emergence in Ant Colonies Name: Laura Cyck Date: 2006-05-03 13:52:54 Link to this Comment: 19208 |
ANT COLONY BEHAVIOR
The simulation here aims to show that organized behavior is capable of existing without direction from above, but instead can result in a bottom-up manner from a collection of agents interacting with one another while following very simple rules.
I. Motivations and purpose
II. The story
III. The code
IV. Conclusions and resources
The motivation for the model here comes from work done by researcher and ant expert Deborah Gordon of Stanford University (see Resources).
As described above, the model attempts to simulate emergent organization in the absence of direction or instruction. More specifically, the model attempts to simulate two interesting and perhaps unpredictable (based on individual ant behavior alone) characteristics of ant colonies: task allocation and colony stability.
1. Task Allocation
One of the first things noted by scientists studying colonies of ants was that somehow work was divided consistently among ants. In nature, ants outside the nest are commonly engaged in one of the following activities: patrolling-- which to an on-looker basically looks like aimless wandering about; midden work-- transporting debris and dead ant remains to confined piles; and lastly, foraging-- scouting the larger surrounding nest area for food and other resources.
It wouldn't be crazy to think that maybe ants are born with a destiny (or fate, depending on how you look at things) to perform the same task day-in and day-out. In this way, task allocation would be decided by genetics. An ant colony has a set number of foragers, for example, and if we were to remove them all the colony might die because it would have no ants to find food.
However, a closer look shows that ants aren't fated to perform the same task. They may switch from day-to-day, hour to hour, or even minute to minute.
How do they decide what to do? And how do they decide when to switch?
Maybe someone tells them to-- like the queen. But the queen usually stays hidden beneath ground deep within chambers, and sometimes ants stay outside of the nest for the entire day. So, unless ants are telepathic, the answer would have to lie somewhere outside the nest. Perhaps in the patrollers, who seem to wander around without purpose anyway?
Scientists have asked all these questions and attempted to answer them by removing the queen ant or by removing individual ants. And when this didn't lead to answers, even by removing entire groups. When this is done, however, the remaining ants continue on with work, albeit after a little adjustment to fill the void left from those removed.
If there's no one then telling an ant that there's not enough or too many other ants doing a certain task, perhaps she (all ants of a colony are female) decides for herself by keeping track of how many ants are performing her task.
This might be possible, since scientists noted that when ants encounter each other, their antennae touch the body of one another. So, it seems like ants might be able to communicate information to each other.
Again though, this idea has been rejected. First, ants aren't considered capable of having such great memories. Second, some colonies can reach over 1,000 ants. Given this, determining one-by-one what every other ant is doing would not be very efficient.
Not all hope of finding a reasonable explanation is lost though. The next important observation by scientists was that the body of an ant (specifically where antennae are likely to hit) has on its surface a unique kind of chemical (called "cuticular hydrocarbons", a waxy substance) which they found to differ from task to task.
Still unsure of why ants would switch tasks, they synthesized their own hydrocarbons and dropped them into a nest in the form of beads to see what would happen.
If an ant really went around asking other ants what they are doing, and monitoring how many ants are doing this task or that, then she would probably ignore these droplets since they don't look much like ants. At the very least, if she mistook them as other ants (many species are blind), in order to mimic an entire force of ants doing one task it would take quite awhile for her to get around to contacting each droplet (remember, some colonies can have over a thousand workers outside of the nest alone).
Dropping a bead or two into the nest had little effect. What researchers discovered, though, was that when more were added, and ants contacted a relatively larger number of them in a shorter span of time, they suddenly changed tasks.
Might task switching be based on something as simple as frequency of contact with other ants? If so, would this be enough to lead to organized behavior?
Click on "Setup patches/clear all" to setup the environment (or to start over after you've run a simulation).
This divides the world into three areas: on the right, a larger green area for foragers, on the top left a gray area for patrollers, and on the bottom right a brown area for midden workers.
The three setup buttons below add ants to their respective locations. You can vary how many ants are added ("NumberOfAnts") with each click, but try starting out with a smaller number to see how the model is set up. The total number of ants, "Total ants", at any given time is represented under the plot.
The ants show up as different colors to set them apart from the background and to make it easier to visualize how they are dispersed. Foragers will always turn red, patrollers blue, and midden workers purple.
Clicking "Step" will run the program through one cycle and clicking "Go" will run the simulation continually until it is un-clicked.
You'll see that the ants move around the screen in different directions and generally stay confined to their designated task area.
In the model here the ants do not have specific "tasks", but you can imagine their movement within one general area as representational of their engagement in a task (patrollers wander around surveying the area just outside the nest entrance, midden workers collect debris from all over the place, and foragers explore). What they actually do is unimportant for purposes here. The most important thing is the spatial variable which affords ants the potential for interaction. On that note, the world also wraps, so sometimes an ant may disappear from one edge of the screen and reappear on the other. Select "Watch an ant" to follow a randomly-chosen ant; if you want to follow a different ant or return to the original view just hit the adjacent "Reset view" button.
If you let the program run for awhile you'll notice that within one task some ants come while others go (they momentarily set their colors to yellow and pink so they're easier to spot). The "Task Allocation" plot and the three neighboring monitors display and track the percentages of ants broken down by task (green = foragers, brown = midden workers, gray = patrollers).
Now back to our question: Is changing tasks based only on the frequency of encounters with other ants enough to organize everyone?
Find out for yourself: Test out different initial configurations of the world but try keeping the total population constant to begin with and watch what happens.
You might try setting up the world with 100 ants all starting as foragers. What happens? At first they all just stay engaged in the same task, but if you wait a bit, a few ants will switch to patrolling or midden work. (If you want to keep track of time, the "Clock" monitor keeps a record of how many iterations the program has run; additionally, holding the mouse over the plot will show the step number for any point on the x-axis; the y-axis will show distribution percentages.) Eventually, more ants will leave foraging, and sometimes the percentage of foragers will drop pretty low before it returns to a steady state. The distribution seems to always come out at around 50%/25%/25% for foraging, patrolling, and midden work, respectively (with normal fluctuations of give or take 5%).
Now try starting out with a different initial configuration, but keep the total population the same as before.
What happens?
No matter how we set the world at the start-- all ants doing the same thing, only two tasks with ants, or perhaps 90% patrollers and 10% midden workers, and so on-- eventually, given enough time, we wind up with the same distribution.
Did someone plan this? Did one individual cause this? Is there an elite handful of ants running around keeping tabs on everyone else?
You can test some of the same ideas and run similar experiments as the scientists described above did.
Unfortunately, there's no queen represented here but you can add a version of "hydrocarbons" and add or remove ants while the simulation is running.
Hydrocarbons: Clicking "Add hydrocarbons" will add 3 beads, which are always added to the midden work area. "Remove hydrocarbons" deletes them. See if you can determine how many are required to have a noticeable effect on task allocation by adding them in gradually.
Adding ants: You can similarly add ants to respective tasks during simulation by clicking "Add foragers", "Add midden workers", or "Add patrollers". Clicking once will add the number designated by the "NumberOfAnts" slider used in setting up ants.
Removing ants: Lastly, you can remove ants during the simulation by clicking "Remove foragers", "Remove midden workers", or "Remove patrollers". The number removed is determined by the corresponding slider which is based on a percentage.
If you've tried to find a directing ant and given up, you'll probably not be surprised to know at this point that there isn't one. The ants aren't programmed to do anything but switch tasks based on encounter frequency (see The Code section). The equilibrium emerges as a collective property of the individual ants interacting with one another.
Don't believe it? There's more to play around with. Next to the percentage monitors are sliders labeled "ForagersEncounterThreshold" and so on. You can change overall thresholds to be higher or lower for all ants, or you can adjust each task differently. This adjustment makes changes to each ant's individual set of rules.
Try changing around the encounter thresholds, and again start with different configurations to see if the same pattern emerges.
When you're convinced that what's happening is emergent, below is a sketch of the algorithm each ant is programmed with. It's very basic and pretty simple and has only two variables: an "encounter" and a "time elapsed" variable. Furthermore, ants don't know anything about other ants, the only information she has access to is her own*:
Go forward one space
Add + 1 to "time elapsed"
Check to see if there's another ant on the current space
If there is, add + 1 to "encounters"
If "time elapsed" > x, reset "time elapsed" AND "encounters" to 0
If "encounters" > x, go to a new task
If not, Turn in a random direction
Loop
("x" is the variable defined by the EncounterThreshold sliders)
Notice that resetting the ant's "time elapsed" variable and subsequently "encounters" prevents an ant from keeping a tally of each and every ant. Therefore, switching tasks can happen only if the ant meets a certain number (threshold) of ants before its "time elapsed" variable resets itself and cannot happen by determining the total number of ants doing a task.
*With one exception being a Boolean "Alert" variable. However, this variable is not one used for the behavior described above; see below.
2. Stability
A second interesting property that scientists noticed about ant colonies was their stability. They noted that when they disturbed colonies-- be it by adding hydrocarbons, adding ants, removing ants, or after an intrusion from a neighboring colony-- older colonies tended to re-establish equilibrium faster than younger ones.
Maybe this is because older colonies are more mature, wiser, more experienced, or used to disturbances, while younger colonies are somewhat ignorant. Ants of older colonies have learned how to quickly get back on track after an interruption.
Scientists making these observations were comparing colonies as young as 1-2 years old with colonies up to 10 years old. So, after ten years one would think a colony might have learned a thing or two in its lifetime.
The problem? The lifespan of an ant is only about one year. Maybe a really healthy ant might live a year and a half or so, but certainly never as many as ten.
What could be causing younger colonies and older colonies to behave differently then?
Explore the model and see if you can find any parameters that could have a bearing on stability. You can monitor stability in the following way:
When you add ants using the "Add foragers" etc. buttons, the "Capture % foragers" reports the percentage of ants engaged in foraging before the addition of new ants. When the colony has reached equilibrium again the "Time to restabilize" will show how many iterations re-stabilization took (it can be reset with the adjacent "Reset"). (As a side note, you'll want to wait until ants reach an equilibrium before introducing new ones for this number to be most meaningful.)
What could account for older colonies being more stable if their ants are the same age as those in younger colonies? Task allocation emerges without an organizer, but perhaps there's a directing ant that facilitates a return to normal behavior after a disruption.
Or, could this behavior too be emergent?
Not surprisingly (or surprisingly?): Yes, it can be. The only difference between the younger and older colonies researchers noted was a difference in population. As colonies age, they steadily grow larger.
If you haven't already, try running two simulations of differing sizes and see how quickly the group as a whole returns to equilibrium after a disturbance.
If you want a summary of what happens, below is a graph comparing the results of multiple runs.
For all these trials, foragers were added for a 50% increase in the starting total population after exactly 500 cycles of the simulation was run (to allow the group to reach equilibrium). Also, the encounter threshold for each task was held at 50.
Finally, here are some additional tools and suggestions to play around with.
Intrusions: You can add enemy or "intruder" ants from hypothetical neighbor colonies by clicking "Add intruders" buttons and adjust their numbers using "IntrudersToAdd". Intruders will show up as black and will always be added to the foraging area. They are programmed to stay in this area, so they will never invade the entire colony. They will also almost always leave (unless the colony for some reason abandons a specific task...) because when they meet a certain number of members from the colony they leave (die). Though, they operate on the same basic principle of frequency as the colony ants do. So, they don't know the total size of the colony they're invading...
"IntruderPersistence" dictates how many ant encounters within a certain time period it takes for them to leave; "AntAlertness" is a variable for the colony ants. When an ant meets an intruder, it becomes "alert" and passes this information on to other ants. But, it only remains on alert for a certain period of time unless it runs into an other intruder.
Remember, all the variables control the algorithm of each individual ant. By changing "AntAlertness", for example, you're not telling the colony as a whole to do anything specific. You're only telling each ant to adjust her and only her behavior alone.
What happens with larger and smaller intrusions? What happens to task allocation in the colony when intruders appear? What happens after they're gone?
In some colonies, ants stay longer in the foraging area after an intrusion... are these colonies more "vigilant" than others? "smarter"? Are the individual ants smarter? Is the colony smarter? In both smaller and larger setups, all ants follow the same, simple set of rules...
There are many variables in the model to play around with. See if you can find any other interesting behavior that might emerge...
To prove that there's no director responsible for any organized behavior that you see, below is the code for the program. The first is a basic description of what's going on for those unfamiliar with the NetLogo programming language. The second is the raw code for programmers or others wanting hard evidence.
1. Each ant holds 5 variables, and can access the value of her and only her variables (with the Boolean Alert being an exception as noted earlier): Encounters, Time Elapsed*, Task, Alert, and Alert Clock.
Each time the program iterates once, the following commands are executed (x's represent the user-adjustable values) by each ant:
Determine task: Look at the color square you're on. If you're on a green square you're a forager, brown you're a midden workers, gray you're a patrollers.
Interact: Add +1 to Time Elapsed. If there are any other ants on your square add +1 to Encounters. If your Time Elapsed has reached 50, set it to 0 and also set Encounters to 0.
Work: Turn in a random direction. If the square ahead corresponds to your task, move forward one. If not, turn 180 degrees to the right and move forward one.
Check task: If the value of Encounters is > or = than x, run the commands for Change-task.
Change-task: Move forward one. If the color of the current square is different than before, set Distance Traveled to 0 and set Encounters to 0. Move forward a random number of spaces, but no greater than 15. If the color of the current square is not different than before turn in a random direction and run the commands for Find-new-task.
Find-new-task: Jump forward a random number of places, but no more than 5. If the color of the current square is different than before, set Task to the corresponding task, set Distance Traveled to 0, and set Encounters to 0. If the color of the current square is not different than before, re-run the commands from Change-task.
Check for intruders: If there is an ant of color black on your square, set Alert to 1.
Check alert status: If Alert = 1, set Encounters to 0.
Check alert status: If Alert = 1, add +1 to Alert Clock .
Check alert status: If Alert = 1 and Alert Clock = x, set Alert Clock back to 0, and set Alert to 0.
Check alert status: If there is another ant on your square, and her Alert = 1, set your Encounters back to 0.
Loop.
The intruders hold 2 variables of their own: Time Elapsed and Collisions.
Check variables: If Time Elapsed = 150, reset it to 0 and set Collisions to 0.
Move: If the square ahead is the same color, move forward one. If the square ahead is not the same color, turn 180 degrees to the right and move forward one. Turn in a random direction.
Check for colony ants: If there is another ant on the same square, add +1 to Collisions.
Check variable: If Collisions > x, die.
*In the NetLogo code below this variable is termed "patchestraveled", which may look misleading. The ants are not remembering encounters for certain distances traveled, but over a certain amount of time as described above. Since an ant moves at least one square every iteration, time is coded through this parameter.
2. The NetLogo code:
<--- begin --->
to setup
to setupforagers
to setupmiddenworkers
to setuppatrollers
to-report totalturtles
to setup-plotting
to go
to move-turtles
to setuptask
to interact
to work
to change-task
to find-new-task
to-report foragers
to-report middenworkers
to-report patrollers
to do-plot
to addhydrocarbons
to removehydrocarbons
to removeforagers
to removemiddenworkers
to removepatrollers
to followanant
to resetperspective
to-report clock
to addforagers
to addmiddenworkers
to addpatrollers
to-report currentdistribution
to runclock
to-report timetorestabilize
to resettimetorestabilize
to addintruder
to intrudercommands
to-report intrusionduration
to resetintrusionclock
globals [ time distribution stability intrusionclock ]
breeds [ ants hydrocarbons intruders ]
ants-own [ encounters patchestraveled task alert alertcounter ]
intruders-own [ collisions patchestraveled_intruders ]
patches-own [ location ]
ca
ask patches [ if (pxcor > 0) [set pcolor green] if (pxcor < 1) and
(pycor < 1) [set pcolor brown] if (pxcor < 1) and (pycor > 0) [set
pcolor gray]]
ask patches [ if (pcolor = green) [set location 1] if (pcolor = brown)
[set location 2] if (pcolor = gray) [set location 3]]
set-default-shape ants "bug"
setup-plotting
end
ask random-n-of NumberOfAnts patches with [location = 1] [sprout 1 [set breed ants set task 1 set color red - 1]]
ask ants [ set heading (random 360) ]
ask ants [ set encounters 0 ]
ask ants [ set patchestraveled 0 ]
end
ask random-n-of NumberOfAnts patches with [location = 2] [sprout 1 [set breed ants set task 2 set color magenta - 1]]
ask ants [ set heading (random 360) ]
ask ants [ set encounters 0 ]
ask ants [ set patchestraveled 0 ]
end
ask random-n-of NumberOfAnts patches with [location = 3] [sprout 1 [set breed ants set task 3 set color blue - 1]]
ask ants [ set heading (random 360) ]
ask ants [ set encounters 0 ]
ask ants [ set patchestraveled 0 ]
end
report (count ants)
end
set-current-plot "Task Allocation"
end
move-turtles
runclock
intrudercommands
end
setuptask
do-plot
interact
work
ask ants [if (task = 1) and (encounters > ForagersEncounterThreshold ) [change-task]
if (task = 2) and (encounters > PatrollersEncounterThreshold ) [change-task]
if (task = 3) and (encounters > MiddenworkersEncounterThreshold ) [change-task]
]
ask ants [if any? intruders-here [set color cyan set alert 1]]
ask ants [if alert = 1 [set encounters 0]]
ask ants [if alert = 1 [set alertcounter (alertcounter + 1)]]
ask ants [if alertcounter = AntAlertness [set alertcounter 0 set alert 0]]
ask ants [if any? other-ants-here with [alert = 1] [set encounters 0]]
end
ask ants [if (pcolor = green) [set task 1 set color red - 1] if (pcolor = brown) [set task 2 set color magenta - 1] if (pcolor = gray) [set task 3 set color blue - 1]]
end
ask ants [ set patchestraveled (patchestraveled + 1) ]
ask ants [ if any? other-ants-here [set encounters (encounters + 1)]]
ask ants [ if any? other-hydrocarbons-here [set encounters (encounters + 1)]]
ask ants [ if (patchestraveled = 150 ) [set patchestraveled 0 ]]
ask ants [ if (patchestraveled = 0 ) [set encounters 0]]
end
ask ants [set heading (random 360)]
ask ants [
if (task = 1) [ifelse (location-of patch-ahead 1 = 1) [fd 1] [set heading heading rt 180 fd 1]]
if (task = 2 ) [ifelse (location-of patch-ahead 1 = 2) [fd 1] [set heading heading rt 180 fd 1]]
if (task = 3) [ifelse (location-of patch-ahead 1 = 3) [fd 1] [set heading heading rt 180 fd 1]]]
end
set encounters 0
fd 1
ifelse (location-of patch-here != task) [set color yellow set encounters 0 set patchestraveled 0 fd random 7] [set color pink set heading (random 360) find-new-task]
end
jump (random 5)
ifelse (location-of patch-here != task) [stop set patchestraveled 0 set encounters 0]
[change-task]
end
ifelse any? ants with [task = 1]
[report (count ants with [task = 1] / count ants) * 100]
[report 0]
end
ifelse any? ants with [task = 2]
[report (count ants with [task = 2] / count ants) * 100]
[report 0]
end
ifelse any? ants with [task = 3]
[report (count ants with [task = 3]/ count ants) * 100]
[report 0]
end
carefully [set-current-plot-pen "foragers"
plot (count ants with [task = 1] / count ants) * 100
set-current-plot-pen "middenworkers"
plot (count ants with [task = 2] / count ants) * 100
set-current-plot-pen "patrollers"
plot (count ants with [task = 3] / count ants) * 100] [print error-message]
end
ask random-n-of 3 patches with [location = 2] [sprout 1 [set breed hydrocarbons set shape "drop" set color white]]
end
ask hydrocarbons [die]
end
ask random-n-of (PercentForagersToRemove * count ants with [task = 1]) ants with [task = 1] [die]
end
ask random-n-of (PercentWorkersToRemove * count ants with [task = 2]) ants with [task = 2] [die]
end
ask random-n-of (PercentPatrollersToRemove * count ants with [task = 3]) ants with [task = 3] [die]
end
watch random-one-of ants
end
reset-perspective
end
report time
end
set distribution (count ants with [task = 1] / count ants) * 100
ask random-n-of NumberOfAnts patches with [location = 1] [sprout 1 [set breed ants set task 1 set color red - 1]]
ask ants [ set heading (random 360) ]
ask ants [ set encounters 0 ]
ask ants [ set patchestraveled 0 ]
set time 0
end
set distribution (count ants with [task = 1] / count ants) * 100
ask random-n-of NumberOfAnts patches with [location = 2] [sprout 1 [set breed ants set task 2 set color magenta - 1]]
ask ants [ set heading (random 360) ]
ask ants [ set encounters 0 ]
ask ants [ set patchestraveled 0 ]
set time 0
end
set distribution (count ants with [task = 1] / count ants) * 100
ask random-n-of NumberOfAnts patches with [location = 3] [sprout 1 [set breed ants set task 3 set color blue - 1]]
ask ants [ set heading (random 360) ]
ask ants [ set encounters 0 ]
ask ants [ set patchestraveled 0 ]
set time 0
end
report distribution
end
if (stability = 0) [if
(distribution < (count ants with [task = 1] / count ants) * 100 + 1) and
(distribution > (count ants with [task = 1] / count ants) * 100 - 1)
[set stability clock]]
set time (time + 1)
end
report stability
end
set stability 0
end
ask random-one-of patches with [location = 1] [sprout IntrudersToAdd [set breed intruders set color black set shape "bug" set collisions 0 set patchestraveled_intruders 0 ]]
end
if (any? intruders)
[
ask intruders [if patchestraveled_intruders = 150 [set patchestraveled_intruders 0 set collisions 0]]
ask intruders [ifelse (location-of patch-ahead 1 = 1) [fd 1 set heading (random 360) set patchestraveled_intruders (patchestraveled_intruders + 1)] [set heading heading rt 180 fd 1]]
ask intruders [if any? ants-here [set collisions (collisions + 1)]]
ask intruders [if (collisions > IntruderPersistence) [die]]
]
end
if (any? intruders) [set intrusionclock (intrusionclock + 1)]
report intrusionclock
end
set intrusionclock 0
end
You might be asking yourself "what's the big deal?" These are just ants, why should their behavior be relevant or applicable to anything else? That's just the thing, though. They are just ants. Not very intelligent or complex on their own, but combined...
Can you think of other instances of seemingly complex or intelligent behavior that involve a collection of agents or units interacting with each other? Can you think of behavior that appears to an outside observer as so complex/intelligent that one assumes it needs an organizer, a director, a conductor?
How about: Termite mounds? Bird flocking? Schools of fish? Slime mold? Urban development? Embryonic development? The brain? Humans?...
...Life in general? That you'll have to decide for yourself. But hopefully this model has shown that such behavior/organization is possible without a central force holding it all together, without anyone or anything telling it what to be...
Suggested resources:
The Gordon Lab-- website of Deborah Gordon, Professor of Biology/Behavioral Ecologist at Stanford University; includes descriptions of her research and list of publications.
Ants At Work: How An Insect Society Is Organized, by Deborah Gordon (1999)
Emergence: The Connected Lives of Ants, Brains, Cities, and Software, by Steven Johnson (2001) -- many examples of emergence (including ant colonies) from a wide range of disciplines
Using a Neural Network to Crack Various Encryption Name: Sunny Sing Date: 2006-05-03 13:53:43 Link to this Comment: 19209 |
***************** ** 1.0: PRIMER ** *****************
The goal of my project was to use a neural network in an attempt to 'crack' different encryption algorithms. In order to implement this idea, I needed to devise a way to numerically represent letters. Since there are 26 letters in the alphabet, I assigned each letter a five bit number. Additionally, I decided to restrict my dataset to 10 letter words, in an attempt to make my life a little bit easier. As a result, I designed the network such that there are 50 input/output nodes and 25 hidden nodes.
1.2: Algorithms
The two enciphering algorithms I used were the Caesar Cipher and the Vigenere Cipher. The Caesar Cipher is one of the oldest, and weakest, encryption algorithms; it was developed by Julius Caesar as a means to communicate with his military personnel. This cipher is a simple substitution/shift cipher in that each letter in the plaintext message is replaced by the nth subsequent letter in the alphabet. For example, if the shift value was 1, A would go to B, B to C, etc. Similarly, a shift of 26 would cause the ciphertext to be the same as the plaintext. In general, the enciphered value for a letter would be given by En(x) = (x + n) mod 26, where x is the value of the letter in question (A=0...Z=25) and n is the value of the shift. Thus, decryption is given by Dn(x) = (x - n) mod 26. What this basically amounts to is that the Caesar Cipher is relatively easy to crack. A code-cracker would merely need to cycle through, at most, 26 possible shifts in order to find the 'right' message (generally, the one that looks coherent). In the addition to the 10 letter restriction, I decided to encode my dataset with a shift of 15. I could have presumably studied various shifts, but I 'randomly' chose 15 for this study (I guess it wouldn't be random if I have unconscious predisposition to the number 15.)
The Vigenere Cipher is a polyalphabetic cipher that actually makes use of the Caesar cipher. Instead of using a fixed number to equally shift each letter in the plaintext, a keyword is used to encrypt the message. The keyword must be of equal length as the plaintext itself, or it must be repeated until it is of equal length. The Vigenere cipher can be represented graphically by a table with 26 rows: each row contains the alphabet, but is cyclically shifted over one. In the end, the table represents the 26 different Caesar ciphers. To encode a message using this cipher, each letter in the plaintext is 'matched' up with the corresponding letter in the key (remember, the plaintext and key have the same length!) So, if the first letter in the plaintext is N and the first letter in the key is E, one would look at row N and column E to obtain the enciphered letter--which happens to be R. Mathematically, if A=0...Z=25, the ciphertext is given by: Ci = (Pi + Ki) mod 26; similarly, the decrypted message is given by Pi = (Ci - Ki + 26) mod 26.
1.3: Issues
I originally tested the network by hard-coding 7 input/output pairs into the program. After consulting Doug Blank, I realized I needed to train the network on a much more massive dataset. With the 10 letter restriction in mind, I could only come up with a handful of 10 letter words. Feeling lost, I did a Google search and found a list of 20,301 10 letter words. I spent a fair amount of time writing a script to parse the massive list into the appropriate format, but it was doable and I now have a significantly larger dataset. This subsequently leads to a much slower network. Despite the network being rather sluggish, it managed to recognize all 20,301 enciphered patterns for both encryptions in just under roughly 2000 epochs. The learning rate and tolerance were both set to .01, which I thought would be sufficient. When presented with new inputs, however, the network merely spits out an incorrect answer--an answer that is nowhere near the plaintext message. I cannot pinpoint the reason why it is doing this. When
I propagate the network with new inputs, the program returns a list of 50 numbers, each between 0 and 1. I wrote a function to take the list and round each element either up or down--.99999 clearly rounds to 1 and .000000000034 should surely be 0. There may be a problem with the discrepancy when it comes to rounding either up or down. I was not sure if, for example, .33 should go to 0 or 1 (traditionally, it would go to 0). I set my threshold to .45--below .45 would be 0 and above would be 1. This could potentially be problematic with values that could go either way; however, I wouldn't attribute the overall failure of the network to this. Even when I look at the list of 50 numbers before the rounding and convert them with the various discrepancies in mind, I still do not get the correct output. Another postulation was that the tolerance and learning rate needed to be lower. I decreased both to about .00001 and I've been running the network for a few days. As of this writing, both networks are at 3750 epochs and both have 0.0000 correct.
1.4: Concerns
I am unsure as to how 'interesting' this project is. How applicable is this? First, if I needed to crack secret codes, chances are the messages would not have a fixed length. Although my 10 letter restriction makes my life easier, it significantly takes away from the applicability of the network. Furthermore, if I was hired to crack a certain code, why would I program a neural network WITH complete knowledge of the exact cryptosystem in mind?
1.5: Further Investigations
Instead of using the network to crack the actual code, I think a more realistic implementation would be to use a neural network to learn whether a string of letters is coherent English or not. Earlier this year a Haverford student presented a project in which he used brute force to crack a message encoded by the RSA algorithm. He used a mathematical model called Markov chains, which used various probabilities and weights to determine which of the potentially decoded messages made sense. Though I don't fully understand the workings of Markov chains, I believe they are somewhat similar to neural networks. Though such a project would be centered heavily on upper level mathematics, I think it would be worthwhile to use a network to strictly learn coherent English.
1.6: Updates
I originally tested my network with 1000 nodes--which was a bit excessive. I shrank the hidden layer down to 25 to see if that would allow the network to generalize. Although the network can learn both encryption schemes in under a few thousand epochs, it can only do so with a relatively high learning rate and tolerance. When presented with new data, it still cannot make the generalization. If I decrease the tolerance to 10^-4, the neural net ceases after 5000 epochs without any progress.
***************** ** 2.0: HOW-TO ** *****************
Consult readme.txt for a tutorial.
CaesarNN.py is the neural network for the Caesar Cipher.
VigNN.py is the neural network for the Vigenere Cipher.
Ciphers.py is the program used for creating new test data for the Vigenere and Caesar neural networks.
********************* ** 3.0: Resources ** *********************
Dataset: www.esclub.gr/games/wordox/10.html
Encryption methods: http://en.wikipedia.org/wiki/Caesar_cipher http://www.trincoll.edu/depts/cpsc/cryptography/caesar.html http://en.wikipedia.org/wiki/Vigen%C3%A8re_Cipher http://www.trincoll.edu/depts/cpsc/cryptography/vigenere.html
The way a trend spreads Name: Stephanie Date: 2006-05-05 11:47:17 Link to this Comment: 19239 |
Synchronizing Fireflies Name: Leslie McT Date: 2006-05-05 13:34:32 Link to this Comment: 19243 |
The Dynamics of Propagating Memes Through Social N Name: Ben Koski Date: 2006-05-06 16:46:03 Link to this Comment: 19272 |
A Final Project for the Bryn Mawr College Emergence Course, Spring 2006
By Ben Koski, Haverford College '06
We are all familiar, at least indirectly, with the evolution of cultural trends. We know that songs become popular and then fade away, technologies come and go, clothes come into and then go out of style. What sorts of dynamics affect the dissemination of these trends? Using the concept of a "meme," can we model how these trends move through groups of people?
As a user of the Internet, you may be familiar with the concept of an "Internet Meme," usually observed as short-lived, faddish e-mail forwards of the likes of the Nike Sweatshop meme or the Goodtimes Virus meme. The concept of a meme, however, extends well beyond the Internet to cover all sorts of knowledge transmission or dissemination. Formally defined, a meme is "any unit of cultural information, such as a cultural practice, idea or concept, which one mind transmits (verbally or by demonstration) to another mind." Memes can be small and trivial (for instance, a song, catchphrase, or fashion could qualify as such "low-brow" memes), or broad and significant (examples of these sorts of memes might be an economic system or a technology--say, cars).
Regardless of scope, memes are defined both by their cultural payload and, perhaps most interestingly, their evolutive properties. The concept of a meme was introduced in 1976 by Richard Dawkins, as the sort of sociocultural counterpart to the gene. Dawkins argued that one could view "cultural entities (people, churches, schools) as replicators of ideas." When a cultural entity transmits a meme to another entity, it is meaning is slightly changed: "memes do not always get copied perfectly and might indeed become refined, combined, or otherwise modified with other ideas--resulting in new memes." This interaction between old and new memes leads to what is known as "memetic evolution": if the new version of a meme is better at replicating or transmitting itself than an older meme, this new version will spread farther and wider. As the new meme spreads through the network of cultural entities and interacts with older versions of the meme--as well as other memes--the cultural payload is shifted and evolved.
What affects this ability of memes to diffuse? The literature outlines six broad factors that may affect a meme's ability to replicate and diffuse through a network:
The goal of this model is simulate the process of meme diffusion by modeling these factors affecting a meme's ability to diffuse through a social network. Such a model should allow us to gain an understanding of the relative importance of each of these factors in determining a meme's evolutive fitness.
Inspiration for this project--as well as quotes for this background section--were
derived from the "memes" Wikipedia
article.
Basic Tools
Since building and analyzing networks was well beyond the capabilities of
NetLogo, I chose to implement this model in Python using NetworkX--an advanced network
analysis and visualization tool.
Model Implementation
The model begins by constructing a virtual "social network" of a specified size and average connectedness. This network can either be built as a random network, or a scale-free network. The random network construction algorithm creates the specified number of nodes, and then continues to add random connections between nodes until the desired average connectedness is reached. The scale-free network construction routine is based on a built-in NetworkX library function, whose construction algorithm is described in a paper by the authors found here. Though the scale-free network more faithfully models known patterns in human social networks, random networks also have utility in testing the factors affecting diffusion of memes through social networks. After network generation is complete, the network is checked to ensure that it is fully connected. If it is not, connections are added between the disconnected subgraphs until the network is fully connected.
Once the social network has been built, a variety of characteristics are assigned to each node:
Several constants are defined for meme itself:
The sum of all additive weights (that is, the weights for distinctiveness, fear, happiness, economic class, and experience) must be greater than zero, but less than or equal to 100. This sum represents the likelihood that a node will adopt the meme if all values apply (e.g. if the meme correlates with the node's experience, is propagated by a node of the highest economic class, appeal's to the node's sense of fear, and makes the node happy). Thus, if the sum of all weights is 100, a node will always adopt the meme if all values apply. If the sum of all weights is 0, a node will never adopt the meme.
After setup of the network and the meme is complete, a number of nodes are
randomly seeded with the meme. These seeds attempt to propagate the meme to
each of their neighbors in a randomized order. The sum of weights is calculated
for each node, based on its properties (e.g. using the node's experience, fear,
happiness, etc. values). A random integer is chosen between 0 and 100; if the
random integer is less than or equal to the sum of weights, the node accepts
the meme. If the node does not accept the meme, the attempt is recorded. Once
a node has exceeded the maximum number of attempts
(by default,
15), neighbors
no longer attempt to propagate the node. Once all seeds have attempted to propagate
the meme to their neighbors, another iteration begins. During this iteration,
every node that has adopted the meme makes an attempt to propagate the meme
to its neighbors.
Iterations
continue until all nodes have seen the meme, all nodes that have not seen the
meme have exceeded their maximum number of attempts, or until the maximum number
of iterations (125 by default) is reached. At this point, the model run
is complete.
Pattern of Connection is Significant
The first version of the model relied on my random graph generator to create the nodes and connections of the hypothetical "social network." Upon the suggestion of Prof. Blank, however, I added the capability of generating scale-free social networks to my model (upon further research, it turns out that random scale-free graph generation is built in to the Network X library), with the idea that scale-free networks are much more similar in their topology to a real social network. Human networks are, in actuality, not randomly connected networks (as illustrated in (a) below). Rather, people tend to cluster into tightly connected groups surrounding a central "hub" that connects out to other network members (illustrated in (b) below).
I was curious: did the network topology significantly affect the time necessary to propagate a meme through a network? How did network types affect the completeness of a meme propagation? To investigate, I created a program to record the number of iterations necessary to completely propagate a meme for a progressively larger average connectedness values. The size of the network was set at a firm 1,000 nodes, and the total of the weights was set to 0.5 (including a 0.2 base weight). All other settings were left at their default. If a particular network topology was much better at diffusing memes, we should see a lower number of iterations required at every degree of average connectedness. The results of this investigation are surprising:
Though the scale-free network diffused the meme at a significantly faster rate at low average levels of connection, the number of iterations necessary to complete a diffusion converges with the rate of the random network near an average connectedness of 15. Presumably, scale-free networks are better at diffusing memes with low connection rates since the network's clustering allows the "hub" nodes to rapidly diffuse the meme to a large number of neighbors. However, I did not expect the performance of a randomly generated network to match that of a scale-free network, even at high levels of connection. One possible explanation for this observation is that, at a high level of average connectedness, random networks develop properties similar to a scale-free network where some nodes have large numbers of connections and can serve as "hubs" for diffusion. Or, perhaps the performance of a scale-free network degrades as connectedness is increased and the special properties of the scale-free network become less pronounced. Likely, the answer lies somewhere in the intersection of these to explanations.
In this experiment, I also investigated the total number of nodes that had seen the meme at the completion of the model run:
Since the model completes its run when either:
a run may complete without all nodes having seen the meme. Interestingly, though scale-free networks diffuse at a faster rate, they do not diffuse as completely. The most plausible explanation for this phenomenon is that if critical nodes in a scale-free network (e.g. those that protect access to additional "hubs") max out their attempted propagations, the meme will likely not diffuse to that hub--and all of its densely clustered neighbors. This makes sense, because the incomplete diffusion in a scale-free network is most pronounced at low levels of average connectedness, where there would be high numbers of these "critical nodes." Beyond an average degree of two or three, the performance of the scale-free network is roughly equal to that of the random network.
This is also a surprising property: though scale-free networks are efficient
in diffusion, they are not always the most complete. More importantly, however,
this investigation suggests that the ability of a meme to diffuse through a
social network is highly dependent on the network's structure--a factor not
clearly identified in available literature.
Cycles in Results of Meme Seeding Experiment
Based on my previous observations, it seemed that the placement--and number--of initial meme seeds would be important in determining the speed of a meme's diffusion. It seemed to me that significantly increasing the number of memes seeded into the network before iteration began would logically lead to a significant decrease in the amount of diffusion time required--particularly in scale free networks, where a large number of initial seeds could avoid the problems of blockages by "critical" nodes. So, I wrote another test program to record the number of iterations required for diffusion in models with progressively more random seeds. The run was conducted with a scale-free network, 1,000 nodes, average connectedness of 2, and all other values at their defaults. The results here, too, are quite surprising:
Instead of a directly inverse relationship as I would have expected, we see cycles emerging! Some of the cycles in independent trials are in phase; others are noticeably out of phase. Though I do not have any proposed explanations--even after pondering over these observations for some time--they are very surprising! My only thought is that the cycles are likely produced by some sort of emergent pattern (rather than an artifact of randomness), which is supported by the fact that some of the trials are in phase--even though they were conducted using entirely different random seeds
Python source for the model is available here.
What do I need to install?
To make the project work, you'll need the following:
How do I run the program?
Once you have all of the dependencies installed and working, simply navigate to the folder and type python memes.py. This will run the program, and produce any selected output. Note that output files will be written to the directory in which the source file resides. Once you have it running, open up the source and play with some of the variables!
Evolving Rulesets for the Game of Life Name: Julia Ferr Date: 2006-05-06 23:01:36 Link to this Comment: 19273 |
Evolved Rules | Randomized
Rules |
Starting Board: 1 0 1 0 0 0 0 0 0 0 1 0 0 1 0 1 1 1 1 1 0 1 0 0 0 0 0 0 0 1 0 0 1 0 1 0 1 0 1 1 1 0 0 1 0 0 0 1 1 0 1 0 1 0 1 0 0 1 1 1 0 0 0 0 0 0 0 1 0 1 0 1 0 1 0 0 0 1 0 1 1 0 1 1 0 1 1 1 1 1 0 1 0 1 0 0 0 0 1 0 |
Starting Board: 0 1 1 1 1 0 1 1 0 1 1 1 0 1 0 1 1 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 0 1 0 1 1 0 0 1 0 1 1 0 1 0 0 1 1 0 0 0 0 0 0 0 1 0 0 1 0 1 1 1 1 1 0 0 0 1 1 0 0 0 1 0 0 1 0 0 1 1 0 1 1 1 0 0 0 0 1 0 1 0 1 1 0 1 0 0 |
Ending Board: 1 0 1 1 1 0 0 0 0 1 0 1 1 0 1 1 0 1 0 1 0 1 1 0 1 1 0 0 1 1 1 0 0 1 0 1 1 0 0 0 1 0 0 0 0 1 0 1 0 1 0 1 1 1 0 0 0 0 0 0 1 0 1 1 1 1 1 0 0 0 0 1 0 0 0 0 1 1 0 0 1 1 1 0 0 1 1 1 1 1 0 0 1 1 0 1 0 1 1 1 |
Ending Board: 0 0 1 1 1 1 1 0 1 1 0 1 1 1 0 1 0 0 1 0 1 1 1 1 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 1 1 0 0 1 0 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 0 1 0 1 1 |
Fitness
for evolved board is: 0.69 |
Fitness for randomized board is: 0.54 |
Emergent Tree Generation Name: David Rose Date: 2006-05-07 01:25:07 Link to this Comment: 19274 |
A Random Walk Through The Game of Life Name: Laura Kasa Date: 2006-05-07 22:01:12 Link to this Comment: 19279 |
Adding an Element of Randomness To Conway's Game of Life...
John Conway discovered
(or invented, depending on your philosophy) the Game
of Life in 1970. The game illustrates how a simple rule set can exhibit
complex, even lifelike behavior.
If a square is dead:
It becomes alive only if exactly three of its neighbors are alive.
If a square is alive:
It stays alive if exactly two or three neighbors are alive. (survives)
Otherwise it dies. (from loneliness or overcrowding)
Out of these simple rules emerge a plethora of interesting “life” forms. There are still life objects whose configurations remain
stable under the rules of the Game of Life. A 2-by-2 square is an example of
a still life object. There are also oscillators in the Game
of Life, objects that do change from step to step, but repeat and “oscillate” within a given period. Finally there are gliders who give the
impression of "motion."
In order to see examples of the various life forms mentioned here, simply go
to the applet, click the “Setup Blank” and then click either the
“Glider,” “Oscillator,” or “Still Life” button, and then click on the grid with your mouse to add one of these figures.
Then click “Go Forever” to see how these objects behave under the
Game of Life.
The Game of Life is completely deterministic. That is, if you start out with
a specific pattern on the grid, the rules of the Game of Life will always take
that starting pattern to a predetermined end state. Try it out. Use the “Create
Life” button to draw a specific pattern, and you will see that no matter
how many times you start with that pattern, the end result will be the same
each time. Try the “R-pentomino”; the R-pentomino consists of only five cells but takes1103 steps before reaching its end state.
So what happens if we add an element of randomness to the Game of Life? We have
seen that the Game of Life is deterministic. If we add an element of randomness,
could the Game of Life still be deterministic? Would gliders and still life
objects behave the same way? Would the final density of life be the same in
the end states of both versions? Let’s explore the applet.
This applet was created with created with NetLogo.
Note: This model is a modified version of a model found in the NetLogo Models
Library. Download this applet and view the source code for copyright information.
The “Go Random” buttons add an element of randomness to the normal
game of life. By changing the value on the birth-randomness slider, the likelihood
that a cell with 3 neighbors will stay alive or be born decreases with the percentage.
Similarly, decreasing the value of death-randomness increases the chance that
a cell that was supposed to die will live.
The “Go Random2” buttons act the same as the “Go Random” buttons. The only difference is that the number of increments by which you can
adjust the randomness of the death and birth is increased. Finally, the “Go
Limited” button simply acts on living cells, increasing the likelihood
they will die when birth-randomness is decreased.
Note: When the birth-randomness and death randomness are at their maximum value (either 100 or 1000 depending on the version you use), then the rules operate like the normal Game of Life.
Surprisingly, our results show that by even adding just an iota of randomness
to the system, the defining characteristics of the Game of life deteriorate.
Try starting with a random setup by clicking the “Setup Random” button, and then play with the birth-randomness and death-randomness sliders.
To see the game of life with a random element press the “Go Random” button.
Provided below is a table of results for varying death-randomness and birth-randomness
percentages. The results are in the form (x, y), where x is the final density
and y is the number of iterations it takes to reach the final density. The infinity
sign indicates that the grid oscillates erratically at the given final density
from the beginning and continues on in a similar fashion forever. The initial
density was 50% for the following results.
Birth Randomness % | Death Randomness | |||||
0 | 25 | 50 | 75 | 100 | ||
0 | (1, < 20) | (.70, ∞) | (.30, ∞) | (.20, ∞) | (0, < 20) | |
25 | (1, < 20) | (.75, ∞) | (.40, ∞) | (.25, ∞) | (0, < 20) | |
50 | (1, < 20) | (.75, ∞) | (.50, ∞) | (.30, ∞) | (0, < 20) | |
75 | (1, < 20) | (.75, ∞) | (.55, ∞) | (.40, ∞) | (0, < 20) | |
100 | (1, < 20) | (.75, ∞) | (.60, ∞) | (.45, ∞) | (.03,1100) |
As expected the final entry has values like the normal Game of Life (.03,1100).
We see that none of the trials with randomness behave remotely like the normal
game of life.
Note that the initial density of life did not seem to have a statistically significant
effect on the end result of the Game of Life. An experiment of 25 runs shows
that the average final density is:
Average (25 Runs) | Initial Density | Final Density | Steps |
35% | 3.24% | 1236 | |
50% | 2.92% | 1144 |
Our intuition confirms this finding since a little five cell figure like the
R-pentomino with negligible initial density can result in a much more substantial
final density.
We looked at a nice smattering of trials with various birth-randomness and death-randomness
values, and saw that they did not behave like the game of life. They did not
end at a pre-determined relatively stable state with a low density of life.
Try our random life buttons with as little randomness as possible.
In both cases the game looks a bit like our normal game of life, but it never
reaches a final determined state. Randomness still devours the heart of the
Game of Life.
It is interesting to see how random rules of life act on gliders, oscillators,
still life objects and the R-pentomino. I found that random behavior destroyed
the way in which these objects behave under the normal rules of life.
You could also try the “Go Random Limited” button which will increase
the probability that a cell that should live will die. My intention of including
this button was to limit the random behavior solely on the area of the grid
that had life on it. However, I found the results uninteresting since usually
all life dies out. Perhaps you can think of a way to contain the randomness
to a particular portion of the grid.
The Game of Life changes fundamentally when mixed with a random element. Could
there be a way to add a random element without fundamentally changing the Game
of Life? Perhaps there is a way to rein the randomness so that the entire grid
is not overcome by a detrimental wave of unpredictability. Is this random element
fatal specifically to the Game of Life or is there ever away to add randomness
to a deterministic system? Hopefully through better modeling and increased understanding,
the answers to these questions and others unasked will emerge!
References
Wonders of Math:
The Game of Life, 2000-2005.
Exploring Emergence,
Epistemology and Learning Group, MIT, 1996.
NetLogo Basketball Name: Sarah Mala Date: 2006-05-10 14:10:03 Link to this Comment: 19300 |
This model is a simplified depiction of a basketball game. There are two teams of five players, one blue and one green. One team has the ball at a time. The team with the ball has the ability to move randomly and the team without the ball will follow. The ball is either passed to a random player on the same team shot at random in a 2 pass to 1 shot ratio. Once the ball is shot the probability of making it is a function of the number of passes and the distance from the hoop. After a shot is taken the other team gets the ball whether made or missed.
This model is intended to depict the emergent aspects of athletics, within the context of the sport of basketball. A model of a simplified basketball game is set up where the goal of each team is to score points by making shots. The ability to make a shot is a random function, but also influenced by how far the shot is taken from the basket and the number of passes within a possession. Although making shots is the general goal, by incorporating a learning mechanism the blue team players synthetically "learn" how to maximize their ability to make shots. While the blue team has this ability to "learn", the green team does not; therefore, the two can be compared to see the effects of changing one's actions based on prior results.
Upon setup, the turtles are set up randomly; however, they can be moved via mouse throughout the world. The blue team always starts with the ball and when play commences the two teams have an equal likelihood to either pass or shoot, as well as an equal likelihood to make shots; however both functions change for the blue team as the game is played.
The equation for the probability of making shots is based on two factors. First, the court is split up into three distances from each team's respective hoop. The close_distance has an inherent value of 90, the medium_distance, 60, and the far_distance, 30. The shot is always taken from one of these three regions and the value of the region is labeled the shot%, which is put into the shot probability equation. The second aspect of the shot equation is the number of passes from the time the team receives the ball to the shot. Therefore, one side of the equation is: (number of passes) x (shot %). Also, at the time of any shot a random number between 0 and 300 is chosen. If this number is less than the value derived from the equation above (passes x shot %), then the shot is made, if not, it is missed. This ceiling of 300 can be changed to make the game more difficult or easier. The Overall Shot probability equation is: ifelse random 300 < ( shot% * passes) [make] [miss].
The Green team is set up in such a way that the team will shoot the ball 1 out of every 3 times and pass it 2 out of every three times. The learning mechanism for the blue team is set up to influence the amount of passing in which the blue team will do. Initially, the ratio of pass to shoot is the same for the blue as it is for the green, 1 out three is a shot. However, the blue team's equation is different such that it takes into consideration prior makes and misses. Instead of the green team's equation for shooting: ifelse random 15 < 5 [shoot pass_in wait 1][pass], the blue team equation is: ifelse random 100 < (33 - (missedshots * 5) + (score * 2) ) [shoot pass_in wait 1][pass]. This means that the amount of shots missed multiplied by 5 is subtracted from the original pass threshold of 33, while the number of shots made multiplied by 4 (which is equal to score x 2) is added to the threshold. Ultimately, the more shots missed, the more likely to pass, and the more shots made, the more likely to shoot. In effect, the blue team learns how to maximize their shoot to pass ratio, in order to maximize their ability to make shots.
Two buttons, SETUP and PLAY, control execution of the model. As in most NetLogo models, the SETUP button will put the players randomly on the court and create the two hoops. The PLAY button, a forever button, will then run the model. The MOVE BLUE PLAYERS (taken from Mouse Click & Drag Example in Models Library)button will move the blue players where ever on the court, because some times when they are setup, they are all on one end of the court. BLUE T-PASSES is the total number of passes the blue team has made the entire game. BLUE PASSES is the number of passes in each possession by the blue team. BLUE SHOTS is the number of total shots taken by the blue team throughout the entire game. BLUE MISSED SHOTS is the number of shots the blue team has missed throughout the entire game. BLUE TEAM SCORE is the total number of points (shots made * 2) the blue team has in the game.
GREEN T-PASSES is the total number of passes the green team has made the entire game. GREEN PASSES is the number of passes in each possession by the green team. GREEN SHOTS is the number of total shots taken by the green team throughout the entire game. GREEN MISSED SHOTS is the number of shots the green team has missed throughout the entire game. GREEN TEAM SCORE is the total number of points (shots made * 2) the green team has in the game. PASSES PER POSESSION is a graph of the number of passes per possession as a function of time. It has two lines, one blue, representing the blue team, and one green representing the green team. COMMAND CENTER displays the values for the shot probability equation. It shows the shot%, number of passes, and the two multiplied together for every shot. It also shows which turtle took the shot.
The major two things to look at are the command center and the graph. From the command center one can see how the overall shot probability value (shot% x passes) is effected by passing. It is also good to look at the values for the blue team compared with those of the green team as the game moves on.
The graph is the most important thing to look at. The graph shows the passes for every possession. As the game goes on, the number of passes should increase for the blue team, while for the green team, it will remain constantly low. However, the blue team will eventually find an equilibrium, and the number of passes will generally stay within a certain range. At times there will be drops in the blue passing level, but it should usually be followed by an increase in passing once the team has reached its equilibrium.
Although no sliders were created in this model, different values should be manipulated by the user to see the effects that those changes might have. One major value that can be changed is the random sample number for the shot probability. The default is 300. Increasing the value would make making a shot more difficult. One could also change the shot % values.
Second, one could change the pass threshold for the blue team. Its default value is 33 of 100, but it could be raised or lowed to make shooting or passing more probable respectively. More importantly one can change the made shot and missed shot multipliers. There are 4 and 5 respectively. By changing these numbers the blue agents will put more emphasis on the effects of making or missing a shot. This will greatly change how they learn as well as the equilibrium in which they achieve.
Also, it is important to note that the distance from the basket influences the probility of making a shot. Therefore, if one wants a "fair", he or she should set up the players equal distances from the baskets. At the same time one can make it more difficult for the blue team by setting the further from their basket, and see if they learn to overcome their handicap.
Because basketball is such a complex game, there are endless amounts of features that could be added to make the game more realistic. Here are a few things. First momentum can be made a factor by building in a factor into the shot probability equation that takes into account the amount of made shots made in a row, or missed in a row. A shot clock can be implemented so that a team just can't pass forever. With that the team can learn to minimize shot clock violations. Also, to discourage too much passing, 1 out every 10 passes can result in a steal by the other team. Furthermore, it can be set up so that passes are more likely to go to players closer to the basket. As of now there are only three regions where players have different shooting percentages. This can be increased to 7 or 8.
Something that would be extremely interesting would be to have different types of players. Some that tend to shoot more, some that pass more, some that steal the ball more, some that tend to stay close to the basket, etc, and allow the user to choose 5 players from any type. It can then be seen under which combination of players does a team succeed most.
In the models library:
*Biology
-Aids
-Disease Solo
-Virus
*Code Examples
-Mouse Click & Drag Example
-Plotting Example
-Shape Animation Example
Sarah Sniezek's NetLogo Basketball Game
NetLogo Segregation Models Name: Angad Sing Date: 2006-05-10 14:37:50 Link to this Comment: 19302 |
Framing the Issue:
In conducting research to inform my NetLogo model, I first wanted to confirm my suspicion that racial segregation in America was a worthy topic to pursue. I read sociology essays and perused government statistics. Because this background information is only tangentially related to the project assignment itself, I'll focus more on brevity than thoroughness. There is a plethora of statistical evidence suggesting that segregation causes key indicators such as education, employment, and health to suffer. I'll only briefly delve into the issue of education with the intention of it being representative of other social ills potentially associated with racial segregation [from government statistics and George Gaister's essay "Polarization, Place, and Race"].
In terms of education, black youths are 30 percent less likely to finish secondary school than whites, and Hispanic youth are 170 percent less likely. The education gap between black and white Americans widens further in college, where college completion rates for whites is 85 percent higher than for blacks. This is due in part to the large concentration of minority youth in large urban school districts. For a number of reasons, the clustering of minority students itself is a determinant of their educational success. For the nation's largest forty-seven school districts, the dropout rate is about twice the national average. The racial composition of the largest eleven school districts is majority non-white, with Denver being the most white at forty-one percent.
Phrasing the issue as one of segregation, to some extent, misses the point of these NetLogo models. It may be more effective to approach the issue as community clustering, with the understanding that minority communities tend to be apart from white communities in older, core municipalities of metropolitan areas.
Model 1: Assimilate
available at, with some instructions and model description: http://bubo.brynmawr.edu/~asingh/assimilate.html
This model is based on the NetLogo Segregation model. The primary modification is that turtles on the peripheries of their communities become accustomed to turtles of different color through repeated interactions with them. Depending on the set "assimilate-rate", a red turtle may lose its preference for red turtles within one to three iterations. Color preference, in this model, is incrementally lost if and only when a turtle of a particular color is in the vicinity of a majority of turtles of a different color. For instance, a red turtle will incrementally lose its color preference if surrounded by three green turtles and two red turtles. Of course, a red turtle will only have green neighbors if it resides on the periphery of a red community.
Some interesting aspects of the model:
• A higher turtle mobility results in a higher initial segregation peak. Increased mobility allows red and green turtles to more readily realize their ideal environment, which under the settings of this model is a segregated community.
• Time scale: consider each turtle to be a family unit. The children in each family inherit the same color predisposition of the parents. If each family moves 3 times per generation and it takes one generation to lose color preference (assimilate-rate set on 3), then every 3 iterations is one generation. Within just a few generations, we see many boundaries dissolve - but it takes hundreds of iterations to dissolve all communities!
• Percent-green: The percent-green isn't as important as what it shows. Set the green-percent to 0.6 or 0.7. With a smaller overall red population, we see only small red communities that are easier to dissolve. The percent-similar indicator should be ignored because the high prevalence of green turtles will necessarily yield inflated percent-similar numbers. Instead, the visual representation of small red communities quickly dissolving should suffice.
Much of the writing in urban policy and sociology attempts to suggest reasons why segregation has remained persistent in America. Among the suggestions are: interracial economic disparities, preferences for whites to live in predominantly white neighborhoods, and illegal racial discrimination by public and private parties. What this NetLogo model suggests as being incredibly important is the size and density of white and minority communities. This may seem readily apparent and abundantly obvious, but I have not come across it in any literature. The larger, homogeneous communities are difficult to penetrate, and the process by which their peripheries dissolve is painstakingly slow. This is by far the most interesting and surprising outcome of my NetLogo modeling career. The importance of the size and population density of homogeneous communities has been overlooked by academic and popular literature because of its structural and systemic bias. What emergence and my NetLogo model reinforce, instead, is that a large group of individuals are operating under certain predispositions to produce the larger pattern of segregation in America.
Model Two: Allies
available at, with some instructions and model description: http://bubo.brynmawr.edu/~asingh/allies.html
This project grew out of a program sponsored by Haverford, Bryn Mawr, and Swarthmore. It is formally known as the Winter TriCollege Multicultural Institute, though it is more typically referred to as Winter TriCo. It is an intensive, 8-hours a day program for students, faculty, and staff of the three participating colleges. In many of the workshops, persons identified as holding greater power or societal influence were termed "allies" if they utilized their influence in the interest of a subjugated population. In a relatively silly workshop, persons wearing masks aided those not wearing masks, because in that fictional society, persons with masks were granted certain enumerated privileges not available to those without masks. Each masked person thus represented an all: "a person of one social identity group who stands up in support of members of another group; typically a member of a dominant group standing beside member(s) of a group being discriminated against or treated unjustly" (Wikipedia).
Some interesting aspects of the model:
• Unlike the previous model (Assimilate), allies are able to penetrate large swaths of red or green turtles. Though a bit strained, it reminds me of something like an enlightened despot or celebrity on a turtle-based computer-model scale. This ability mitigates the importance of the size and population of segregated communities. I don't think this model is a replacement for the assimilate model, but it serves instead as a complementary supplement.
• It is also interesting to observe the behaviors of blue turtles (termed apathetic because they exhibit no color preference). If the majority of red and green turtles retain their color preference, then there will be a large prevalence of segregated communities. In the narrow regions between these communities is open space for blue turtles to populate. So even though the blue turtles have no internal color preference, they tend to cluster much like the red and green turtles.
Areas of Improvement:
There are a couple levers I could include to make the models more functional or more closely related to reality.
• Racial preference between whites and blacks is not the same. 95% of black Americans would be willing to live in a neighborhood that is 85% white. In opposition to this, only 16% of white Americans are willing to live in a neighborhood that is 57% black. So one possible improvement would be to include differential color preferences. Presently, the color preferences for all turtles as a whole can be manipulated through a slider, but the same level of preference becomes instilled in turtles of all colors.
• Another reality in America is the differential earnings of blacks and whites. This is important for my NetLogo models because it places constraints on mobility. White Americans are more able to move into a neighborhood of their liking, resulting in the phenomenon known as "white flight". Black Americans, on the other hand, are on average less able to move to a neighborhood of their liking.
And of course there are an infinite other possible improvements to these models. Because they are the first computer models I've ever created, I'm unfamiliar with a lot of the possibilities with programming. If you have any suggestions, or just want to tinker with the code, please go ahead.
Visual Modelling in NetLogo of Methods for Searchi Name: Jesse Rohw Date: 2006-05-11 16:30:58 Link to this Comment: 19325 |
In this paper, I explain the objective of my project, give a general description of how I built my model in NetLogo, briefly summarize the concepts behind various search methods, report on the outcome of my efforts, and offer some ideas based on my findings.
I started my project with the objective of creating a flexible model in NetLogo that would visually illustrate the performance of agents searching a 2-dimensional solution space. I wanted to create a model that would be both an easy-to-follow graphical model of the search and a statistical tool that could help the user discover which of the four search methods we discussed in class (hillclimbing, simulated annealing, computational temperature, and genetic algorithms) was best-suited to different types of fitness landscapes (i.e. different types of fitness distributions over the 2-dimensional solution space). The project went well, except that I have not yet completed the genetic algorithm search option, so my model illustrates comparisons between only the first three methods.
My first problem was finding an easy way to generate fitness landscapes. I wanted the user to be able to quickly and easily distribute fitness across the solution space in a way that allowed the creation of different types of fitness landscapes but that was also fairly predictable, so that the user could choose which type of landscape they wanted to generate. I needed to find some way to parameterize the general qualities of a fitness landscape relevant to agents searching it. The first of these general qualities I addressed was smoothness.
When the landscape was first created, it was very "rough"¡ªI started the landscape with a random distribution of fitness, from 0 to 300 (since this range is large enough to realistically model many fitness functions, but does not exceed the 256 colors I used to represent fitness by enough to compromise the visual representation). Whenever the user made changes to the landscape that might affect the maximum and minimum fitness, my scaling function could (and should, for statistical purposes and to avoid a misleading visual representation) be used to map the new values back onto the 0 to 300 range.
To smooth the landscape, I let the user control the application of the NetLogo primitive ¡°diffuse¡± to the fitness of the entire landscape; this distributes a variable in one patch among the neighboring patches, modeling natural diffusion of a gas or liquid down its concentration gradient. This smoothing function created a gracefully curved landscape with relatively few local maxima and minima.
To introduce sharp edges, I created a function that caused the fitness of the landscape to separate at an adjustable point (set by default as half the maximum fitness). Thus, by clicking ¡°diverge¡±, the user could make half (by default¡ªany other fraction could also be attained) of the landscape decrease in fitness while the other half increased, creating ¡°cliffs.¡± More general ¡°roughness¡± could also be attained with the function ¡°scramble¡±, which simply reset the fitness of each patch randomly to a value within a user-determined range of the initial fitness.
Using a combination of these three functions (¡°smooth¡±, ¡°diverge¡±, and ¡°scramble¡±) and re-scaling the landscape appropriately after each change, it was possible to create a wide variety of landscapes. However, it smoothness was an all-or-none option, because I had not placed limits on the fitness (i.e. fitness could become arbitrarily small or large, and as soon as the patches were rescaled, it would still be smoothly distributed between 0 and 300). Thus, even when ¡°diverge¡± was used to create cliffs, these cliffs were still approachable and climbable, because there was always a slight slope following their rise or fall. To fix this problem and allow the user to create difficult-to-navigate plateaus, I created an option to prevent fitness from rising above 300 or falling below 0, so ¡°diverge¡± could be used to squash the landscape flat at the highest and lowest points. By adjusting the point from which the fitness diverged, the user could place these plateaus at whatever altitude they wanted.
The plateaus also inspired me to add another option: when the fitness exceeded the acceptable range, it could be inverted instead of kept constant at the floor or ceiling; this created a highly ¡°folded¡± landscape. With ¡°invert¡± on, diverging for a long time produced a pattern of concentric ridges and valleys.
Finally, I wanted to allow the user to partition the landscape even more severely, so that the difficulty of searching solution spaces with highly isolated or unpredictable maxima could be visually represented. To do this, I created a function for laying a set of lines of 0 fitness across the entire landscape, either horizontally or vertically, at an adjustable interval. With these functions, the a highly diverse array of landscapes could be generated.
I allowed the user to populate the landscape with any number of agents so that statistics for performance on the various landscapes could be averaged easily and quickly from a large sample (although with more than a few thousand the program would start to slow down significantly). The agents¡¯ progress could be tracked on a plot of agent fitness over successive iterations, or by comparing various monitors of average, best, and worst agent fitness to monitors of average landscape fitness and to the visual representation of the landscape. Or, the user could watch the progress of an individual agent following the algorithm for hillclimbing, simulated annealing, or computational temperature.
Hillclimbing is an algorithm in which the agent simply searches the immediately adjacent positions and moves to whichever is most fit. This makes sense, as the agent¡¯s current location on the landscape represents a solution to a problem. In the case of my model, the problem has two parameters. The agent¡¯s position along the x-axis is the value of one parameter, and the position along the y-axis the value of the other. So hillclimbing is simply trying out all the possible new combinations of output values (i.e. all other possible solutions) that are attainable by changing the current values (the current solution) by the minimum increment.
In simulated annealing, agents hillclimb with some randomness in whether or not they pick the best adjacent position. The randomness varies according to the ¡°temperature¡±, a variable that decreases with time. In my model, the user can adjust the temperature and the rate at which it falls as the agents are searching, allowing the user to experiment with the effects of different temperatures in real time.
Finally, computational temperature is like simulated annealing except that the temperature increases when the agent gets frustrated by getting stuck in the same position. In my model, I set each agent¡¯s temperature (or ¡°frustration¡± in my model) at 0 to begin, and increased it by an amount determined by their collective ¡°impatience¡± (a user-controlled variable) for each iteration that that individual agent chose to stay in its same location. Once an agent¡¯s frustration was sufficient for it to move, I decreased it¡¯s frustration by another adjustable variable, ¡°calmRate¡±, each time it moved to a new location.
Experimenting with these three search methods on a variety of different fitness landscapes was interesting. There wasn¡¯t as big a difference between the agents¡¯ performance with different methods as I had expected. In this paper¡¯s conclusion, I express some thoughts on how the methods could have been improved. However, despite being less that what it could have been, the difference was enough to be significant.
As I expected, on ¡°rough¡± landscapes with a moderate degree of randomness, simulated annealing and computational temperature outperformed hillclimbing, whereas on the smooth landscapes, hillclimbing was a much more efficient and reliable way of reaching the same solutions that simulated annealing and computational temperature were likely to reach.
What disappointed me was the failure of the second two methods to improve substantially on hillclimbing in highly partitioned landscapes. My implementations of simulated annealing and computational temperature were only marginally more successful than hillclimbing at escaping from local maxima and discovering the absolute maximum. Of course, if enough randomly seeded agents were used, some of them would always start in the ¡°right¡± position and attain the best solution. But I was unable to get the agents that had started in the ¡°wrong neighborhoods¡± to strike out, explore, and discover a new maximum. However, this problem could probably be solved:
A method that I think would be effective on smooth or rough landscapes at finding the absolute maximum regardless of starting position involves reverse hillclimbing, i.e. descending the hill instead of ascending it. It would be a simple matter for an individual agent to hillclimb until it gets stuck, record the coordinates of that maximum, and then descend, by the steepest route, to the worst solution. From there, it would hillclimb again. In some situations, since the steepest path down is sometimes also the steepest path up, the agent might need to make a few random choices at local minima to avoid always retracing its steps. In the same way, some randomness or memory of which ¡°directions¡± it had previously chosen might be needed when the agent is first descending from a peak to avoid setting out in the same direction and reaching the same local minimum, if that minimum has already been explored. Once the agent is finding no new maxima, it can simply choose the best of those that it has found and recorded. This same principle¡ªdeliberately relocating to the worst locally accessible solution in order to overcome partitions in the landscape¡ªcould be applied with simulated annealing and computational temperature.
Another search method that I had planned on including in the project but that I was unable to finish in time is the evolution of genetic algorithms. To me, the most obvious method of implementing a genetic algorithm in my model would be to have each unit of displacement along an axis be a ¡°gene¡±. Thus, crossover between two agents would place their offspring somewhere within the rectangle that had the two parent agents at the corners. Clearly, this would facilitate the exploration of the area between already-discovered local maxima, since those agents on the peaks would be the most fit and most likely to reproduce. Thus, genetic algorithms would probably do well on partitioned landscapes.
In conclusion, my model is a useful tool for visualizing the search of a solution space, but could certainly be improved to include more search methods and new types of fitness landscapes.
The Story of Modeling the Mommy Wars Name: Flora Shep Date: 2006-05-24 13:39:02 Link to this Comment: 19418 |
I count things. For as long as I can remember, I have counted everything around me in my quest for patterns, for the rules of the world. Yellow and white lines on the street, tiles on the floor, lamps in coffeehouses, pretty much every set of discrete objects I saw, I was convinced, contained a secret. Mildly OCD, I made up systems of behavior around the patterns I saw around me, predicted the safety of my family based on which lane my Mom chose to drive in on the highway. Given this childhood, it is only natural I crave the comfort patterns of numbers give me in my gender studies classes. But, I have never read a feminist theory written in formulas. There are too many variables to consider in explaining social phenomena. Rhetoric captures the nuances of interlocking systems of oppression better than mathematics.
Emergent computer modeling combines the attributes of rhetoric and classical mathematics. The results of models are repeatable, like a good physical formula, but the outcome of an argument is extremely difficult to impossible to predict and requires interpretation, like a good piece of writing. Many scholars already employ computer models to test their theories in social areans. However, much of feminist theory includes a top-down approach to social phenomena: a overbearing system that dictates the behavior of men and women. Emergent models can only illustrate a system composed of many agents. I needed to find a feminist theory that gave women agency within the confines of a restricted environment and I found it in Deniz Kandiyoti's "Patriarchal Bargain."
In this article, Kandiyoti compares women's reactions to social change in various cultures. She concludes:
Women's strategies are always played out in the context of identifiable patriarchal bargains that act as implicit scripts that define, limit, and inflect their market and domestic options...A focus on more narrowly defined patriarchal bargains rather than on an unqualified notion of patriarchy, offers better prospects for the detailed analysis of processes of transformations."
In her analysis, women have agency and make decisions based on the options available to them. She does not view women as slaves to a dominating culture but rather as agents making the best of the world them have based on cultural and social boundaries. This is a theory that can be pushed into an emergent model.
I chose to model the current "mommy wars," the endless arguments between couples that choose to have a stay at home parent and couples that choose to have a double breadwinner family. By far, the most difficult part of constructing a model was breaking down the theory into programmable parts. I am more used to portraying the complexities of social interaction in words rather than quantities within an environment. I had to pick and choose which social factors to include and how to include them. Also, I fought very hard to keep my own political views out of the model. I did not want to favor one style of parenting over another. I wanted to create a world where the observer could change the environment in a great many ways and watch societal change unfold. Translating a rhetorical idea into logical processes agents could follow was an exciting mental exercise. I thought about many facets of the mommy wars argument in different ways than writing about them would cause me to.
I wanted to create an unpredictable Net-Logo model that was easy to manipulate. There are four variables in this world: single or double breadwinner families, childcare cost, class and family income. An observer can control the likelihood that a family will choose to be a single or double breadwinner family. This control symbolizes the cultural pressure from the society the agents live in. Childcare cost can be controlled as well, but the observer controls basic childcare cost. The cost goes up for families in higher classes and for double breadwinner families. Family income is determined by two variables. First, the class of the family determines the peak salary amount for the breadwinner(s) and the amount of high paying jobs determines each family's ability to receive the highest salary they are capable of. The minimum salary can also be controlled. This world is a simplistic one. It does not factor in added childcare costs of health problems, families incapable of having two breadwinners, any form of social discrimination and many other important social phenomena. I am a beginning programmer and this model is far from perfect. My aim was not to model the world but to model the decisions families make everyday. I am not a parent myself, but I based the ideas for the constraints of my model on my own observations and Kandiyoti's assertion that a family works within certain constraints.
My findings were quite upsetting. An upper class, wealthy society could be sent quickly into debt by skyrocketing childcare cost. However, this imbalance could be quickly corrected by switching childcare approaches. High childcare costs sent the society into single breadwinner mode while low childcare costs sent the society into double. This model further impressed upon me the complexities of social interaction. An effective analysis and model of society cannot be created using cultural ideology or economic structure alone. If the combination of the two was necessary for my model of a fake world, then they become even more important in daily life.
So, what did I learn about the Mommy Wars from my model? The issue is complicated, much too complicated to derive a right and wrong way to raise a family. I find it difficult to compare and contrast the families in my artificial world. Each one had a different set of circumstances. And, with each step, each generated a random number that was their likelihood to be a double breadwinner family. Depending upon where that number fell on the number line of the model society, they would make a certain decision. It was not the point of this model to prove that children need a stay at home parent in their infancy. I only sought to figure out how people make these decisions. And, whichever side a person may take, s/he will have to do more than spout ideology to make social change. The strongest factors in this model were societal and economic ones.
I think this model was most useful to me as a learning tool. I thoroughly thought through the issue that I wished to model. However, it would have to be greatly altered to be more useful and accurate in an academic or social setting. A more sophisticated version of this model would be able to accept real demographic data to simulate the impact of various societal changes. I do believe that this could be useful in a practical way. And, the results are quite interesting, so I think that academics would enjoy it as well.
Works Cited:
Kandiyoti, Deniz. "Bargaining with Patriarchy" Gender and Society, Vol. 2, No. #, Special Issue to Honor Jessie Bernard (Sep.,1988), 274-290.