Virus
Model was written in NetLogo 6.1.0
•
Viewed 102 times
•
Downloaded 6 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
;; not sick = 0 ;; sick = 1 ;; immune = 2 turtles-own [isSick sickOn sickness-is-critical] globals [dead] to setup clear-all ask patches [ set pcolor white ] ;; create turtles create-turtles number-of-people [ setxy random-xcor random-ycor set color black set isSick 0 set sickOn -1 set size 0.5 ] ;; assign one random person to be sick ask turtle random number-of-people [ set isSick 1 set color red set sickOn 0 ] reset-ticks end to go ;; stop after 200 days if ticks > 200 [ stop ] ask turtles [ ifelse ticks > action-after-days [ ;; chance that any given turtle will move on a day if random 100 < chance-of-moving [ wiggle move ] ] [ wiggle move ] ;; if a person is sick, check to see if they will infect someone standing on top of them if isSick = 1 [ infect-others if sickness-is-critical = true and random 100 < 80 [ set dead dead + 1 die ] ] ;; if they have been sick for more than some days, they are immune if sickOn >= 0 and ticks > days-infected + sickOn [ set isSick 2 set color green ] ] ;; update the plots my-update-plots tick end to infect-others ;; if i'm standing on any other turtles, ask the turtle if they are not infected yet. ;; if they have not been infected yet, make them sick and keep track of what time they were sick if any? turtles-here [ let target one-of turtles-here ask target [ if isSick = 0 [ ;; around 5% of the cases are critical if random 100 < 5 [ set sickness-is-critical true ] set color red set isSick 1 set sickOn ticks ] ] ] end to wiggle ;; wiggle right random 90 left random 90 end to move ;; move forward fd 1 end to my-update-plots set-current-plot-pen "infected" plot count turtles with [isSick = 1] set-current-plot-pen "not infected" plot count turtles with [isSick = 0] set-current-plot-pen "immune" plot count turtles with [isSick = 2] set-current-plot-pen "dead" plot dead end
There are 3 versions of this model.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Virus.png | preview | Preview for 'Virus' | almost 4 years ago, by Mighty Chen | Download |
This model does not have any ancestors.
This model does not have any descendants.