MIHS-18 Dylan L Hunter E Ava M

No preview image

1 collaborator

Default-person Dylan Lim (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.0.2 • Viewed 35 times • Downloaded 1 time • Run 0 times
Download the 'MIHS-18 Dylan L Hunter E Ava M' 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-fireflies ]
breed [ fireflies firefly ]
breed [ bats bat ]
turtles-own [ energy ]
patches-own [ countdown ]

to setup
  clear-all
  ifelse netlogo-web? [set max-fireflies 10000] [set max-fireflies 30000]
  ifelse model-version = "sheep-wolves-grass" [
    ask patches [
      set pcolor one-of [ black black ]
      ifelse pcolor = black
        [ set countdown grass-regrowth-time ]
      [ set countdown random grass-regrowth-time ]
    ]
  ]
  [
    ask patches [ set pcolor green ]
  ]

  create-fireflies initial-number-fireflies
  [
    set shape  "butterfly"
    set color white
    set size 1.5
    set label-color blue - 2
    set energy random (2 * firefly-gain-from-food)
    setxy random-xcor random-ycor
  ]

  create-bats initial-number-bats
  [
    set shape "bird"
    set color black
    set size 2
    set energy random (2 * bat-gain-from-food)
    setxy random-xcor random-ycor
  ]
  display-labels
  reset-ticks
end 

to go
  if not any? turtles [ stop ]
  if not any? bats and count fireflies > max-fireflies [ user-message "The fireflies have inherited the earth" stop ]
  ask fireflies [
    move
    if model-version = "sheep-wolves-grass" [
      set energy energy - 1
      eat-grass
      death
    ]
    reproduce-sheep
  ]
  ask bats [
    move
    set energy energy - 1
    eat-sheep
    death
    reproduce-bats
  ]
  if model-version = "sheep-wolves-grass" [ ask patches [ grow-grass ] ]
  tick
  display-labels
end 

to move
  rt random 50
  lt random 50
  fd 1
end 

to eat-grass
  if pcolor = black [
    set pcolor black
    set energy energy + firefly-gain-from-food
  ]
end 

to reproduce-sheep
  if random-float 100 < firefly-reproduce [
    set energy (energy / 2)
    hatch 1 [ rt random-float 360 fd 1 ]
  ]
end 

to reproduce-bats
  if random-float 100 < bat-reproduce [
    set energy (energy / 2)
    hatch 1 [ rt random-float 360 fd 1 ]
  ]
end 

to eat-sheep
  let prey one-of fireflies-here
  if prey != nobody  [
    ask prey [ die ]
    set energy energy + bat-gain-from-food
  ]
end 

to death
  if energy < 0 [ die ]
end 

to grow-grass
  if pcolor = brown [
    ifelse countdown <= 0
      [ set pcolor black
        set countdown grass-regrowth-time ]
      [ set countdown countdown - 1 ]
  ]
end 

to-report grass
  ifelse model-version = "sheep-wolves-grass" [
    report patches with [pcolor = black]
  ]
  [ report 0 ]
end 

to display-labels
  ask turtles [ set label "" ]
  if show-energy? [
    ask bats [ set label round energy ]
    if model-version = "sheep-wolves-grass" [ ask fireflies [ set label round energy ] ]
  ]
end 

There is only one version of this model, created 4 months ago by Dylan Lim.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.