MIHS-18 P2 HB, SM, MF

No preview image

1 collaborator

Default-person Harry Matthews (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 28 times • Downloaded 3 times • Run 0 times
Download the 'MIHS-18 P2 HB, SM, MF ' 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-sheep ]
breed [ sheep a-sheep ]
breed [ wolves wolf ]
breed [ people person ]
turtles-own [ energy ]
patches-own [ countdown ]

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

  ifelse model-version = "sheep-wolves-people-grass" [
    ask patches [
      set pcolor one-of [ green brown ]
      ifelse pcolor = green
        [ set countdown grass-regrowth-time ]
      [ set countdown random grass-regrowth-time ]
    ]
  ]
  [
    ask patches [ set pcolor green ]
  ]

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

  create-wolves initial-number-wolves
  [
    set shape "wolf"
    set color black
    set size 2
    set energy random (2 * wolf-gain-from-food)
    setxy random-xcor random-ycor
  ]

  create-people initial-number-people
  [
    set shape "person"
    set color pink
    set size 2.5
    set energy random (2 * person-gain-from-food)
    setxy random-xcor random-ycor
  ]

  display-labels
  reset-ticks
end 

to go
  if not any? turtles [ stop ]
  ask sheep [
    move
    if model-version = "sheep-wolves-people-grass" [
      set energy energy - 1
      eat-grass
      death
    ]
    reproduce-sheep
  ]
  ask wolves [
    move
    set energy energy - 1
    eat-sheep
    death
    reproduce-wolves
  ]
  ask people [
    move
    set energy energy - 1
    eat-sheep
    eat-wolves
    death
    reproduce-people
  ]
  if model-version = "sheep-wolves-people-grass" [ ask patches [ grow-grass ] ]
  ; set grass count patches with [pcolor = green]
  tick
  display-labels
end 

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

to eat-grass  ; sheep procedure
  if pcolor = green [
    set pcolor brown
    set energy energy + sheep-gain-from-food
  ]
end 

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

to reproduce-wolves  ; wolf procedure
  if random-float 100 < wolf-reproduce [
    set energy (energy / 2)
    hatch 1 [ rt random-float 360 fd 1 ]
  ]
end 

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

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

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

to death
  if energy < 0 [ die ]
end 

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

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

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

There is only one version of this model, created 3 months ago by Harry Matthews.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.