Advertisement
Guest User

NetLogo

a guest
Jun 3rd, 2014
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. globals [
  2. total_dogs_infected
  3. total_dogs
  4. dead_humans
  5. dead_dogs
  6. ]
  7.  
  8. turtles-own [
  9. has_dog?
  10. sick_dog?
  11. sick_human?
  12. vaccinated_dog?
  13. dog_rabies_phase
  14. days_infected
  15. end-incubator
  16. end-furious
  17. end-life
  18. ]
  19.  
  20. to setup
  21. clear-all
  22. initialize-globals
  23. setup-turtles
  24. reset-ticks
  25. end
  26.  
  27. to initialize-globals
  28. set dead_humans 0
  29. set dead_dogs 0
  30. set total_dogs_infected 0
  31. end
  32.  
  33. to setup-turtles
  34. set-default-shape turtles "person"
  35. crt people [
  36. setxy random-xcor random-ycor
  37. set size 1.5
  38.  
  39. ifelse (random 100) < 43 [
  40. set has_dog? true
  41. set sick_dog? false
  42. set sick_human? false
  43. set color green ;green: both human and dog sane
  44. set days_infected 0
  45.  
  46. ifelse random 100 < %_not_vaccinated [set vaccinated_dog? false set color orange] [set vaccinated_dog? true] ;orange: sane human with no vaccinated dog
  47. ]
  48. ;coloro che non hanno cani
  49. [set has_dog? false
  50. set sick_human? false
  51. set color blue] ;umano sano senza cane
  52. ]
  53.  
  54. set total_dogs count turtles with [has_dog?]
  55. ask n-of 1 turtles with [has_dog?] [dog_gets_sick]
  56.  
  57. end
  58.  
  59. to dog_gets_sick
  60. set sick_dog? true
  61. set color white ;red: sane human with infective dog
  62.  
  63. set dog_rabies_phase 1
  64. set end-incubator 14 + random 57
  65. set end-furious (end-incubator + random 5)
  66. set end-life (end-furious + 4 + random 2)
  67.  
  68. ;set %dogs_infected ((count turtles with [has_dog? and sick_dog?] - 1) / (count turtles with [has_dog?])) * 100
  69. set total_dogs_infected total_dogs_infected + 1
  70. end
  71.  
  72. to go
  73. move
  74. infect
  75. get-older-sick-dog
  76. tick
  77. end
  78.  
  79. to move
  80. ask turtles [
  81. rt random 180
  82. lt random 180
  83. fd 1
  84. ]
  85. end
  86.  
  87. to infect
  88. ask turtles with [has_dog? and sick_dog?] [
  89.  
  90. if (dog_rabies_phase = 1 and (random 100) <= 2)
  91. [ask other turtles-here with [has_dog? and not vaccinated_dog? and not sick_dog?] [dog_gets_sick]]
  92.  
  93. if (dog_rabies_phase = 2)
  94. [ask other turtles-here with [has_dog? and not vaccinated_dog? and not sick_dog?] [dog_gets_sick]]
  95.  
  96. ]
  97. end
  98.  
  99.  
  100. to get-older-sick-dog
  101.  
  102. ask turtles with [has_dog? and sick_dog?] [
  103.  
  104. set days_infected days_infected + 1
  105.  
  106. ;the incubator phase ends after at least 14 days + random(57) and then we have phase 2 (furious)
  107. if (days_infected = end-incubator) [set dog_rabies_phase 2];
  108.  
  109. ;when the main furious phase finishes we have 75% of probability that a secondary furious phase continues for other 4 - 6 days until death
  110. ;or we have a probability of 25% that the disease end in paralysis with a fast death
  111. if (days_infected = end-furious and (random 100 > 75))
  112. [set dead_dogs dead_dogs + 1 die]
  113.  
  114. if (days_infected = end-life) [die]
  115.  
  116. ]
  117.  
  118. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement