Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- globals [
- total_dogs_infected
- total_dogs
- dead_humans
- dead_dogs
- ]
- turtles-own [
- has_dog?
- sick_dog?
- sick_human?
- vaccinated_dog?
- dog_rabies_phase
- days_infected
- end-incubator
- end-furious
- end-life
- ]
- to setup
- clear-all
- initialize-globals
- setup-turtles
- reset-ticks
- end
- to initialize-globals
- set dead_humans 0
- set dead_dogs 0
- set total_dogs_infected 0
- end
- to setup-turtles
- set-default-shape turtles "person"
- crt people [
- setxy random-xcor random-ycor
- set size 1.5
- ifelse (random 100) < 43 [
- set has_dog? true
- set sick_dog? false
- set sick_human? false
- set color green ;green: both human and dog sane
- set days_infected 0
- ifelse random 100 < %_not_vaccinated [set vaccinated_dog? false set color orange] [set vaccinated_dog? true] ;orange: sane human with no vaccinated dog
- ]
- ;coloro che non hanno cani
- [set has_dog? false
- set sick_human? false
- set color blue] ;umano sano senza cane
- ]
- set total_dogs count turtles with [has_dog?]
- ask n-of 1 turtles with [has_dog?] [dog_gets_sick]
- end
- to dog_gets_sick
- set sick_dog? true
- set color white ;red: sane human with infective dog
- set dog_rabies_phase 1
- set end-incubator 14 + random 57
- set end-furious (end-incubator + random 5)
- set end-life (end-furious + 4 + random 2)
- ;set %dogs_infected ((count turtles with [has_dog? and sick_dog?] - 1) / (count turtles with [has_dog?])) * 100
- set total_dogs_infected total_dogs_infected + 1
- end
- to go
- move
- infect
- get-older-sick-dog
- tick
- end
- to move
- ask turtles [
- rt random 180
- lt random 180
- fd 1
- ]
- end
- to infect
- ask turtles with [has_dog? and sick_dog?] [
- if (dog_rabies_phase = 1 and (random 100) <= 2)
- [ask other turtles-here with [has_dog? and not vaccinated_dog? and not sick_dog?] [dog_gets_sick]]
- if (dog_rabies_phase = 2)
- [ask other turtles-here with [has_dog? and not vaccinated_dog? and not sick_dog?] [dog_gets_sick]]
- ]
- end
- to get-older-sick-dog
- ask turtles with [has_dog? and sick_dog?] [
- set days_infected days_infected + 1
- ;the incubator phase ends after at least 14 days + random(57) and then we have phase 2 (furious)
- if (days_infected = end-incubator) [set dog_rabies_phase 2];
- ;when the main furious phase finishes we have 75% of probability that a secondary furious phase continues for other 4 - 6 days until death
- ;or we have a probability of 25% that the disease end in paralysis with a fast death
- if (days_infected = end-furious and (random 100 > 75))
- [set dead_dogs dead_dogs + 1 die]
- if (days_infected = end-life) [die]
- ]
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement