turtles-own [man? woman? happy?] patches-own [men women people] globals [boring-groups moves number-happy group-sites] to setup ca set group-sites patches with [group-site?] set-default-shape turtles "person" cct number [ ;;blue represents male, pink represents female. No stereotypes are meant ;;to be promoted. Simply change the colors right here if you'd like. ifelse (random 2 = 0) [set man? true set woman? false set color blue] [set man? false set woman? true set color pink] ifelse (random 2 = 0) [set heading 90] [set heading 270] ;; randomly face right or left set ycor 0 set xcor random screen-size-x ] ask turtles [move-into-groups] setup-patches setup-plots set moves 0 update-labels spread-people update-plots end to setup-patches ask patches [ set men 0 set women 0 set people 0] ask turtles [ if man? [set men (men + 1)] if woman? [set women (women + 1)]] ask patches [ set people (men + women)] update-happiness update-boring-groups end to go if (number-happy = number) [ stop ;; stop the simulation if everyone is happy ] group-people ;; put all people on the x-axis update-happiness move-if-unhappy update-boring-groups update-labels spread-people ;; move the people into vertical columns set moves (moves + 1) update-plots if limit-speed? [ wait 0.75 ] ;; keep the spread groups on the screen for a bit end to update-labels ask group-sites [ set plabel count turtles-here ] end to update-happiness ask patches [ set people (men + women)] ask turtles [ ;;; you are happy if the proportion of people of the opposite sex does not exceed your tolerance if man? [ifelse (women / people) > (tolerance / 100) [set happy? false] [set happy? true]] if woman? [ifelse (men / people) > (tolerance / 100) [set happy? false] [set happy? true]] ;; if (happy? = true) [set num-happy (num-happy + 1)] ] set number-happy count turtles with [happy?] ;; update number-happy variable end 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 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 (screen-size-x / 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 (((screen-edge-x - pxcor) mod group-interval) = 0) and ;; finally, make sure we don't wind up with more groups than ;; the user asked for (floor ((screen-edge-x - 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 to setup-plots set-current-plot "Happy Partygoers" set-plot-y-range 0 number end to update-plots set-current-plot "Happy Partygoers" set-current-plot-pen "Happy" plot (count turtles with [happy?]) set-current-plot "Single Sex Groups" plot boring-groups end ;; spread people out vertically to spread-people ask turtles [ifelse man? [set heading 0 fd 2] [set heading 180 fd 2] jump count other-turtles-here] ;; this trick works because of the serial ordering of turtle execution end ;; pile people up on the x-axis to group-people ask turtles [set ycor 0] end ; *** NetLogo Model Copyright Notice *** ; ; This model was created as part of the project: CONNECTED MATHEMATICS: ; MAKING SENSE OF COMPLEX PHENOMENA THROUGH BUILDING OBJECT-BASED PARALLEL ; MODELS (OBPML). The project gratefully acknowledges the support of the ; National Science Foundation (Applications of Advanced Technologies ; Program) -- grant numbers RED #9552950 and REC #9632612. ; ; Copyright 1997 by Uri Wilensky. All rights reserved. ; ; Permission to use, modify or redistribute this model is hereby granted, ; provided that both of the following requirements are followed: ; a) this copyright notice is included. ; b) this model will not be redistributed for profit without permission ; from Uri Wilensky. ; Contact Uri Wilensky for appropriate licenses for redistribution for ; profit. ; ; This model was converted to NetLogo as part of the project: ; PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN ; CLASSROOMS. The project gratefully acknowledges the support of the ; National Science Foundation (REPP program) -- grant number REC #9814682. ; Converted from StarLogoT to NetLogo, 2001. Updated 2002. ; ; To refer to this model in academic publications, please use: ; Wilensky, U. (1997). NetLogo Party model. ; http://ccl.northwestern.edu/netlogo/models/Party. ; Center for Connected Learning and Computer-Based Modeling, ; Northwestern University, Evanston, IL. ; ; In other publications, please use: ; Copyright 1998 by Uri Wilensky. All rights reserved. See ; http://ccl.northwestern.edu/netlogo/models/Party ; for terms of use. ; ; *** End of NetLogo Model Copyright Notice *** @#$#@#$#@ GRAPHICS-WINDOW 204 10 538 485 40 55 4.0 1 10 1 1 1 CC-WINDOW 3 320 198 454 Command Center BUTTON 7 10 75 43 setup setup NIL 1 T OBSERVER BUTTON 7 47 75 80 go go T 1 T OBSERVER BUTTON 7 84 75 117 step-once go NIL 1 T OBSERVER MONITOR 7 215 63 264 moves moves 0 1 SLIDER 77 10 200 43 tolerance tolerance 0.0 99.0 25.0 1.0 1 % SLIDER 77 47 200 80 number number 0 300 75 1 1 NIL MONITOR 69 215 173 264 number-happy number-happy 0 1 MONITOR 24 266 142 315 single-sex-groups boring-groups 0 1 PLOT 541 10 784 250 Happy Partygoers moves number 0.0 10.0 0.0 150.0 true false PENS "Happy" 1.0 0 -11352576 true PLOT 541 252 784 454 Single Sex Groups moves seg-groups 0.0 10.0 0.0 12.0 true false PENS "Single Sex" 1.0 0 -65536 true SLIDER 77 84 200 117 num-groups num-groups 5 20 10 1 1 NIL SWITCH 35 150 168 183 limit-speed? limit-speed? 0 1 -1000 @#$#@#$#@ WHAT IS IT? ----------- This program models a cocktail party. The party is made up of groups of both men and women. The partygoers have a TOLERANCE that defines their comfort level with a group that has members of the opposite sex. If they are in a group that has a higher percentage of people of the opposite sex than their TOLERANCE allows, then they are considered "uncomfortable", and they leave that group to find another group. This action continues until everyone at the party is "comfortable" within their group. This model is based on the work of the pioneering economist Thomas Schelling. It is also described in: Resnick, M. & Wilensky, U. (1998). Diving into Complexity: Developing Probabilistic Decentralized Thinking through Role-Playing Activities. Journal of Learning Sciences, Vol. 7, No. 2. http://ccl.northwestern.edu/cm/papers/starpeople/ HOW TO USE IT ------------- To set the number of people at the party, use the NUMBER slider. To set the number of initial groups, use the NUM-GROUPS slider. To set the tolerance of the people for the opposite sex, use the TOLERANCE slider. If the TOLERANCE slider is set to 75, then each person will tolerate being in a group with less than or equal to 75% people of the opposite sex. If there are more than this, the person is uncomfortable, and he/she leaves the group and tries out an adjacent group. The SETUP button sets up all the people into random groups. The GO button sets the party in motion. You can use the STEP-ONCE button to make all uncomfortable partygoers move once. The MOVES monitor shows the number of times people move from their groups. The NUMBER-HAPPY monitor shows how many people are content and this value is dynamically graphed in the "happy partygoers" plot. The counts are shown in gray for "single-sex" groups, white for mixed groups. The simulation ends when everyone is happy. The SINGLE-SEX-GROUPS monitor shows the number of single-sex groups and this value is dynamically plotted in the "single sex groups" plot. RUNNING the MODEL ----------------- THINGS TO NOTICE ---------------- At the end of the simulation (when everyone is happy), notice the number of single-sex groups. Is there an increase from their initial compositions? Is there a critical tolerance at which each group ends up being a single-sex group? Notice the difference in time it takes for all groups to be comfortable depending upon the tolerance. THINGS TO TRY ------------- See how many mixed groups (not a single-sex group) you can get. Use the STEP-ONCE button, and experiment with different tolerances. Watch how one unhappy person can disrupt the stability of other groups. Is it possible to have an initial grouping such that the party is never completely content? (i.e. the model never terminates) Observe real parties. Is this model descriptive of real social settings? What tolerances would model the people in the real party? EXTENDING THE MODEL ------------------- Add another dimension to the model. Instead of male/female, try a trait that has more than two types, like race or religion. You can use BREEDS to implement that. Allow each BREED of person to have their own tolerance. Complicate the tolerance rules: For example, the tolerance could go up as long as there are at least 2 of one BREED. Allow groups to subdivide, instead of finding new groups. Set a maximum group size, so that if there are too many people in the group, they become unhappy. NETLOGO FEATURES ----------------- Notice the use of the "mod" function with a portion of the "screen-size" to space out the groups evenly. Setting up the groups in this manner allows for easy movement from group to group. Note also the use of the seriality of turtle execution for spreading out the turtles. Knowing that lower numbered turtles execute first enables this code to align the labels in the SHOW-COUNTS option. RELATED MODELS --------------- Segregation CREDITS AND REFERENCES ---------------------- Schelling, T. (1978). Micro-motives and Macro-Behavior. New York: Norton. Resnick, M. & Wilensky, U. (1998). Diving into Complexity: Developing Probabilistic Decentralized Thinking through Role-Playing Activities. Journal of Learning Sciences, Vol. 7, No. 2. To refer to this model in academic publications, please use: Wilensky, U. (1997). NetLogo Party model. http://ccl.northwestern.edu/netlogo/models/Party. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL. In other publications, please use: Copyright 1997 by Uri Wilensky. All rights reserved. See http://ccl.northwestern.edu/netlogo/models/Party for terms of use. @#$#@#$#@ default true 0 Polygon -7566196 true true 150 5 40 250 150 205 260 250 arrow true 0 Polygon -7566196 true true 150 0 0 150 105 150 105 293 195 293 195 150 300 150 box true 0 Polygon -7566196 true true 45 255 255 255 255 45 45 45 circle true 0 Circle -7566196 true true 35 35 230 person false 0 Circle -7566196 true true 155 20 63 Rectangle -7566196 true true 158 79 217 164 Polygon -7566196 true true 158 81 110 129 131 143 158 109 165 110 Polygon -7566196 true true 216 83 267 123 248 143 215 107 Polygon -7566196 true true 167 163 145 234 183 234 183 163 Polygon -7566196 true true 195 163 195 233 227 233 206 159 spacecraft true 0 Polygon -7566196 true true 150 0 180 135 255 255 225 240 150 180 75 240 45 255 120 135 thin-arrow true 0 Polygon -7566196 true true 150 0 0 150 120 150 120 293 180 293 180 150 300 150 truck-down false 0 Polygon -7566196 true true 225 30 225 270 120 270 105 210 60 180 45 30 105 60 105 30 Polygon -8716033 true false 195 75 195 120 240 120 240 75 Polygon -8716033 true false 195 225 195 180 240 180 240 225 truck-left false 0 Polygon -7566196 true true 120 135 225 135 225 210 75 210 75 165 105 165 Polygon -8716033 true false 90 210 105 225 120 210 Polygon -8716033 true false 180 210 195 225 210 210 truck-right false 0 Polygon -7566196 true true 180 135 75 135 75 210 225 210 225 165 195 165 Polygon -8716033 true false 210 210 195 225 180 210 Polygon -8716033 true false 120 210 105 225 90 210 turtle true 0 Polygon -7566196 true true 138 75 162 75 165 105 225 105 225 142 195 135 195 187 225 195 225 225 195 217 195 202 105 202 105 217 75 225 75 195 105 187 105 135 75 142 75 105 135 105 @#$#@#$#@ NetLogo 2.0alpha2 @#$#@#$#@ @#$#@#$#@ @#$#@#$#@