Party Model (Next Level)

No preview image

1 collaborator

Default-person Kaylin Ervay (Author)


(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 6.1.0 • Viewed 63 times • Downloaded 2 times • Run 0 times
Download the 'Party Model (Next Level)' modelDownload this modelEmbed this model

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


This is a model of a cocktail party. The men and women at the party form groups. A party-goer becomes uncomfortable and switches groups if their current group has too many members of the opposite sex. What types of group result?


The party-goers 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. Movement continues until everyone at the party is "comfortable" with their group.


The NUMBER slider controls how many people are in the party, and the NUM-GROUPS slider controls how many groups form.

The SETUP button forms random groups. To advance the model one step at a time, use the GO ONCE button. The GO button keeps the model running until everybody is comfortable.

The numbers in the view show the sizes of the groups. White numbers are mixed groups and gray numbers are single-sex groups.

To set the tolerance of the people for the opposite sex, use the TOLERANCE slider. You can move the slider while the model is running. 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.

The NUMBER HAPPY and SINGLE SEX GROUPS plots and monitors show how the party changes over time. NUMBER HAPPY is how many party-goers are happy (that is, comfortable). SINGLE SEX GROUPS shows the number groups containing only men or only women.


At the end of the simulation (when everyone is happy), notice the number of single-sex groups. Are there more than at the start?


Try varying TOLERANCE. Is there a critical tolerance at which each all groups end up being single-sex? At different tolerance levels, does it take longer or shorter for everyone to become comfortable?

See how many mixed groups (not a single-sex group) you can get.

Using the GO ONCE button, 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 never reaches a stable state? (i.e. the model never stops running)

Observe real parties. Is this model descriptive of real social settings? What tolerance level do real people typically have?


Add more attributes to the model. Instead of male/female, try a trait that has more than two types, like race or religion. (You might use NetLogo's breeds feature 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 two 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.


Most NetLogo models put the origin (0,0) in the center of the world, but here, we have placed the origin near the right edge of the world and most of the patches have negative X coordinates. This simplifies the math for situating the groups.

Horizontal wrapping is enabled, but vertical wrapping is disabled. Thus, the world topology is a "vertical cylinder".

Notice the use of the mod primitive to space out the groups evenly. Setting up the groups in this manner allows for easy movement from group to group.




This model is based on the work of the pioneering economist Thomas Schelling: Schelling, T. (1978). Micro-motives and Macro-Behavior. New York: Norton.

See also: Resnick, M. & Wilensky, U. (1998). Diving into Complexity: Developing Probabilistic Decentralized Thinking through Role-Playing Activities. Journal of Learning Sciences, Vol. 7, No. 2.


If you mention this model or the NetLogo software in a publication, we ask that you include the citations below.

For the model itself:

Please cite the NetLogo software as:


Copyright 1997 Uri Wilensky.


This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit 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

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.

This model was converted to NetLogo as part of the projects: PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN CLASSROOMS and/or INTEGRATED SIMULATION AND MODELING ENVIRONMENT. The project gratefully acknowledges the support of the National Science Foundation (REPP & ROLE programs) -- grant numbers REC #9814682 and REC-0126227. Converted from StarLogoT to NetLogo, 2001.

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

globals [
  group-sites    ;; agentset of patches where groups are located
  boring-groups  ;; how many groups are currently single-sex

turtles-own [
  happy?         ;; true or false

to setup
  set group-sites patches with [group-site?]
  set-default-shape turtles "person"
  create-turtles number [
    choose-sex                   ;; become a man or a woman
    set size 3                   ;; be easier to see
    set my-group-site one-of group-sites
    move-to my-group-site
  ask turtles [ update-happiness ]
  ask turtles [ spread-out-vertically ]

to go
  if all? turtles [happy?]
    [ stop ]  ;; stop the simulation if everyone is happy
  ask turtles [ move-to my-group-site ]  ;; put all people back to their group sites
  ask turtles [ update-happiness ]
  ask turtles [ leave-if-unhappy ]
  ask turtles [
    set my-group-site patch-here

to update-happiness  ;; turtle procedure
  let total count turtles-here
  let same count turtles-here with [heading = [heading] of myself]
  let opposite (total - same)
  ;; you are happy if the proportion of people of the opposite sex
  ;; does not exceed your tolerance
  set happy? ((opposite / total) <= (tolerance / 100)) and (total >= 3) and (total <= 20)

    ;; Women
  if happy? and (heading = 180)
  [set color 16]
  if not happy? and (heading = 180)
  [set color 117]

  ;; Men
  if happy? and (heading = 0)
  [set color 96]
  if not happy? and (heading = 0)
  [set color 57]

to leave-if-unhappy  ;; turtle procedure
  if not happy? [
    set heading one-of [90 270]  ;; randomly face right or left
    fd 1                         ;; leave old group

to find-new-groups
  display   ;; force display update so we see animation
  let malcontents turtles with [not member? patch-here group-sites]
  if not any? malcontents [ stop ]
  ask malcontents [ fd 1 ]

to-report group-site?  ;; patch procedure
  ;; if your pycor is 0 and your pxcor is where a group should be located,
  ;; then you're a group site.
  ;; In this model (0,0) is near the right edge, so pxcor is usually
  ;; negative.
  ;; first figure out how many patches apart the groups will be
  let group-interval floor (world-width / num-groups)
    ;; all group sites are in the middle row
    (pycor = 0) and
    ;; leave a right margin of one patch, for legibility
    (pxcor <= 0) and
    ;; the distance between groups must divide evenly into
    ;; our pxcor
    (pxcor mod group-interval = 0) and
    ;; finally, make sure we don't wind up with too many groups
    (floor ((- pxcor) / group-interval) < num-groups)

to spread-out-vertically  ;; turtle procedure
  if (color = 16) or (color = 117)
    [ set heading 180 ]  ;; face south
  if (color = 96) or (color = 57)
    [ set heading   0 ]  ;; face north
  fd 4                   ;; leave a gap
  while [any? other turtles-here] [
    if-else can-move? 2 [
      fd 1
    [ ;; else, if we reached the edge of the screen
      set xcor xcor - 1  ;; take a step to the left
      set ycor 0         ;; and move to the base a new stack
      fd 4

to count-boring-groups
  ask group-sites [
    ifelse boring?
      [ set plabel-color gray  ]
      [ set plabel-color white ]
  set boring-groups count group-sites with [plabel-color = gray]

to-report boring?  ;; patch procedure
  ;; To see whether this group is single sex, we collect the colors
  ;; of the turtles into a list, then remove all the duplicates
  ;; from the list.  If the result is a list with exactly one color
  ;; in it, then the group is single sex.
  report length remove-duplicates ([color] of turtles-here) = 1

to update-labels
  ask group-sites [ set plabel count turtles-here ]

;;; color procedures

;; Blue represents male, pink represents female. No stereotypes are meant
;; to be promoted. Simply change the colors right here if you'd like.

to choose-sex  ;; turtle procedure
  set heading one-of [180 0]

to-report woman?  ;; turtle procedure
  report heading = 180

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

There is only one version of this model, created 6 months ago by Kaylin Ervay.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.