Carson,Ben Bio Coding
No preview image
Model was written in NetLogo 6.0.2
•
Viewed 111 times
•
Downloaded 10 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Info tab cannot be displayed because of an encoding error
Comments and Questions
Please start the discussion about this model!
(You'll first need to log in.)
Click to Run Model
globals [ max-Fishes ] ; don't let Fishes population grow too large ; Fishes and wolves are both breeds of turtle. breed [ Fishes Fish ] ; Fishes is its own plural, so we use "a-Fishes" as the singular. breed [ Wolves Wolf ] breed [peoples people] turtles-own [ energy ] ; both wolves and Fishes have energy patches-own [ countdown ] to setup clear-all ifelse netlogo-web? [set max-Fishes 10000] [set max-Fishes 30000] ; Check model-version switch ; if we're not modeling grass, then the Fishes don't need to eat to survive ; otherwise the grass's state of growth and growing logic need to be set up ifelse model-version = "Fishes-Turtles-grass-people" [ ask patches [ set pcolor one-of [ 52 105 ] ifelse pcolor = 52 [ set countdown grass-regrowth-time ] [ set countdown random grass-regrowth-time ] ; initialize grass regrowth clocks randomly for 105 patches ] ] [ ask patches [ set pcolor Blue ] ] create-Fishes initial-number-Fishes ; create the Fishes, then initialize their variables [ set shape "Fish" set color 45 set size 2 ; easier to see set label-color blue - 2 set energy random (2 * Fishes-gain-from-food) setxy random-xcor random-ycor ] create-peoples initial-number-people ; create the wolves, then initialize their variables [ set shape "person" set color 135 set size 4 ; easier to see set energy random (2 * peoples-gain-from-food) setxy random-xcor random-ycor ] create-wolves initial-number-Turtles ; create the wolves, then initialize their variables [ set shape "Turtle" set color 72 set size 3 ; easier to see set energy random (2 * Turtles-gain-from-food) setxy random-xcor random-ycor ] display-labels reset-ticks end to go ; stop the simulation of no wolves or Fishes if not any? turtles [ stop ] ; stop the model if there are no wolves and the number of Fishes gets very large if not any? Turtles and count Fishes > max-Fishes [ user-message "The Fish have inherited the earth" stop ] ask Fishes [ move if model-version = "Fishes-Turtles-grass-people" [ ; in this version, Fishes eat grass, grass grows and it costs Fishes energy to move set energy energy - 1 ; deduct energy for Fishes only if running Fishes-wolf-grass model version eat-grass ; Fishes eat grass only if running Fishes-wolf-grass model version death ; Fishes die from starvation only if running Fishes-wolf-grass model version ] reproduce-Fishes ; Fishes reproduce at random rate governed by slider ] ask wolves [ move set energy energy - 1 ; wolves lose energy as they move eat-Fishes ; wolves eat a Fishes on their patch death ; wolves die if our of energy reproduce-Turtles ; wolves reproduce at random rate governed by slider ] ask peoples [ move set energy energy - 1 ; wolves lose energy as they move eat-wolves ; wolves eat a Fishes on their patch death ; wolves die if our of energy reproduce-people ; wolves reproduce at random rate governed by slider ] if model-version = "Fishes-Turtles-grass-people" [ ask patches [ grow-Grass ] ] ; set grass count patches with [pcolor = 52] tick display-labels if model-version = "Fishes-Turtles-grass-people" [ ask patches [ grow-Grass ] ] ; set grass count patches with [pcolor = 52] tick display-labels end to move ; turtle procedure rt random 50 lt random 50 fd 1 end to eat-grass ; Fishes procedure ; Fishes eat grass, turn the patch 105 if pcolor = 52 [ set pcolor 105 set energy energy + Fishes-gain-from-food ; Fishes gain energy by eating ] end to reproduce-Fishes ; Fishes procedure if random-float 100 < Fishes-reproduce [ ; throw "dice" to see if you will reproduce set energy (energy / 2) ; divide energy between parent and offspring hatch 1 [ rt random-float 360 fd 1 ] ; hatch an offspring and move it forward 1 step ] end to reproduce-Turtles ; wolf procedure if random-float 100 < Turtles-reproduce [ ; throw "dice" to see if you will reproduce set energy (energy / 2) ; divide energy between parent and offspring hatch 1 [ rt random-float 360 fd 1 ] ; hatch an offspring and move it forward 1 step ] end to reproduce-people ; wolf procedure if random-float 100 < people-reproduce [ ; throw "dice" to see if you will reproduce set energy (energy / 2) ; divide energy between parent and offspring hatch 1 [ rt random-float 360 fd 1 ] ; hatch an offspring and move it forward 1 step ] end to eat-wolves ; wolf procedure let prey one-of wolves-here ; grab a random Fishes if prey != nobody [ ; did we get one? if so, ask prey [ die ] ; kill it, and... set energy energy + peoples-gain-from-food ; get energy from eating ] end to eat-Fishes ; wolf procedure let prey one-of Fishes-here ; grab a random Fishes if prey != nobody [ ; did we get one? if so, ask prey [ die ] ; kill it, and... set energy energy + Turtles-gain-from-food ; get energy from eating ] end to death ; turtle procedure (i.e. both wolf nd Fishes procedure) ; when energy dips below zero, die if energy < 0 [ die ] end to grow-grass ; patch procedure ; countdown on 105 patches: if reach 0, grow some grass if pcolor = 105 [ ifelse countdown <= 0 [ set pcolor 52 set countdown grass-regrowth-time ] [ set countdown countdown - 1 ] ] end to-report grass ifelse model-version = "Fishes-Turtles-grass-people" [ report patches with [pcolor = 52] ] [ report 0 ] end to display-labels ask turtles [ set label "" ] if show-energy? [ ask Turtles [ set label round energy ] if model-version = "Fishes-Turtles-grass-people" [ ask Fishes [ set label round energy ] ] ] end ; Copyright 1997 Uri Wilensky. ; See Info tab for full copyright and license.
There is only one version of this model, created about 6 years ago by Bob Ross.
Attached files
No files
This model does not have any ancestors.
This model does not have any descendants.