- Art
- Astronomy
- Biology
- Selection and Mutation Series
- Ant Patterns
- Bacterial Growth
- Bark Beetles
- Biological Buffer
- Birds Competing For Worms
- Color Bunnies
- Ecosystem - Predator, Prey, and Grass
- Ecosystem - Rabbits and Grass
- Ecosystem - Two Species
- Ecosystem With Predator, Prey, And Grass
- Forest Fire
- Honeycomb Formation
- Termites Perimeter
- Yeast Growth
- Chemistry
- Earth Science
- Mathematics
- Physics
- Social Science
Ecosystem - Predator, Prey, and Grass
Submitted by librarian on Tue, 2006-08-08 18:48. :: Category
WHAT IS IT?
This project models an ecosystem consisting of growing grass, grasshoppers that eat the grass, and predators that eat the grasshoppers. The grasshoppers and predators are implemented as breeds of turtles, while the grass is implemented as patches. If grass is present on a patch (with its density indicated by shades of green) it grows according to the rate specified in the solar-gain slider. Patches that have no grass at all are considered desertified and are shown in yellow. The only way grass can grow in the desertified areas is if it spreads to these patches through diffusion (one algorithm for modeling the re-seeding of the desert patches).
HOW TO USE IT
The initial number of grasshoppers is controlled with the "ghs-num" slider. Each grasshopper is created with an energy level. The grasshoppers move randomly around, using up a small amount of energy for each step. If a grasshopper lands on a green patch, it consumes the grass at a rate determined by the "ghs-eat-rate" slider. This rate determines both the amount of grass that the grasshopper eats and the amount of energy the grasshopper gains. If a grasshopper is over age 2 and has accumulated enough energy (as determined by the "ghs-birth-thresh" slider), then it will hatch a new grasshopper. If a grasshopper reaches the age shown on the "ghs-max-age" slider or runs out of energy, then it will die.
The "pred-num" slider sets the initial number of predators. These predators also have an energy level that decreases slightly as they move randomly around. If a predator encounters a grasshopper, then it will eat it and gain the amount of energy indicated on the "pred-life-gain" slider. Once a predator accumulates enough energy (as shown on the "pred-birth-thresh" slider), it will hatch a new predator. A predator dies when it runs out of energy or reaches the age shown on the "pred-max-age" slider.
THINGS TO NOTICE
Try running the model with the default parameters. What happens to the populations over time? Can you control the degree of population fluctuation? How? What seems to determine the degree of fluctuation? Try freezing all but one of the parameters and experimenting with different values for the remaining parameter. What happens to the populations of the three species as you change the parameter?
CREDITS AND REFERENCES
This model is based on the Termites model included in the StarLogo Adventures Projects, and the book Adventures in Modeling, by Vanessa Colella, Eric Klopfer, and Mitchel Resnick (published by Teachers College Press, 2001); see
Turtle procedures
;; There are two breeds of turtles, the grasshoppers (ghs) and the predators (preds)
breeds [
ghs
preds
]
;; Each turtle has a variable setting its energy (lifeforce), grass consumption rate (cons-amt)
;; age, and whether it should die.
turtles-own [lifeforce cons-amt thecount age death]
;; ghs-life procedure
;; called by the observer go procedure
;; Grasshoppers wander around and eat grass, which changes the grass density,
;; which in turn increase their own lifeforce. If they have enough energy, they reproduce.
;;
to ghs-life
setcons-amt (min density (ghs-eat-rate * random 5))
setdensity (max 0 (density - cons-amt))
seth random 360
jump 1
setlifeforce max 0 (lifeforce + cons-amt - 10)
setlifeforce min lifeforce 100
if (lifeforce > ghs-birth-thresh) and (age > 2)
[setlifeforce min 0 (lifeforce - 5)
hatch [setlifeforce 10 setage 0 setthecount 0]]
ghs-reaper
end
;; ghs-reaper procedure
;; called by the ghs-life procedure
;; If grasshoppers lifeforce drops below 1, their "death" variable is set to 1 by being eaten
;; by a predator, or grasshoppers grow older than the maximum age, they die.
;;
to ghs-reaper
if death = 1 [die]
ifelse lifeforce < 1
[
setthecount (thecount + 1)
if thecount > 3 [die]
]
[setthecount 0]
if age > ghs-max-age [die]
end
;; pred-life procedure
;; called by the observer go procedure
;; Predators check if there are any grasshoppers present at their current patch, and if so they
;; eat them. This increases their lifeforce, and if it is high enough they reproduce. The predator
;; then moves and dies if it meets the death conditions.
;;
to pred-life
if breed = preds
[if (count-ghs-here > 0)
[setdeath-of one-of-ghs-here 1
setlifeforce lifeforce + pred-life-gain]
setlifeforce (lifeforce - (random 20) / 10)
setlifeforce min lifeforce 150
pred-reaper
if (lifeforce > pred-birth-thresh) and (age > 5)
[setlifeforce max (lifeforce - 20) 0
hatch [setlifeforce 20 setage 0]]
pred-move]
end
;; pred-reaper procedure
;; called by the pred-life procedure
;; Predators die when their age exceeds the maximum age defined by the "pred-max-age" variable
;; or if their lifefoce drops below .1
;;
to pred-reaper
if age > pred-max-age [die]
ifelse lifeforce < .1
[setthecount thecount + 1
if thecount > 3 [die]]
[setthecount 0]
end
;; pred-move procedure
;; called by the pred-life procedure
;; Predators move by simply picking a random direction and if grasshoppers are present at their
;; current patch, they move forward only slightly (.1) whereas if no grasshoppers are present
;; they move forward between 0 and 20 patches.
;;
to pred-move
seth random 360
ifelse count-ghs-here > 0
[fd .1]
[fd random 20]
end
Observer procedures
;; Create a global variable "systime" that is increased after every step,
;; to count the number of steps the model had taken.
globals [systime]
;; Give each patch a "density" variable that stores the amount of grass that
;; patch has.
patches-own [density]
;; startup procedure
;; called by default when the project opens
;;
to startup
plotid 4
end
;; setup-fast procedure
;; called by clicking on the setup-fast button
;; This procedure sets up the environment by creating the graph, clearng
;; the screen, and creating varying grass density amoung the patches.
;; This is accomplished by creating twenty turtles, giving them random
;; positions and the same color, and having them move randomly, stamping
;; patches they land on. The turtle are then removed, and each patch that
;; was stamped by a turtle is given a density between 100 and 150.
;; They then each diffuse this density value to nearby patches. Once the grass has
;; been set up, the procedures to setup the grasshoppers and predators.
;;
to setup-fast
plotid 4
clearplot
setplot-title ""
ca
crt 1
repeat 20
[ask-turtles
[setxy (random screen-height) (random screen-width)
setc 60
repeat (solar-gain * 4) [stamp color seth random 360 fd 1]]]
ask-turtles [die]
ask-patches [if pc = 60 [setdensity ((random 50) + 100)]]
repeat 55 [diffuse density .9]
cgc
plot-setup
intro-grasshoppers
intro-preds
end
;; setup-slow procedure
;; called by clicking on the setup-slow button
;; This alternate setup procedure, like the setup-fast procedure, first clears
;; the screen and sets up the graph. Then, to set up the grass, it randomly
;; selects one tenth of the patches and sets their density to 100. This is then
;; diffuesd to nearby patches, and the agents are set up.
;;
to setup-slow
plotid 4
clearplot
setplot-title ""
setsystime 0
ca
ask-patches [if (random 10) < 1 [setdensity 100]]
repeat 10 [grow-grass
diffuse density .3
cgc]
plot-setup
intro-grasshoppers
intro-preds
end
;; go procedure
;; called by the "go" button.
;; This procedure tells the grass to grow by increasing its density, diffuses
;; this new density, scales the grass color based on its density, and runs the
;; generation procedure (which steps the whole model forwards).
;;
to go
grow-grass
diffuse density .05
cgc
generation
ask-ghs [ghs-life]
cgc
ask-preds [pred-life]
end
;; grow-grass procedure
;; called by the go procedure
;; This procedure tells the grass to grow by having each patch with any grass density
;; to increase its density by setting it to whichever number is smaller: 99 or its current
;; density plus one tenth the "solar-gain" variable. The cgc procedure is then called,
;; having the patches scale their color.
;;
to grow-grass
ask-patches
[if (density > .1)
[setdensity min 99 (density + (solar-gain / 10))]]
cgc
end
;; cgc procedure
;; called by the go procedure
;; This procedure scales the patch colors based on their density. The darker the patch,
;; the higher its density.
;;
to cgc
ask-patches
[ifelse density > 0
[scale-pc green density 100 0]
[setpc 48]]
end
;; intro-grasshoppers procedure
;; called by the setup-fast and the setup-slow procedures
;; This procedure bsets up the grasshoppers. It creates the number of grasshoppers defined by the
;; ghs-num slider, puts them at random positions, give them random "lifeforce" between 0-100, and
;; gives them a random age between 0-50.
;;
to intro-grasshoppers
create-ghs ghs-num
ask-ghs
[setxy (random screen-height) (random screen-width)
setc red
setlifeforce random 100
setage random 50]
end
;; intro-preds procedure
;; called by the setup-fast and the setup-slow procedures
;; This procedure sets up the predators. It creates the number of predators defined by the
;; pred-num slider, puts them at random positions, give them random "lifeforce" between 0-100, and
;; gives them a random age between 0-50.
;;
to intro-preds
create-preds pred-num
ask-preds
[setxy (random screen-height) (random screen-width)
setc 30
setlifeforce random 100
setage random 50]
end
;; generation procedure
;; called by the go procedure
;; A time-step procedure that increments the life of predators and prey as well as stepping the
;; time for the entire model forward.
;;
to generation
ask-ghs [ghs-life]
cgc
ask-preds [pred-life]
ask-turtles [setage age + 1]
setsystime systime + 1
end
;; plot-setup procedure
;; the old way that was used set up the plots in StarLogo
;;
to plot-setup
pp1 ppreset setppc red
pp2 ppreset setppc green
pp3 ppreset setppc 1
setplot-xrange 0 25
setplot-yrange 0 500
setplot-title "Amount vs. Time"
end
;; graph-it procedure
;; this is the old way to update the graph
;;
to graph-it
every 1.8 [ ;only graph every 1.8 seconds
;this causes the graph to be smoother (the averaging makes it somewhat discrete)
pp1 ppd plot count-ghs
;pp2 ppd plot sum-of-patches [density / 200] ;a slower way of graphing approximately the same thing
;we're graphing a scaled distribution of the patch colors
pp2 ppd plot (5 * (count-pc green) + 4 * (count-pc (green - 1)) + 4 * (count-pc (green + 1))
+ 3 * (count-pc (green - 2)) + 3 * (count-pc (green + 2)) + 2 * (count-pc (green - 3))
+ 2 * (count-pc (green + 3)) + 1 * (count-pc (green - 4)) + (1 * count-pc (green + 4))
+ 0 * (count-pc (green - 5)) + 0 * (count-pc (green + 5))) / 10
pp3 ppd plot count-preds]
end
;; start procedure
;; called by clicking on the start button
;; This procdure kicks off the go button and the graph button
;;
to start
startgobutton
startgraphbutton
end
7388 reads
