Final Program Tutorial 3

Final Program Tutorial 3 preview image

1 collaborator

Default-person Colleen Moore (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.2.2 • Viewed 221 times • Downloaded 27 times • Run 0 times
Download the 'Final Program Tutorial 3' modelDownload this modelEmbed this model

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


DEVELOPER NAME AND DATE

Colleen Moore. 9/28/22

WHAT IS IT?

This model shows a simple interaction between turtles and grass.

HOW IT WORKS

The turtles move around randomly and the grass grows randomly. When a turtle comes to grass, it consumes it. If the turtle has enough energy, it reproduces. If the turtle doesn't have enough enerfy, it dies.

HOW TO USE IT

Click the 'setup' button to setup the turtles and the patches of grass. Click the 'go' button to start the model. The 'show-energy?' switch allows the user to display/not display the turtles energy. The 'number' slider controls the initial number of turtles. The 'energy-from-grass' slider controls the amount of energy a turtle gain and lose as they eat grass. The 'birth-energy' slider controls the amount of energy the turtles gain and lose as they reproduce. The 'number-of-ticks' slider controls the number of ticks for for once the model reaches that number, the simulation stops. The 'grass-regrowth-rate' slider controls the rate at which the patches of grass regrow. The 'energy-to-move' slider controls the energy required for the turtles to move.

THINGS TO NOTICE

Pay attention to the 'count turtles' and 'green patches' monitors to to see how the turtle and grass populations change over time. You should also observe the 'Average Energy' and 'Totals' plots to see the average energy of the turtles as well as the total number of turtles and total number of patches throughout the simulation.

RELATED MODELS

Rabbits Grass Weeds is another interactive model with similar perameters.

CREDITS AND REFERENCES

Moore, C. Final Program #3 (2022) (a reference to the model's URL on the web if it has one, as well as any other necessary credits, citations, and links)

Comments and Questions

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

Click to Run Model

turtles-own [energy]     ;; for keeping track of when the turtle is ready
                         ;; to reproduce and when it will die

to setup
  clear-all
  setup-patches
  setup-turtles
  reset-ticks
end 

to setup-patches
  ask patches [ set pcolor green ]
end 

to setup-turtles
  create-turtles number       ;; uses the value of the number slider to create turtles
  ask turtles [ setxy random-xcor random-ycor ]
end 

to go
  if ticks >= number-of-ticks [ stop ]  ;; stop after user defined # of ticks
  if not any? turtles [ stop ]      ;; stops if number of turtles reaches 0
  move-turtles
  eat-grass
  check-depth
  reproduce
  regrow-grass
  tick      ;; increase the tick counter by 1 each time through
end 

to move-turtles
  ask turtles [
    right random 360
    forward 1
    set energy energy - energy-to-move     ;; when the turtle moves it looses the user defined amount of energy
  ]
end 

to eat-grass
  ask turtles [
    if pcolor = green [
      set pcolor black       ;; the value of birth-energy slider is added to energy
      set energy birth-energy
    ]
    ifelse show-energy?
      [ set label energy ]      ;; the label is set to be the value of the energy
      [ set label "" ]          ;; the label is set to an empty text value
  ]
end 

to reproduce
  ask turtles [
    if energy > birth-energy [
      set energy energy - birth-energy      ;; take away birth-energy to give birt
      hatch 1 [ set energy birth-energy ]   ;; give this birth-energy to the offspring
    ]
  ]
end 

to check-depth
  ask turtles [
    if energy <= 0 [ die ]      ;; removes the turtle if it has no energy left
  ]
end 

to regrow-grass
  ask patches [
    if random 100 < grass-regrowth-rate [ set pcolor green ]      ;; each patch has a random chance of growing grass
  ]                                                               ;; based on the grass-regrowth-rate set by user
end 

There is only one version of this model, created almost 3 years ago by Colleen Moore.

Attached files

File Type Description Last updated
Final Program Tutorial 3.png preview Preview for 'Final Program Tutorial 3' almost 3 years ago, by Colleen Moore Download

This model does not have any ancestors.

This model does not have any descendants.