6
13 giugno 2006Master in economia e politica sanitaria - Simulazione per la sanità 6 to move-if-unhappy ask turtles [ if (not happy?) [ifelse man? [set men men - 1] ;;decrease the count in your old group [set women women - 1] ifelse (random 2 = 0) [set heading 90] [set heading 270] ;; randomly face right or left fd 1 ;; move out of your group move-into-groups ifelse man? [set men men + 1] [set women women + 1]]] ;;increase the count in your new in group end to move-into-groups ;;turtle procedure ; move forward until you hit the closest group if not group-site? [ fd 1 if limit-speed? [ wait 0.1 ] ;; slow it down so user can see it happening move-into-groups] end

7
13 giugno 2006Master in economia e politica sanitaria - Simulazione per la sanità 7 to-report group-site? ;; turtle or patch procedure ;; if your pycor is 0 and your pxcor is where a group should be located, ;; then you're a group site (patch) or on a group site (turtle) locals [group-interval] ;; first figure out how many patches apart the groups will be set group-interval floor (world-width / num-groups) report ;; first check pycor (pycor = 0) and ;; then check if the distance between groups divides evenly into ;; our distance from the right hand edge of the screen (((max-pxcor - pxcor) mod group-interval) = 0) and ;; finally, make sure we don't wind up with more groups than ;; the user asked for (floor ((max-pxcor - pxcor) / group-interval) < num-groups) end to update-boring-groups ask group-sites [ set plabel-color white if people > 0 [if ((men = 0) or (women = 0)) [set plabel-color gray]]] set boring-groups (count group-sites with [plabel-color = gray]) end