Rabbit-Disease

No preview image

1 collaborator

Default-person bosmat bar (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 6.1.1 • Viewed 64 times • Downloaded 8 times • Run 0 times
Download the 'Rabbit-Disease' 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
[
  num-sick   ;number of turtles that are sick
  num-heal   ;number of turtles that are heal
  run-number ; when multiple runs are recorded in the plot, this tracks what run number we're on
  delay      ; counter used to keep the model running for a little while after the last turtle gets infected

]

breed [ rabbits rabbit ]

rabbits-own
[
  infected?       ;whether turtle is sick (true/false)
  immunity?       ;whether turtle is immunne (true/false)
  in-hospital?    ;whether turtle is inside the hospital (true/false)
]

; clears the plot

to setup-clear
  clear-all
  ask patches [ set pcolor green ]                                   ;"world" area
  ask patches [ if ( pxcor > 4 and pycor > 4) [set pcolor black]]    ;hospital area
  ask patches [ if ( pxcor > 5 and pycor > 5) [set pcolor blue]]     ;hospital area
  ask patches [ if ( pxcor = 13  and pycor = 20) [set pcolor red]]   ;hospital area
  ask patches [ if ( pxcor = 13  and pycor = 19) [set pcolor red]]   ;hospital area
  ask patches [ if ( pxcor = 13  and pycor = 18) [set pcolor red]]   ;hospital area
  ask patches [ if ( pxcor = 12  and pycor = 19) [set pcolor red]]   ;hospital area
  ask patches [ if ( pxcor = 14  and pycor = 19) [set pcolor red]]   ;hospital area
  set run-number 1
  set-default-shape rabbits "rabbit"
  create-rabbits מספר-ארנבים                                          ;we start with rabbints-num that the user choosing
  [
     set color white                                                 ;let rabbits be healthy at the beginning - with coloe white
     set size 3
     set heading 90 * random 4
     set infected? false                                             ;all the rabbits are healthy at the beginning
     set immunity? false                                             ;all the rabbits are not immune at the beginning
     set in-hospital? false                                          ;all the rabbits are not in-hospital at the beginning
  ]
  ask rabbits [move-to one-of patches with [ pcolor = green ]]       ;non-sick rabbit will not be inside the hospital
  reset-ticks
end 

to go
  ; in order to extend the plot for a little while
  ; after all the turtles are infected...
  if num-sick = count turtles
    [ set delay delay + 1  ]
  if delay > 300
    [ stop ]
  ;; now for the main stuff;
  rabbits-wander                                                     ;wander rules function
  ask turtles with [ infected? ]
    [ spread-disease ]
  set num-sick count turtles with [ infected? ]
  set num-heal count turtles with [ color = pink ]
  if num-heal = count turtles
    [ user-message "כל הארנבים הבריאו!" stop ]                         ;if all the rabbits have been to the hospital and recovered, stop the model and message the user.
  tick
end 

; controls the motion of the rabbits -------->                       ;white rabbit is not sick, so he wander in green area ("world area")

to rabbits-wander                                                    ;red rabbit is a sick-rabbit, so he goes directly to blue area ("the hospital")
  ask rabbits                                                        ;pink rabbit is a heal-rabbit, he goes back from the blue area ("the hospital") to the green area ("the world"). pink rabbit is immune.
  [                                                                  ;we set in-hospital? = true if the rabbit is sick (red) and inside the hospital
    rt (random 4) * 90
    if ( patch-ahead 1 != nobody)
    [
      if(not infected?) and ( [pcolor] of patch-ahead 1 = black)
      [
        rt 180
      ]
    ]

    if (infected? and pcolor = green)
    [
      set heading (random 2) * 90
      if ( patch-ahead 1 = nobody)
      [
         rt 180
      ]
    ]

    if(infected? and pcolor = blue)
    [
      set heading (random 2) * 90
      if ( patch-ahead 1 = nobody)
      [
         rt 180
      ]
    ]

    if (color = pink and pcolor = blue)
    [
       set heading (random 2) * 90 + 180
    ]
    fd 1

    if (color = red and pcolor = blue)
    [
      set in-hospital? true
    ]
  ]
end 

to spread-disease ; turtle procedure
  ask other turtles in-radius 3 [ maybe-get-sick ]                          ;if one rabbit get sick and there is another rabbit in radius 3, he get infected too
end 

to infect                                                                   ;check if one of the rabbit is healthy. if so, we can make one of the helthy-white-rabbits sick. else, nothing happens.
  if any? rabbits with [ color = white ]
  [
     ask one-of rabbits with [color = white] [ get-sick ]                   ;pressing on the button "infect" (by the user) let randomly one of the white rabbits sick
  ]
end 

to heal
  if any? rabbits with [ in-hospital? = true ]                               ;check if one of the rabbit is inside the hospital already (who is for sure sick). if so, we can make one of the those rabbits heal. else, nothing happens.
  [
     ask one-of rabbits with [in-hospital? = true] [ recovery ]              ;random sick-rabbits (inside the hospital only) gets heal.
  ]
end 

to maybe-get-sick ; turtle procedure
  ;; roll the dice and maybe get sick
  if (not infected?) and (random 100 < סיכויי-הדבקה) and (not immunity?)       ;the user controls the % of spread-disrase success
    [ get-sick ]
end 

to get-sick ; turtle procedure
  if not infected?
  [
    set infected? true
    set color red ; sick rabbit will be red
  ]
end 

to recovery
  if infected?
  [
    set infected? false
    set immunity? true
    set in-hospital? false
    set color pink ; heal rabbit will be pink. pink rabbit is immune and can't get sick again
  ]
end 

There is only one version of this model, created over 3 years ago by bosmat bar.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.