A Simple Ecosystem

Turtles get hungry. They wander from patch to patch searching for energy in the form of food. The more they wander the more energy they consume. Plants grow back, but do they grow back fast enough to satiate greedy turtles? Let's find out by creating an artificial ecosystem:

In our system each patch has an attribute called penergy that represents the amount of energy stored in the patch. Each turtle has an attribute called energy representing the amount of energy it stores.

patches-own [penergy]
turtles-own [energy]

The maximum value of each is 100%. The amount of energy scales the color, too, so bright red turtles and bright green patches have lots of energy. They fasxe as their energy is depleted. A turtle dies when its energy reaches zero.

Turtles are restless. They constantly move about by turning randomly and moving forward a few steps. Each time they move, their energy is depleted by an amount determined by the metabolism slider. When a turtle arrives on a patch he tries to top off its energy by taking energy from the patch.

Try it: eco1.html

Hints and Ideas

Notice that eco1 turtles look like turtles. This is accomplished by setting their shapes during initialization:

set shape "turtle"

Here's a list of pre-defined shapes:

observer> show shapes

observer: ["default" "airplane" "arrow" "box" "bug" "butterfly" "car" "circle" "circle 2" "cow" "cylinder" "dot" "face happy" "face neutral" "face sad" "fish" "flag" "flower" "house" "leaf" "line" "line half" "pentagon" "person" "plant" "sheep" "square" "square 2" "star" "target" "tree" "triangle" "triangle 2" "truck" "turtle" "wheel" "x"]

Under the tools menu find a turtle shapes editor that allows you to create custom shapes:

Use the scale-color procedure to scale color. For example:

set pcolor scale-color green penergy 200 0

Since penergy is between 0 and 100, this means healthy patches will have a nice green color, instead of black.