Each species plays a role in its ecosystem. Species depend on each other and everything is inter-dependant. In Web of Life each patch is a species or organism.
The simulation customizes the basic framework. Here's the web version: weboflife.html.
Each patch has three attributes:
patches-own [penergy original-color dead]
Where penergy is the amount of energy the patch has available to contribute to the other patches in its ecosystem. The value of this attribute is between 0 and 100 (inclusive). Dead is a true-false attribute. When a patch is dead it turns black and no longer contributes to the ecosystem. Random patches can be killed by clicking on the oil spill button.
The color of a patch is some shade of its original color. The shade is proportional to the energy level. The original color is a random basic color. Here's how I created the original color in init-patch:
to init-patch
set original-color one-of base-colors
set pcolor original-color
set penergy 100
set dead false
end
Updating a patch means donating one unit of penergy to every other patch in the ecosystem. Of course when a patch runs out of penergy, it can't donate any more. As a patch donates, its penergy is depleted and its color gets darker. Also, a patch throws away any penergy it receives if its penergy is already 100. As a patch receives energy, it brightens.
The plotter needs to be updated periodically, just like the turtles, patches, and globals. This is done by calling the plot procedure in the update method:
plot mean [penergy] of turtles