SimpleZombie_v.1

No preview image

1 collaborator

Default-person Mohini Tellakat (Author)

Tags

(This model has yet to be categorized with any tags)
Child of model Zombie Apocalypse
Model group MAM-2013 | Visible to everyone | Changeable by the author
Model was written in NetLogo 5.0.4 • Viewed 200 times • Downloaded 17 times • Run 0 times
Download the 'SimpleZombie_v.1' 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

;;;;;;;;;;;;;;;;;;
;; Declarations ;;
;;;;;;;;;;;;;;;;;;

globals
[
  count-zombies
  count-humans 
  run-number
  ;; counter used to keep the model running for a little
  ;; while after the last turtle gets infected
  delay
  
]

breed [ humans human ]



;; infected? - checks to see whether a human is infected
;; energy - human energy level
;; affability - how friendly the human is (helps determine whether they will help others)
humans-own [ energy affability infected? friends nearest-neighbor ]


;;;;;;;;;;;;;;;;;;;;;
;; Setup Functions ;;
;;;;;;;;;;;;;;;;;;;;;

;; clears the plot too

to setup-clear
  clear-all
  set run-number 1
  setup-world
end 

;; note that the plot is not cleared so that data
;; can be collected across runs

to setup-keep
  clear-turtles
  clear-patches
  set run-number run-number + 1
  setup-world
end 

to setup-world
  set-default-shape humans "person"
 
  set delay 0
  create-some-humans
  reset-ticks
end 

to create-some-humans
  create-humans num-humans
  [
    setxy random-pxcor random-pycor   ;; put androids on patch centers
    set color gray
    set heading 90 * random 4
    set energy 20 
    set infected? false 
    set affability 1
    set count-humans num-humans
  ]
end 

to infect
  ask one-of humans [ initial-infect ]
end 



;;;;;;;;;;;;;;;;;;;;;;;
;; Runtime Functions ;;
;;;;;;;;;;;;;;;;;;;;;;;

to go
  humans-wander
  ask humans [
  infect-human
  human-death-natural
  cluster
  ]
  tick
end 



;; controls the motion of the humans

to humans-wander
  ask humans[ 
    rt (random 4) * 90 
    fd 1
    set energy energy - 0.7 ]
end 

to initial-infect  
  if not infected? [
    set infected? true 
    set color green
    set affability 0
    set energy 30 ]               
end 

to infect-human  
  if not infected? and (energy < 15) [
    set infected? true 
    set color green
    set affability 0
    set energy 30 ]
    ;;set count-zombies count-zombies + 1
    ;;set count-humans count-humans - 1 ]                
end 

to human-death-natural  
  if not infected? and (energy < 10) [
    die ]
   ;; set count-humans count-humans - 1]                        
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Clustering together ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;

to cluster  ;; turtle procedure
  ask humans with [not infected?] [
    let x self
    ask humans-on neighbors [
      if not infected? [
        let aff-h [affability] of self
        if affability >= aff-h [
          create-link-with x
        ]
        if affability < aff-h [
          avoid
        ]
      ]
    ]
  ]
end 

to avoid ;; android procedure
  let candidates patches in-radius 1 with [ not any? humans-here with [ infected? ] ]
  ifelse any? candidates
    [ face one-of candidates ]
    [ rt (random 4) * 90 ]
end 

There is only one version of this model, created almost 11 years ago by Mohini Tellakat.

Attached files

No files

Parent: Zombie Apocalypse

This model does not have any descendants.

Graph of models related to 'SimpleZombie_v.1'