Virus
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
WHAT IS IT?
(a general understanding of what the model is trying to show or explain)
HOW IT WORKS
(what rules the agents use to create the overall behavior of the model)
HOW TO USE IT
(how to use the model, including a description of each of the items in the Interface tab)
THINGS TO NOTICE
(suggested things for the user to notice while running the model)
THINGS TO TRY
(suggested things for the user to try to do (move sliders, switches, etc.) with the model)
EXTENDING THE MODEL
(suggested things to add or change in the Code tab to make the model more complicated, detailed, accurate, etc.)
NETLOGO FEATURES
(interesting or unusual features of NetLogo that the model uses, particularly in the Code tab; or where workarounds were needed for missing features)
RELATED MODELS
(models in the NetLogo Models Library and elsewhere which are of related interest)
CREDITS AND REFERENCES
(a reference to the model's URL on the web if it has one, as well as any other necessary credits, citations, and links)
Comments and Questions
;; 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' | over 5 years ago, by Mighty Chen | Download |
This model does not have any ancestors.
This model does not have any descendants.