Zombieland

No preview image

1 collaborator

Default-person Tom Clancys (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.3.1 • Viewed 156 times • Downloaded 7 times • Run 0 times
Download the 'Zombieland' 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

;; Zombieland Model

breed [human]
breed [zombie]

globals [
  percent-human  ;;Percentage of agents that are human.
  percent-zombie  ;;Percentage of agents that are zombies.
  ]

turtles-own [
  speed  ;;How fast the agents can move.
  zombie-near
  human-near
  scared?
  hungry?
  ]

to Setup  ;;Clear previous run and setup initial agent locations.
  __clear-all-and-reset-ticks
  pop-check
  setup-agents
end 

to go
  scared-check
  tick
end 

to setup-agents ;; Create the desired number of each breed on random patches.
  set-default-shape zombie "person"
  set-default-shape human "person"

  ask n-of initial-zombies patches
    [ sprout-zombie 1
      [ set color red ] ]

  ask n-of initial-humans patches
    [ sprout-human 1
      [ set color blue ] ]
end 

to scared-check ;; Test if humans are near a zombie and move them if they are.
  ask human [
    set zombie-near count (turtles-on neighbors) with [breed = zombie]
    set speed human-speed
    set scared? zombie-near >= 1
    ]
    ask human with [ scared? ]
      [ find-new-spot ]

  ask zombie [
    if any? other turtles-here
    [convert]
    set human-near count (turtles-on neighbors) with [breed = human]
    set speed zombie-speed
    set hungry? human-near >= 1
    ]
    ask zombie with [ hungry? ]
      [ seek-brains ]
    ask zombie with [not hungry?]
      [find-new-spot]
end 

to find-new-spot ;; Pick the patch the agent moves to.
    rt random-float 360
    fd random-float speed
    if any? other turtles-here
    [ convert]
end 

to convert
  ask turtles-on patch-here [set breed zombie]
  ask turtles-on patch-here [set color red]
end 

to seek-brains
end 

to pop-check  ;; Make sure total population does not exceed total number of patches.
  if initial-zombies + initial-humans > count patches
    [ user-message (word "This Zombieland only has room for " count patches " agents.")
      stop ]
end 

There is only one version of this model, created almost 8 years ago by Tom Clancys.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.