Lamprey and Trout modeling

Lamprey and Trout modeling preview image

1 collaborator

Default-person Aryan Chandra (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 6.0.2 • Viewed 177 times • Downloaded 24 times • Run 0 times
Download the 'Lamprey and Trout modeling' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

globals [ max-trouts ]  ; don't let trouts population grow too large
; trouts and lampreys are both breeds of turtle.
breed [ trouts a-trouts ]  ; trouts is its own plural, so we use "a-trouts" as the singular.
breed [ lampreys a-lampreys ]
turtles-own [ energy ]       ; both lampreys and trouts have energy
patches-own [ countdown ]

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

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

  create-trouts initial-number-trouts  ; create the trouts, then initialize their variables
  [
    set shape  "fish"
    set color white
    set size 1.5  ; easier to see
    set label-color blue - 2
    set energy random (2 * trouts-gain-from-food)
    setxy random-xcor random-ycor
  ]

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

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

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

to eat-plankton  ; trouts procedure
  ; trouts eat plankton, turn the patch brown
  if pcolor = green [
    set pcolor brown
    set energy energy + trouts-gain-from-food  ; trouts gain energy by eating
  ]
end 

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

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

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

to-report plankton
  ifelse model-version = "trouts-lampreys-plankton" [
    report patches with [pcolor = green]
  ]
  [ report 0 ]
end 

to display-labels
  ask turtles [ set label "" ]
  if show-energy? [
    ask lampreys [ set label round energy ]
    if model-version = "trouts-lampreys-plankton" [ ask trouts [ set label round energy ] ]
  ]
end 


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

There are 4 versions of this model.

Uploaded by When Description Download
Aryan Chandra over 6 years ago changing info Download this version
Aryan Chandra over 6 years ago changing info Download this version
Aryan Chandra over 6 years ago changing info Download this version
Aryan Chandra over 6 years ago Initial upload Download this version

Attached files

File Type Description Last updated
Lamprey and Trout modeling.png preview Preview for 'Lamprey and Trout modeling' over 6 years ago, by Aryan Chandra Download

This model does not have any ancestors.

This model does not have any descendants.