MIHS-18 P2 Max Fischel

No preview image

1 collaborator

Default-person Max Fischel (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 86 times • Downloaded 11 times • Run 0 times
Download the 'MIHS-18 P2 Max Fischel' 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-person  ]
breed [ person a-person ]
breed [ wolves wolf ]
turtles-own [ energy ]
patches-own [ countdown ]

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


  ifelse model-version = "sheep-wolves-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 blue ]
  ]

  create-person initial-number-sheep  ;
  [
    set shape  "person"
    set color yellow
    set size 1.65  ; easier to see
    set label-color blue - 2
    set energy random (2 * person-gain-from-food)
    setxy random-xcor random-ycor
  ]

  create-wolves initial-number-wolves
  [
    set shape "wolf"
    set color brown
    set size 1.88
    set energy random (2 * wolf-gain-from-food)
    setxy random-xcor random-ycor
  ]
  display-labels
  reset-ticks
end 

to go

  if not any? turtles [ stop ]

  if not any? wolves and count person > max-person [ user-message "The people have taken over the earth" stop ]
  ask person [
    move
    if model-version = "sheep-wolves-grass" [
      set energy energy - 1
      eat-grass
      death
    ]
    reproduce-person
  ]
  ask wolves [
    move
    set energy energy - 1
    eat-person
    death
    reproduce-wolves
  ]
  if model-version = "person-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 = green [
    set pcolor brown
    set energy energy + person-gain-from-food
  ]
end 

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

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

to eat-person
  let prey one-of person-here
  if prey != nobody  [
    ask prey [ die ]
    set energy energy + wolf-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 = "person-wolves-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 = "person-wolves-grass" [ ask person [ set label round energy ] ]
  ]
end 


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

There is only one version of this model, created over 5 years ago by Max Fischel.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.