Unhappy Zombie seeking brains to eat
In this version, the Zombies actively seek Humans that they detect within their vision range. Conversely, Humans actively run away from Zombies that they detect in their vision range.
A video overview of the model can be found on my YouTube Channel - Complxity Geek.
powered by NetLogo
A working copy of the model can be downloaded from My Google Drive.
WHAT IS IT?
Zombies!!
HOW IT WORKS
Eat Brains!!!
HOW TO USE IT
Push setup to get ready to eat brains!
Set speed for Humans and Zombies.
Set vision radius for Humans and Zombies.
Push Go to eat brains!
THINGS TO NOTICE
Zombies now seek brains and Humans run away if the see a zombie
near them.
Modified the movement code to smooth the motion of agents.
THINGS TO TRY
Start with just 1 zombie. Slow Zombies will eventually catch faster humans.
EXTENDING THE MODEL
Guns for Humans! Buildings! Super Zombies!
NETLOGO FEATURES
Still working on this.
RELATED MODELS
None that I know of.
CREDITS AND REFERENCES
Michael Ball, Research Coordinator, Computational Modeling & IT Resources at The Center for Complexity in Health - KSUA
PROCEDURES
;; Zombieland Model ver 1.2 - a basic simulation of a zombie attack with seek and flee ;; functions for agents. Movement speed and vision radius are also adjustable. breed [human] ;;The poor sods that are getting eaten. breed [zombie] ;;Brains!!!!!!!!! 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. scared ;;Agent-subset consisting of zombies within vision radius of a single human. brains ;;Agent-subset consisting of humans within vision radius of a single zombie. nearest-brains ;;Variable that holds the target human for a single zombie. nearest-zombie ;;Variable that holds the target zombie for a single human. turn-check ;;Holds the random variable for the wander sub-routine. ] to Setup ;;Clear previous run and setup initial agent locations. clear-all pop-check setup-agents end to go ;;Run the simulation. scared-check repeat human-speed [ ask human [ fd 0.2 ] display ] ;;Controls the speed of humans and zombies repeat zombie-speed [ ask zombie [ fd 0.2 ] display ] ;;and smooths the motion in simulation. 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 have them run away if they are. ask human [ zombies-near ifelse any? scared [run-away] [wander] ] ;; Test if zombies are near a human and have them chase them if they are. ask zombie [ if any? other turtles-here [convert] seek-brains ifelse any? brains [run-toward] [wander] ] end to wander ;; If an agent is not fleeing or chasing, have them wander around aimlessly. set turn-check random 20 if turn-check > 15 [right-turn] if turn-check < 5 [left-turn] ask zombie [ if any? other turtles-here [ convert] ] end to right-turn ;;Generate a random degree of turn for the wander sub-routine. rt random-float 10 end to left-turn ;;Generate a random degree of turn for the wander sub-routine. lt random-float 10 end to convert ;;When a zombie lands on patch occupied by human, eat brains and turn human into zombie. ask turtles-on patch-here [set breed zombie] ask turtles-on patch-here [set color red] end to zombies-near ;;adds all zombies in vision radius of human to an agent subset for that agent. set scared zombie in-radius human-vision end to run-away ;;Make human flee the zombie closest to it. set nearest-zombie min-one-of scared [distance myself] face nearest-zombie rt 180 end to seek-brains ;;adds all humans in vision radius of zombie to an agent subset for that agent. set brains human in-radius Zombie-vision end to run-toward ;;Make a zombie chasse the human closest to it. set nearest-brains min-one-of brains [distance myself] face nearest-brains if any? other turtles-here [convert] 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 ; *** NetLogo 4.1 Model Copyright Notice *** ; ; Copyright 2010 by Michael D. Ball. All rights reserved. ; ; Permission to use, modify or redistribute this model is hereby granted, ; provided that both of the following requirements are followed: ; a) this copyright notice is included. ; b) this model will not be redistributed for profit without permission ; from Michael D. Ball. ; Contact Michael D. Ball for appropriate licenses for redistribution for ; profit. ; ; To refer to this model in academic publications, please use: ; Ball, M. (2010). Zombieland Model ver. 1.2. ; http://www.personal.kent.edu/~mdball/netlogo_models.html. ; KSUAC Center for Complexity in Health, ; Kent State University at Ashtabula, Ashtabula, OH. ; ; In other publications, please use: ; Copyright 2010 Michael D. Ball. All rights reserved. ; See http://www.personal.kent.edu/~mdball/netlogo_models.html ; for terms of use. ; ; *** End of NetLogo 4.1 Model Copyright Notice ***