ZombieApocalypse1
Model was written in NetLogo 5.2.0
•
Viewed 320 times
•
Downloaded 41 times
•
Run 0 times
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
globals [ safety-top ;variables for the government facility safety-bottom safety-left safety-right cross-top ;variables for the vertical red line on the government facility cross-bottom cross-left cross-right cross2-top ;variables for the horizontal red line on the government facility cross2-bottom cross2-left cross2-right worldcolors ] breed [HealthyPeople person] breed [Zombies zombie] breed [Immunity immune] breed [Hunters zombieHunter] to setup clear-all set worldcolors [ 63 62 ] ;list of colors for the world's green patches setupWorld ;function to setup world ;Initialize HealthyPeople in world set-default-shape HealthyPeople "person" create-HealthyPeople initial-number-people ;; create the HealthyPeople, then initialize their variables [ set color 137 set size 1.5 ;; easier to see setxy random-xcor random-ycor ] ;Initialize Zombies in world set-default-shape Zombies "person" create-Zombies initial-number-zombies ;; create the HealthyPeople, then initialize their variables [ set color 66 set size 1.5 ;; easier to see setxy random-xcor random-ycor ] ;Initialize Zombie Hunters in world set-default-shape Hunters "person" create-Hunters initial-number-zombie-hunters [ set color black set size 1.5 setxy random-xcor random-ycor ] reset-ticks end to setupWorld ask patches [ set pcolor one-of worldcolors ] ;color the green patches in the world set safety-top 12 ;initialize the x and y values for the government facility and red lines set safety-bottom 7 set safety-left 4 set safety-right 11 set cross-top 11 set cross-bottom 8 set cross-left 7 set cross-right 8 set cross2-top 10 set cross2-bottom 9 set cross2-left 6 set cross2-right 9 safetyZone end to go if not any? HealthyPeople [ stop ] ;stop the program if there are only Immune and Zombies left if not any? Zombies [ stop ] ask HealthyPeople [ ;Run procedures for HealthyPeople move checkSafety ] ask Zombies [ ;Run procedures for Zombies move catchPerson catchHunter ] ask Immunity [ ;Run procedures for immune people move ] ask Hunters [ ;Run procedures for Zombie Hunters move catchZombies ] tick end to safetyZone ;Color patches for the government facility and red lines ask patches [ if (pycor <= safety-top and pycor >= safety-bottom) and (pxcor >= safety-left and pxcor <= safety-right) [ set pcolor 7 ] if (pycor <= cross-top and pycor >= cross-bottom) and (pxcor >= cross-left and pxcor <= cross-right) [ set pcolor 15 ] if (pycor <= cross2-top and pycor >= cross2-bottom) and (pxcor >= cross2-left and pxcor <= cross2-right) [ set pcolor 15 ] ] end to move ;Movement for HealthyPeople, Zombies, and Immunity breeds rt random 360 fd 1 end to checkSafety ;Procedure for HealthyPeople if pcolor = 7 or pcolor = 15 ;If the HealthyPeople are at the government facility, they become immune [ set breed Immunity set shape "person" set color 47 set size 1.5 ] end to catchPerson ;Procedure for Zombies let prey one-of HealthyPeople-here if prey != nobody and random 100 < humanInfectionRate ;If the zombie has found a person and the infection rate is within range, the person becomes a zombie [ ask prey [ set breed Zombies set color 66 ] ] end to catchHunter ;Procedure for Zombies let prey one-of Hunters-here if prey != nobody and random 100 < hunterInfectionRate ;If the zombie has found a hunter and the infection rate is within range, the hunter becomes a zombie [ ask prey [ set breed Zombies set color 66 ] ] end to catchZombies let prey one-of Zombies if prey != nobody and random 100 < zombie-hunter-effective-rate [ ask prey [ die ] ] end
There are 2 versions of this model.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
ZombieApocalypse1.png | preview | Preview for 'ZombieApocalypse1' | almost 10 years ago, by Jennifer Dana-Farley | Download |
This model does not have any ancestors.
This model does not have any descendants.