Infection Dynamics - Practice
No preview image
Model was written in NetLogo 6.4.0
•
Viewed 3 times
•
Downloaded 0 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 [ trail_count total_infected max_infected total_healed_by_doctors hospital_capacity ] turtles-own [ infected_time recovered_time reinfected? reinfected_for in_hospital_lock? will_go_to_hospital? ] breed [doctors doctor] to-report in_hospital? report [pcolor] of patch-here = pink end to setup clear-all set trail_count 0 set total_infected 1 set max_infected 1 set total_healed_by_doctors 0 set hospital_capacity 5 ask patches [ set pcolor blue + 4.9] ; set hospital zone ask patches with [ pxcor > max-pxcor - 5 and pycor > max-pycor - 5] [set pcolor pink ] ; Mark hospital area with a big H ask patches with [ pxcor > max-pxcor - 3 and pxcor < max-pxcor - 1 and pycor > max-pycor - 3 and pycor < max-pycor - 1 ] [ set plabel "H" set plabel-color black ] create-turtles 30 [ setxy random-xcor random-ycor set color blue set infected_time 0 set recovered_time 0 set reinfected? false set reinfected_for 0 set in_hospital_lock? false set will_go_to_hospital? false ] ask n-of 5 turtles [ set color red set infected_time 1 ] create-doctors 2 [ setxy random-xcor random-ycor set color orange + 1 set size 1.3 set label "Doctor" set label-color black ] reset-ticks end to go ;main turtle logic ask turtles with [not member? self doctors ] [ ;infection logic if color = red [ let nearby-turtles turtles in-radius 1 with [color = blue] ask nearby-turtles [ set color red set infected_time 0 set total_infected total_infected + 1 set will_go_to_hospital? (random-float 1.0 < 0.2) ] ] ;Recovery logic set infected_time infected_time + 1 if in_hospital? [ set infected_time infected_time + 2 ] ; faster recovery in hospital if infected_time > recovery_time and color = red [ set color green set recovered_time 0 set in_hospital_lock? false ] ;Reinfection logic if color = green [ set recovered_time recovered_time + 1 if recovered_time > reinfection_delay and not reinfected? [ set color cyan ; flash color to highlight reinfection set label "Lost Immunity" ; showing label set label-color black set reinfected? true set reinfected_for 25 ; flash will last for 25 ticks set size 2 ; make the turtle stand out ] ] ; maintain flash for a few ticks if reinfected? and reinfected_for > 0 [ set reinfected_for reinfected_for - 1 ] ; end flash, reset to blue if reinfected? and reinfected_for = 0 [ set color blue set infected_time 0 set label "" set reinfected? false set size 1 ; reset to previous size ] ; hospital entry logic if color = red and will_go_to_hospital? and not in_hospital? and not in_hospital_lock? [ if xcor = max-pxcor - 5 and ycor >= max-pycor - 5 [ if count turtles with [ color = red and in_hospital_lock? ] < hospital_capacity [ facexy max-pxcor - 3 max-pycor - 3 forward 1 ] ] ] ; lock turtle when it get inside hospital if color = red and in_hospital? and will_go_to_hospital? and not in_hospital_lock? [ if count turtles with [color = red and in_hospital_lock?] < hospital_capacity [ set in_hospital_lock? true ] ] ; lock movement if inside hospital and infected if in_hospital_lock? [ if not in_hospital? [ facexy max-pxcor - 3 max-pycor - 3 forward 1 ] ] ; block healthy turtles from entering hospital if (color != red and in_hospital?) [ rt 180 forward 1 ] ;movement logic forward movement_speed rt random 50 lt random 50 if color = green and in_hospital? [ rt 180 forward 1 ] ] ;update max infected count let current_infected count turtles with [color = red ] if current_infected > max_infected [ set max_infected current_infected ] ; Doctors logic ask doctors [ let nearby_infected turtles in-radius 1 with [color = red] ask nearby_infected [ set color green set total_healed_by_doctors total_healed_by_doctors + 1 ] ; doctor movement forward 1 rt random 30 lt random 30 ] tick end
There is only one version of this model, created 1 day ago by Mohammad Mustafa.
Attached files
No files
This model does not have any ancestors.
This model does not have any descendants.