MIHS-18P2 caseyellakillian tortles coral garbage

No preview image

1 collaborator

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.0.4 • Viewed 31 times • Downloaded 3 times • Run 0 times
Download the 'MIHS-18P2 caseyellakillian tortles coral garbage' modelDownload this modelEmbed this model

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-tortles ]  ; don't let tortle population grow too large
; tortle and trash are both breeds of turtle.
breed [ tortles tortle ]  ; tortle is its own plural, so we use "a-tortle" as the singular.
breed [ trash a-trash ]
turtles-own [ energy ]       ; both trash and tortle have energy
patches-own [ countdown ]

to setup
  clear-all
  ifelse netlogo-web? [set max-tortles 10000] [set max-tortles 30000]

  ; Check model-version switch
  ; if we're not modeling coral, then the tortle don't need to eat to survive
  ; otherwise the coral's state of growth and growing logic need to be set up
  ifelse model-version = "tortles-trash-coral" [
    ask patches [
      set pcolor one-of [ pink blue ]
      ifelse pcolor = blue
        [ set countdown coral-regrowth-time ]
      [ set countdown random coral-regrowth-time ] ; initialize coral regrowth clocks randomly for blue patches
    ]
  ]
  [
    ask patches [ set pcolor pink ]
  ]

  create-tortles initial-number-tortles  ; create the tortle, then initialize their variables
  [
    set shape  "turtle"
    set color 52
    set size 5  ; easier to see
    set label-color blue - 2
    set energy random (2 * tortles-gain-from-food)
    setxy random-xcor random-ycor
  ]

  create-trash initial-number-trash  ; create the trash, then initialize their variables
  [
    set shape "garbage can"
    set color gray
    set size 4  ; easier to see
    set energy random (2 * trash-gain-from-food)
    setxy random-xcor random-ycor
  ]
  display-labels
  reset-ticks
end 

to go
  ; stop the simulation of no trash or tortle
  if not any? turtles [ stop ]
  ; stop the model if there are no trash and the number of tortle gets very large
  if not any? trash and count tortles > max-tortles [ user-message "The tortle have inherited the earth" stop ]
  ask tortles [
    move
    if model-version = "tortles-trash-coral" [ ; in this version, tortle eat coral, coral grows and it costs tortle energy to move
      set energy energy - 1  ; deduct energy for tortle only if running tortle-trash-coral model version
      eat-coral  ; tortle eat coral only if running tortle-trash-coral model version
      death ; tortle die from starvation only if running tortle-trash-coral model version
    ]
    reproduce-tortles  ; tortle reproduce at random rate governed by slider
  ]
  ask trash [
    move
    set energy energy - 1  ; trash lose energy as they move
    eat-tortles ; trash eat a tortle on their patch

  ]
  if not any? tortles [ user-message "congrats you killed them all. https://www.seeturtles.org/billion-baby-turtles-donations/" stop ]
  if model-version = "tortles-trash-coral" [ ask patches [ grow-coral ] ]
  ; set coral count patches with [pcolor = pink]
  tick
  display-labels
end 

to move  ; turtle procedure
  rt random 50
  lt random 50
  fd 1
end 

to eat-coral  ; tortle procedure
  ; tortle eat coral, turn the patch blue
  if pcolor = pink [
    set pcolor blue
    set energy energy + tortles-gain-from-food  ; tortle gain energy by eating
  ]
end 

to reproduce-tortles  ; tortle procedure
  if random-float 100 < tortles-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-trash  ; trash procedure
  if random-float 100 < trash-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-tortles  ; trash procedure
  let prey one-of tortles-here                    ; grab a random tortle
  if prey != nobody  [                          ; did we get one?  if so,
    ask prey [ die ]                            ; kill it, and...
    set energy energy + trash-gain-from-food     ; get energy from eating
  ]
end 

to death  ; turtle procedure (i.e. both trash nd tortle procedure)
  ; when energy dips below zero, die
  if energy < 0 [ die ]
end 

to grow-coral  ; patch procedure
  ; countdown on blue patches: if reach 0, grow some coral
  if pcolor = blue [
    ifelse countdown <= 0
      [ set pcolor pink
        set countdown coral-regrowth-time ]
      [ set countdown countdown - 1 ]
  ]
end 

to-report coral
  ifelse model-version = "tortles-trash-coral" [
    report patches with [pcolor = pink]
  ]
  [ report 0 ]
end 

to display-labels
  ask turtles [ set label "" ]
  if show-energy? [
    ask trash [ set label round energy ]
    if model-version = "tortle-trash-coral" [ ask tortles [ set label round energy ] ]
  ]
end 


; Copyright 1997 Uri Wilensky.
; See Info tab for full copyright and license.

There are 2 versions of this model.

Uploaded by When Description Download
casey ella killian hh 3 months ago we fixed it Download this version
casey ella killian hh 3 months ago Initial upload Download this version

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.