Zombieland
Model was written in NetLogo 5.0.4
•
Viewed 396 times
•
Downloaded 28 times
•
Run 0 times
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[] patches-own[] turtles-own[] breed[zombies zombie] breed[mortals mortal] to setup clear-all ask patches [ if(pxcor mod 15 = 0 or pycor mod 20 = 0 )[ ask neighbors[set pcolor gray] set pcolor gray ] ] zombieSetup mortalsSetup reset-ticks end to go ask zombies[attack] ask mortals[avoid] tick end ;;Breeds Movement Functions to attack if(zombiePen = true)[pen-down] killIfAnyNear ifelse (any? mortals in-radius zombieVision)[headTowardsMortal][headRandom] forward zombiesSpeed + (random randomnessInzombiesSpeed) * zombiesSpeed end to avoid let zombieAround other zombies in-cone mortalVision mortalVisionAngle ifelse any? zombieAround[runaway][moveHappily] end ;;Zombies Movement Functions to headTowardsMortal set heading (towards min-one-of mortals [distance myself]) + randomAngleRange randomnessInzombiesDirection moveTowardsValidPatch (zombiesSpeed + (random randomnessInzombiesSpeed) * zombiesSpeed) black 90 end to headRandom right randomAngleRange 10 moveTowardsValidPatch (zombiesSpeed + (random randomnessInzombiesSpeed) * zombiesSpeed) black 10 end ;;Mortals Movement Functions to runaway set shape "face neutral" set color yellow set heading (towards min-one-of zombies [distance myself]) + 180 moveTowardsValidPatch (mortalSpeed + mortalSpeed * mortalRunawaySpeedMultiplier) black 90 forward mortalSpeed + mortalSpeed * mortalRunawaySpeedMultiplier end to moveHappily set shape "face happy" set color green right randomAngleRange 10 moveTowardsValidPatch (mortalSpeed) black 10 forward mortalSpeed end ;;Auxiliary to-report patchAheadIsInvalid[distanceOfMovement forbiddenColor] ifelse([pcolor] of patch-ahead distanceOfMovement = forbiddenColor)[report true][report false] end to moveTowardsValidPatch[distanceOfMovement forbiddenColor randomRange] if(patchAheadIsInvalid distanceOfMovement forbiddenColor)[while[patchAheadIsInvalid distanceOfMovement forbiddenColor][right randomAngleRange randomRange]] end to-report randomAngleRange[range] report random range - random range end to getSick set breed zombies set color red set size 2 set shape "x" end to killIfAnyNear if any? mortals in-radius zombieKillingRange[ ifelse contagious [ ask mortals in-radius zombieKillingRange[getSick] ][ ask mortals in-radius zombieKillingRange[die] ] ] end ;;Setup Functions to zombieSetup create-zombies zombiePopulation[ set color red set size 2 set shape "x" setxy random-xcor random-ycor while[pcolor = black][setxy random-xcor random-ycor] ] end to mortalsSetup create-mortals mortalPopulation[ set color green set size 2 set shape "face happy" setxy random-xcor random-ycor while[pcolor = black][setxy random-xcor random-ycor] ] end
There is only one version of this model, created over 11 years ago by Héctor Sanchez.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Zombieland.png | preview | Preview for 'Zombieland' | over 11 years ago, by Héctor Sanchez | Download |
This model does not have any ancestors.
This model does not have any descendants.