Covid-19_1

Covid-19_1 preview image

This model is seeking new collaborators — would you please help?

1 collaborator

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.1.1 • Viewed 144 times • Downloaded 4 times • Run 0 times
Download the 'Covid-19_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

globals [Allowed lock-down-period-count Alternate-condition original-condition infected-and-cured]
;extensions [ vid bitmap ]

turtles-own [
  infected?    ;; has the person been infected with the disease?
  infectionage
  age
]


;;;;;;;;;;;;;;;;;;;;;;;;
;;; Setup ;;;
;;;;;;;;;;;;;;;;;;;;;;;;

to setup
  clear-all
  set who-should-move "All people can move"
  set lock-down-period-count 1
  set infected-and-cured 0
  set Alternate-condition "No One should Move"
  set original-condition who-should-move
  set-default-shape turtles "person"
  make-turtles
;  ask patches [ set p-infected? false ]
  infect
  recolor
;  if variant = "network" [ make-network ]
  reset-ticks
end 

to make-turtles
  create-turtles num-people [
    set infected? false
    setxy random-xcor random-ycor
    set age 50
  ]
end 

to infect
  ask n-of num-infected turtles [
    set infected? true
    set infectionage 1
    ;set age random 50
    ;set infectionage 1
;    if variant = "environmental" [
;      ;; the patch under an infected turtle becomes infected:
;      set p-infected? true
;    ]
  ]
end 

to recolor
  ask turtles [
    ;; infected turtles are red, others are gray
    set color ifelse-value infected? [ red ] [ gray ]

  ]
;  ask patches [
;    ;; infected patches are yellow, others are black
;    set pcolor ifelse-value p-infected? [ yellow ] [ black ]
;  ]
end 

;;;;;;;;;;;;;;;;;;;;;;;
;;; Main ;;;
;;;;;;;;;;;;;;;;;;;;;;;

to go




  if all? turtles [ infected? ] [ stop ]
  spread-infection
  cure-infection
  recolor

    ;; recording video
;   if vid:recorder-status = "inactive" [
;    vid:start-recorder
;  ]
;  vid:record-view

  move
  if all? turtles [ not infected? ] [ stop ]

  tick
end 

to spread-infection
;  ask patches with [ p-infected? ] [
;    ;; count down to the end of the patch infection
;    set infect-time infect-time - 1
;  ]
  ask turtles with [ infected? ] [
  ask turtles-here [ set infected? true ]
    ]
end 

to cure-infection
  ask turtles with [ infected? ] [
  set  infected? ifelse-value infectionage >= cure-days [ false ] [ true ]
  if  random 100 >= 100 - virus-death-rate [ die ]
  ;ask n-of 1 turtles with [ infected? ]  [ die ]
  set  infectionage ifelse-value infectionage >= 14 [ 0 ] [ infectionage ]
  ;set  infected? ifelse-value infectionage >= 14 [ false ] [ true ]
  ;set color ifelse-value infected? [ red ] [ gray ]
  ]
end 

;;;;;;;;;;;;;;
;;; Layout ;;;
;;;;;;;;;;;;;;d

to move

  set Allowed movement-allowed * count turtles / 100
  if who-should-move = "All people can move" [
      ask turtles [
      fd 1
      rt random 30
      lt random 30
    ]
  ]

  if who-should-move = "Limited People can move for essential work" [
        ask n-of Allowed turtles [
      fd 1
      rt random 30
      lt random 30
    ]
  ]

    if who-should-move = "Infected People should not move" [
        ask turtles with [not infected?] [
      fd 1
      rt random 30
      lt random 30
    ]
  ]

      if who-should-move = "No One should Move" [
        ask turtles with [not infected?] [
      fd 0
      rt 0
      lt 0
    ]
  ]

  ;; who chooses what to happen you or me
  if i-will-chose-who-should-move = false [

  ;; lockdown rules
if ticks > 0 and unlimited-lock-down = true [
    set who-should-move Alternate-condition

  ]


  if ticks > 0 and lock-down-period = 0 and unlimited-lock-down = false [
    set who-should-move original-condition

  ]

;  lock down
  if ticks > 0 and lock-down-period > 0 and unlimited-lock-down = false [
    if ticks > 0 and remainder ticks lock-down-period = 0 [set lock-down-period-count lock-down-period-count + 1 print lock-down-period-count]
;   if ticks > 0 and remainder lock-down-period-count 2 = 0 [set lock-down-period-count lock-down-period-count + 1 print lock-down-period-count]
    set who-should-move ifelse-value ticks > 0 and remainder lock-down-period-count 2 = 0 [Alternate-condition] ["All people can move"]
;    set who-should-move ifelse-value ticks > 0 and remainder ticks lock-down-period = 0 [Alternate-condition] ["All people can move"]
  ]

]

    ask turtles with [ infected? ] [
    set infectionage infectionage + 1
    set infected-and-cured infected-and-cured + 1
  ]
end 


; Copyright 2020 Mohit Singh.

There is only one version of this model, created 7 months ago by Mohit Kumar Singh.

Attached files

File Type Description Last updated
Covid-19_1.png preview Preview for 'Covid-19_1' 7 months ago, by Mohit Kumar Singh Download

This model does not have any ancestors.

This model does not have any descendants.