Disease Doctors

Disease Doctors preview image

1 collaborator

Uri_dolphin3 Uri Wilensky (Author)

Tags

biology 

Tagged by Reuven M. Lerner about 7 years ago

hubnet 

Tagged by Reuven M. Lerner over 7 years ago

Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 5.0beta1 • Viewed 406 times • Downloaded 35 times • Run 0 times
Download the 'Disease Doctors' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


WHAT IS IT?

This model is a modified version of the Disease activity which, simulates the spread of a disease through a population. In this version the population can consist of students, which are turtles controlled by individual students via the HubNet Client, androids, infectable turtles controlled by the computer and doctors, un-infectable turtles that can heal other turtles. Doctors do not exist in the Disease activity.

For further documentation on the original Disease activity, see the Participatory Simulations Guide found at http://ccl.northwestern.edu/ps/

HOW IT WORKS

Turtles move around, possibly catching an infection, either randomly in the case of androids and doctors or as controlled by HubNet clients. Healthy turtles on the same patch as sick turtles have an INFECTION-CHANCE chance also becoming sick. A plot shows the number of sick turtles at each time tick, and if SHOW-SICK? is on, sick turtles have a red circle attached to their shape. Both students and androids can become sick, doctors cannot. If an infectable turtle is on the same patch as a doctor they are cured.

Initially, all turtles are healthy. A number of turtles equal to INITIAL-NUMBER-SICK become sick when the INFECT button is pressed.

HOW TO USE IT

Quickstart Instructions:

Teacher: Follow these directions to run the HubNet activity. Optional: Zoom In (see Tools in the Menu Bar) Optional: Change any of the settings. Optional: Add androids and doctors.

Everyone: Open up a HubNet Client on your machine and type your user name, select this activity and press ENTER.

Teacher: Have the students move their turtles around to acquaint themselves with the interface. Press the INFECT button in the NetLogo interface to start the simulation.

Everyone: Watch the plot of the number infected.

Teacher: To start the activity again with the same group, stop the model by pressing the GO button, if it is on. Change any of the settings that you would like. Press the SETUP button or the CURE-ALL button, SETUP will kill the androids and doctors, CURE-ALL will not.

Teacher: Restart the simulation by pressing the GO button again. Infect some turtles and continue.

Teacher: To start the simulation over with a new group stop the model by pressing the GO button, press the RESET button in the Control Center and follow these instructions again from the beginning.

Buttons:

SETUP - sets all students to an uninfected state, kills all androids, and increments the run-number so the data in the plot will overlay the previous run. CURE-ALL - sets all turtles to an uninfected state and increments the run-number. GO - runs the simulation CREATE-ANDROIDS - adds NUM-ANDROIDS randomly moving turtles to the simulation CREATE-DOCTORS - adds NUM-DOCTORS turtles that can heal other turtles INFECT - infects INITIAL-NUMBER-SICK of the turtles in the simulation NEXT >>> - shows the next quick start instruction <<< PREVIOUS - shows the previous quick start instruction RESET INSTRUCTIONS - shows the first quick start instruction

Sliders:

NUM-ANDROIDS - defines how many androids are created by the CREATE-ANDROIDS button NUM-DOCTORS - defines how many doctors are created by the CREATE-DOCTORS button ANDROID-DELAY - the delay time, in seconds, for android movement - the higher the number, the slower the androids move DOCTOR-DELAY - the delay time, in seconds, for doctor movement - the higher the number, the slower the doctors move INITIAL-NUMBER-SICK - the number of turtles that become infected spontaneously when the INFECT button is pressed INFECTION-CHANCE - sets the percentage chance that every tenth of a second a healthy turtle will become sick if it is on the same patch as an infected turtle

Switches:

WANDER? - when on, the androids and doctors wander randomly. When off, they do not move SHOW-SICK? - when on, sick turtles add to their original shape a red circle. When off, they can move through the population unnoticed

Monitors:

INFECTABLE TURTLES - the sum of students and androids since doctors cannot be infected. NUMBER SICK - the number of turtles that are infected

Plots:

NUMBER SICK - shows the number of sick turtles versus time

Client Information

After logging in, the client interface will appear for the students, and if GO is pressed in NetLogo they will be assigned a turtle which will be described in the YOU ARE A: monitor. Their current location will be shown in the LOCATED AT: monitor. If the student doesn't like their assigned shape and/or color they can hit the CHANGE APPEARANCE button at any time to change to another random appearance.

The SICK? monitor will show "true" if your turtle is infected, or "false" will be shown if your turtle is not infected.

The student controls the movement of their turtle with the UP, DOWN, LEFT, and RIGHT buttons and the STEP-SIZE slider. Clicking any of the directional buttons moves their turtle in the appropriate direction a distance of STEP-SIZE.

THINGS TO NOTICE

If no doctors are present no matter how you change the various parameters, the same basic plot shape emerges. After using the model once with the students, ask them how they think the plot will change if you alter a parameter and when you add doctors. Altering the initial percentage sick and the infection chance will have different effects on the plot.

THINGS TO TRY

Use the model with the entire class to serve as an introduction to the topic. Then have students use the NetLogo model individually, in a computer lab, to explore the effects of the various parameters. Discuss what they find, observe, and can conclude from this model.

Ask students to predict how the shape of the plot change will change when doctors are added.

EXTENDING THE MODEL

Try to make the androids and doctors smarter about how they move around the world.

Experiment with different infection scenarios, for example once a turtle is cured it builds immunity to the disease or turtles may still carry the disease and infect others even after it has been cured.

RELATED MODELS

Disease Disease Solo

HOW TO CITE

If you mention this model in a publication, we ask that you include these citations for the model itself and for the NetLogo software:

COPYRIGHT AND LICENSE

Copyright 2006 Uri Wilensky.

CC BY-NC-SA 3.0

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at uri@northwestern.edu.

Comments and Questions

Click to Run Model

globals
[
  ;; lists used to create the various turtles
  shape-names        ;; list that holds the names of the non-sick shapes a student's turtle can have
  colors             ;; list that holds the colors used for students' turtles
  color-names        ;; list that holds the names of the colors used for students' turtles
  used-shape-colors  ;; list that holds the shape-color pairs that are already being used
  max-possible-codes ;; total number of possible unique shape/color combinations

  ;; when multiple runs are recorded in the plot, this
  ;; tracks what run number we're on
  run-number

  ;; keep track of where the show-sick slider was last time around
  old-show-sick?

  ;; quick start instructions variables
  quick-start  ;; current quickstart instruction displayed in the quickstart monitor
  qs-item      ;; index of the current quickstart instruction
  qs-items     ;; list of quickstart instructions
]

;; doctors cannot be infected but giving them an infected? variable makes code simpler
turtles-own
[
  infected?    ;; if a turtle is sick, infected? is true, otherwise, it is false
  base-shape   ;; original shape of a turtle
  step-size    ;; the amount that a turtle will go forward in the current direction
]

breed [ androids android ]  ;; created by the CREATE-ANDROIDS button, controlled by the simulation
breed [ students student ]  ;; created and controlled by the clients
breed [ doctors  doctor ]   ;; created by the CREATE-DOCTORS button, controlled by the simulation

students-own
[
  user-id  ;; unique id, input by the students when they log in, to identify each student turtle
]


;;;;;;;;;;;;;;;;;;;;;;
;; Setup Procedures ;;
;;;;;;;;;;;;;;;;;;;;;;

to startup
  hubnet-reset
  setup-vars
  setup-plot
  setup-quick-start
end 

to setup
  reset-ticks
  ask androids [ die ]
  ask doctors [ die ]

  cure-all
end 

to cure-all
  ask turtles
  [
    set infected? false
    if breed = students
      [ update-sick?-monitor ]
    set shape base-shape
  ]

  ;; advance the run-number but don't clear the plot
  ;; so run results can be compared
  set run-number run-number + 1
  setup-plot
end 

;; initialize global variables

to setup-vars
  set shape-names [ "box" "star" "wheel" "target" "cat" "dog"
                   "butterfly" "leaf" "car" "airplane"
                   "monster" "key" "cow skull" "ghost"
                   "cactus" "moon" "heart" ]

  ;; these colors were chosen with the goal of having colors
  ;; that are readily distinguishable from each other, and that
  ;; have names that everyone knows (e.g. no "cyan"!), and that
  ;; contrast sufficiently with the red infection dots and the
  ;; gray androids
  set colors      (list white brown green yellow
                        (violet + 1) (sky + 1))
  set color-names ["white" "brown" "green" "yellow"
                   "purple" "blue"]
  set max-possible-codes (length colors * length shape-names)
  set used-shape-colors []
  set-default-shape doctors "android"
  set run-number 1
end 

;; create a temporary plot pen for the current run
;; cycle through a few colors so it is easy to
;; differentiate the runs.

to setup-plot
  create-temporary-plot-pen word "run " run-number
  set-plot-pen-color item (run-number mod 5)
                          [blue red green orange violet]
end 

to make-androids
  create-androids num-androids
  [
    move-to one-of patches
    face one-of neighbors4
    set color gray
    set infected? false
    set base-shape "android"
    set shape base-shape
    set step-size 1
  ]
end 

to make-doctors
  create-doctors num-doctors
  [
    setxy random-xcor random-ycor
    face one-of neighbors4
    set color white
    set infected? false
    set base-shape "android"
    set shape base-shape
    set step-size 1
  ]
end 


;;;;;;;;;;;;;;;;;;;;;;;;
;; Runtime Procedures ;;
;;;;;;;;;;;;;;;;;;;;;;;;

to go
  ;; get commands and data from the clients
  listen-clients

  every 0.1
  [
    ;; allow the androids and doctors to wander around the view
    if wander?
      [ wander ]

    ask turtles with [ infected? ]
      [ spread-disease ]

    ask doctors [ heal ]

    tick
    plot count turtles with [ infected? ]
  ]
  ;; we don't want to reset the turtle shapes every time
  ;; through go but we do want to respond to the show-sick?
  ;; switch so keep track of when it's changed
  if show-sick? != old-show-sick?
  [
    ask turtles with [infected?] [ set-sick-shape ]
    set old-show-sick? show-sick?
  ]
end 

;; controls the motion of the androids and doctors

to wander
  ;; doctors and androids may wander at different rates
  every android-delay
    [ breed-wander androids ]
  every doctor-delay
    [ breed-wander doctors ]
end 

;; have breed-type (a turtle agentset) move around

to breed-wander [ breed-type ]
  ask breed-type
  [
    ;; always move in one of the cardinal directions
    face one-of neighbors4
    fd step-size
  ]
end 

;; additional check infect called when student moves to new patch
;; added to avoid rewarding movement

to student-move-check-infect ;; turtle procedure
  if infected?
  [ spread-disease ]

  ask other turtles-here with [ infected? ]
  [ ask myself [ maybe-get-sick ] ]
end 

;; spread disease to other turtles here

to spread-disease ;; turtle procedure
  ask other turtles-here with [ breed != doctors ] [ maybe-get-sick ]
end 

;; roll the dice and maybe get sick

to maybe-get-sick ;; turtle procedure
  if not infected? [
    if ((random 100) + 1) <= infection-chance
    [ get-sick ] ]
end 

;; set the appropriate variables to make this turtle sick

to get-sick ;; turtle procedure
  set infected? true
  set-sick-shape
  if (breed = students)
  [ update-sick?-monitor ]
end 

;; change the shape of turtles to its sick shape
;; if show-ill? is true and change the shape to the base-shape if
;; show-ill? is false

to set-sick-shape ;; turtle procedure
  ifelse show-sick?
  [
    ;; we want to check if the turtles shape is already a sick shape
    ;; to prevent flickering in the turtles
    if ( shape != word base-shape " sick" )
    [ set shape word base-shape " sick" ]
  ]
  [
    ;; we want to check if the turtles shape is already a base-shape
    ;; to prevent flickering in the turtles
    if (shape != base-shape)
    [ set shape base-shape ]
  ]
end 

;; infected turtles check if they are on the same patch as a doctor.
;; if they are, then they become healthy.

to heal ;; turtle procedure
  ask turtles-here with [ infected? ]
    [
      set infected? false
      set shape base-shape
    ]
end 

;; causes the initial infection in the turtle population --
;; infects a random healthy turtle until the desired number of
;; turtles are infected

to infect-turtles
  let healthy-turtles turtles with [ not infected? and breed != doctors ]

  ifelse count healthy-turtles < initial-number-sick
  [
    ask healthy-turtles
    [
      get-sick
      set-sick-shape
    ]
    user-message "There are no more healthy turtles to infect.  Infection stopped."
    stop
  ]
  [
    ask n-of initial-number-sick healthy-turtles
    [
      get-sick
      set-sick-shape
    ]
  ]
end 

;;;;;;;;;;;;;;;;;;;;;;;
;; HubNet Procedures ;;
;;;;;;;;;;;;;;;;;;;;;;;

;; determines which client sent a command, and what the command was

to listen-clients
  while [ hubnet-message-waiting? ]
  [
    hubnet-fetch-message
    ifelse hubnet-enter-message?
    [ create-new-student ]
    [
      ifelse hubnet-exit-message?
      [ remove-student ]
      [ execute-command hubnet-message-tag ]
    ]
  ]

  ask students
    [ update-sick?-monitor ]
end 

;; NetLogo knows what each student turtle is supposed to be
;; doing based on the tag sent by the node:
;; step-size - set the turtle's step-size
;; Up    - make the turtle move up by step-size
;; Down  - make the turtle move down by step-size
;; Right - make the turtle move right by step-size
;; Left  - make the turtle move left by step-size
;; Get a Different Turtle - change the turtle's shape and color

to execute-command [command]
  if command = "step-size"
  [
    ask students with [user-id = hubnet-message-source]
    [ set step-size hubnet-message ]
    stop
  ]
  if command = "Up"
  [ execute-move 0 stop ]
  if command = "Down"
  [ execute-move 180 stop ]
  if command = "Right"
  [ execute-move 90 stop ]
  if command = "Left"
  [ execute-move 270 stop ]
  if command = "Change Appearance"
  [ execute-change-turtle stop ]
end 

;; Create a turtle, set its shape, color, and position
;; and tell the node what its turtle looks like and where it is

to create-new-student
  create-students 1
  [
    setup-student-vars
    send-info-to-clients
  ]
end 

;; sets the turtle variables to appropriate initial values

to setup-student-vars  ;; turtle procedure
  set user-id hubnet-message-source
  set-unique-shape-and-color
  move-to one-of patches
  face one-of neighbors4
  set infected? false
  set step-size 1
end 

;; pick a base-shape and color for the turtle

to set-unique-shape-and-color ;; turtle procedure
  let code random max-possible-codes
  while [member? code used-shape-colors and count students < max-possible-codes]
  [
    set code random max-possible-codes
  ]
  set used-shape-colors (lput code used-shape-colors)
  set base-shape item (code mod length shape-names) shape-names
  set shape base-shape
  set color item (code / length shape-names) colors
end 

;; report the string version of the turtle's color

to-report color-string [color-value]
  report item (position color-value colors) color-names
end 

to update-sick?-monitor ;; turtle procedure
  hubnet-send user-id "Sick?" infected?
end 

;; sends the appropriate monitor information back to the client

to send-info-to-clients ;; turtle procedure
  hubnet-send user-id "You are a:" (word (color-string color) " " base-shape)
  hubnet-send user-id "Located at:" (word "(" pxcor "," pycor ")")
  update-sick?-monitor
end 

;; Kill the turtle, and remove it's shape-color combo from the used list

to remove-student
  ask students with [user-id = hubnet-message-source]
  [
    set used-shape-colors remove my-code used-shape-colors
    die
  ]
end 

;; translates a student turtle's shape and color into a code

to-report my-code
  report (position base-shape shape-names) + (length shape-names) * (position color colors)
end 

;; Cause the students to move forward step-size in new-heading's heading

to execute-move [new-heading]
  ask students with [user-id = hubnet-message-source]
  [
    set heading new-heading
    fd step-size
    hubnet-send user-id "Located at:" (word "(" pxcor "," pycor ")")

    ;; maybe infect or get infected by turtles on the patch student moved to
    student-move-check-infect
  ]
end 

to execute-change-turtle
  ask students with [user-id = hubnet-message-source]
  [
    set used-shape-colors remove my-code used-shape-colors
    show-turtle
    set-unique-shape-and-color
    hubnet-send user-id "You are a:" (word (color-string color) " " base-shape)
    if infected?
    [ set-sick-shape ]
  ]
end 

;;; this procedure is handy for testing out additional shapes and colors;
;;; you can call it from the Command Center

to show-gamut
  ca
  setup-vars
  crt max-possible-codes [
    fd max-pxcor * 0.7
    if who mod 3 = 0
      [ fd max-pxcor * 0.3 ]
    if who mod 3 = 1
      [ fd max-pxcor * 0.15 ]
    set heading 0
    set-unique-shape-and-color
  ]
  ask patch 0 0 [
    ask patches in-radius 2 [
      sprout-androids 1 [
        set shape "android"
        set color gray
      ]
    ]
  ]
  user-message (word length shape-names
              " shapes * "
              length colors
              " colors = "
              max-possible-codes
              " combinations")
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Quick Start Procedures
;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; instructions to quickly setup the model, and clients to run this activity

to setup-quick-start
  set qs-item 0
  set qs-items
  [
    "Teacher: Follow these directions to run the HubNet activity."
    "Optional: Zoom In (see Tools in the Menu Bar)"
    "Optional: Change any of the settings."
    "Optional: Add androids and doctors."
    "Press the GO button."
    "Everyone: Open up a HubNet Client on your machine and type your user name..."
    "select this activity and press ENTER."
    "Teacher: Have the students move their turtles around..."
    "...to acquaint themselves with the interface."
    "Press the INFECT button in the NetLogo interface to start the simulation."
    "Everyone: Watch the plot of the number infected."
    "Teacher: To start the activity again with the same group..."
    "stop the model by pressing the GO button, if it is on."
    "Change any of the settings that you would like."
    "Press the SETUP button or the CURE-ALL button..."
    "SETUP will kill the androids and doctors, CURE-ALL will not."
    "Teacher: Restart the simulation by pressing the GO button again."
    "Infect some turtles and continue."
    "Teacher: To start the simulation over with a new group,"
    "have all the students log out "
    "...or kick out the clients from the HubNet Control Center."
    "Stop the model by pressing the GO button,"
    "press SETUP and follow these instructions again from the beginning."
  ]
  set quick-start (item qs-item qs-items)
end 

;; view the next item in the quickstart monitor

to view-next
  set qs-item qs-item + 1
  if qs-item >= length qs-items
  [ set qs-item length qs-items - 1 ]
  set quick-start (item qs-item qs-items)
end 

;; view the previous item in the quickstart monitor

to view-prev
  set qs-item qs-item - 1
  if qs-item < 0
  [ set qs-item 0 ]
  set quick-start (item qs-item qs-items)
end 


; Copyright 2006 Uri Wilensky.
; See Info tab for full copyright and license.

There are 7 versions of this model.

Uploaded by When Description Download
Uri Wilensky about 7 years ago Updated to NetLogo 5.0.4 Download this version
Uri Wilensky almost 8 years ago Updated version tag Download this version
Uri Wilensky almost 8 years ago Updated to version from NetLogo 5.0.3 distribution Download this version
Uri Wilensky over 8 years ago Updated to NetLogo 5.0 Download this version
Uri Wilensky about 10 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky about 10 years ago Disease Doctors Download this version
Uri Wilensky about 10 years ago Disease Doctors Download this version

Attached files

File Type Description Last updated
Disease Doctors.png preview Preview for 'Disease Doctors' over 7 years ago, by Uri Wilensky Download

This model does not have any ancestors.

This model does not have any descendants.