Dice Stalagmite HubNet

Dice Stalagmite HubNet preview image

3 collaborators

Uri_dolphin3 Uri Wilensky (Author)
Josh3 Josh Unterman (Author)
Dor Abrahamson (Author)

Tags

hubnet 

Tagged by Reuven M. Lerner over 9 years ago

Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 5.0beta5 • Viewed 327 times • Downloaded 18 times • Run 0 times
Download the 'Dice Stalagmite HubNet' modelDownload this modelEmbed this model

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


WHAT IS IT?

Dice Stalagmite HubNet is a Participatory Simulation Activity (PSA) in probability for exploring dependent and independent events. Specifically, you compare the outcome distribution of a compound event, the sum of two randomly "rolled" dice, to the outcome distribution of independent events, the values of these same dice, taken one die at a time.

This model is a part of the ProbLab curriculum. The ProbLab curriculum is currently under development at the CCL. For more information about the ProbLab Curriculum please refer to http://ccl.northwestern.edu/curriculum/ProbLab/.

HOW IT WORKS

Participants each roll their own pair of dice (preferably dice of different colors) and input the outcome, for example, "5 2", through the client interface. Each outcome appears at the top middle of the server interface, in the form of the same two dice. Then, this pair is duplicated, and one pair moves to the right (the pair), and the other pair moves to the left (the singles). On each side, there is a "picture bar chart": on the right, the bar chart is for sums of dice (2 through 12) and on the left, the bar chart is for individual die values (1 through 6). The dice have to find their columns and slide down those columns. On the right, the dice find the column of their sum, and on the left, the dice each finds its own column of its value. The events in each of the charts are mirrored in their respective histograms.

As the dice stack up, you begin to notice different typical distributions in each bar chart. The "singles" chart (SINGLE DICE), on the left, grows to become equally distributed. It's never really "flat," but we can never predict in advance which column will "win." On the other hand, the "pairs" bar chart (PAIR SUMS), on the right, always grows to the shape of a triangle -- the closer a column is to the middle of the of chart, the taller it will be, eventually.

This triangle of pairs emerges as a result of the probabilities of rolling each sum with a pair of dice. These probabilities can be found by examining the number of ways there are to roll each sum, as shown below.

                           61
                        51 52 62
                     41 42 43 53 63
                  31 32 33 34 44 54 64
               21 22 23 24 25 35 45 55 65
            11 12 13 14 15 16 26 36 46 56 66

For example, there are four ways to roll a 5 (14, 23, 32 and 41), and thus the probability of rolling a 5 is 4/36, or 1/9.

A printable sheet graphically depicting all of the combinations can be found here:
http://ccl.northwestern.edu/curriculum/ProbLab/dice-total-distrib.doc

HOW TO USE IT

Make sure all participants are connected and have their clients. Press GO. Participants each roll their own pair of dice and then use their interface to input the result of the roll. It is helpful (but not absolutely important) to have dice of different colors, because then you can differentiate between, say, a "2 5" and a "5 2." That is helpful for comparing the outcomes to the combinatorial analysis of a pair of dice.

Make sure your participants understand the difference between the two charts and how the dice find their columns (independently, on the left, and as a pair, on the right). You can use the RANDOM-ROLL button and the speed slider to show this.

Once you see that the sums chart is beginning to grow its "bump" in the middle, ask the participants if they are noticing anything. If not, keep playing until participants notice the bump. If you have worked on the combinatorial analysis of a pair of dice, participants may realize that they are getting in the pairs chart (PAIR SUMS) the same triangular shape they got in that analysis (see the ProbLab materials for this triangular shaped combinatorial space of a pair of dice). A useful discussion could be around why an experiment with random outcomes mirrors the shape of a chart you built through careful analysis. Note that the combinatorial-analysis chart has no duplicates -- each combination appears only once -- whereas the experiment does have duplicates.

IMPORTANT NOTE: Because there is limited space in the view, when dice are stacking up near the top of either the singles area or the pairs area, the program bumps the die columns down, so that they can keep growing. A useful way to think about this is that you are always looking at only the top section of each dice stack. The plots, however, keep track of all the dice that have been rolled.

Buttons:
SETUP -- reset the dice in the world but keep the logged in clients.

GO -- GO needs to be running so that participants can submit their dice rolls, and so that the dice can move (e.g. from RANDOM-ROLL).

RANDOM-ROLL -- creates a random pair of dice that behaves the same as though it had been input by a client. This is useful for preparing for class, for demonstrations to the classroom, and for boosting the activity of a relatively small group of participants.

AUTO-FILL -- creates random pairs in a loop.

Switches:
COLORED-DICE? -- when set to "On", the dice that are created will be color-coded (from a set of 12 different colors) based on what client "rolled" them.

Monitors:
ROLLS -- the total number of rolls performed including random rolls and rolls from clients.

Plots:
SINGLE DICE -- histogram of independent outcomes of rolling dice (each die value is a separate event).

PAIR SUMS -- histogram of compound outcomes from rolling dice (each sum of a pair of dice is an event).

To start the activity over with the same group of students stop the GO button by pressing it again, press the SETUP button, and press GO again. To run the activity with a new group of students press the RESET button in the Control Center.

THINGS TO NOTICE

The more events you stack up in the charts, the more the PAIR SUMS chart will take on a triangular shape. Eventually, the '7' column will be the tallest, and then, in descending order, the '5' and '8,' the '4' and '9,' the '3' and '10,' the '2' and '11,' and the '1' and '12.' The chart will not necessarily be perfect, but the more input the program gets, the closer the chart will approach this shape.

At the same time, the SINGLE DICE graph approaches the shape of an equal distribution.
The SINGLE DICE is never exactly equally distributed. If you look at the chart, you'll see that one of the columns is "beating" the other columns. So why do we call it "equally distributed" if it's not really equal? Well, it may depend on whether we are attending to the differences between the heights of the columns (an "additive" approach) or if we're attending to the proportions of the heights (a "multiplicative" approach). Once you've accumulated hundreds of pairs of dice, one column may be over ten rows taller than another, but when you look at its plot, SINGLE DIE, this difference will not appear as large as it is in the bar chart of the display.

THINGS TO TRY

If you are working alone on this PSA, for instance, if you are preparing for class, press GO and then type in the Command Center: simulate 1000. This will allow you to see how the charts will look after, say, 30 students have each input 34 rolls.

EXTENDING THE MODEL

Why settle for a pair of dice? How would the charts look for three dice? Do you expect any difference in the shapes of the outcome distributions? Would the SINGLE DICE graph change at all?

NETLOGO FEATURES

This model animates the movement of the dice and uses the display command to show the intermediate states.

RELATED MODELS

See the ProbLab model Dice Stalagmite that is essentially the same activity but is designed to be used by a single person. See the ProbLab model 9-Block Stalagmite that conveys the same ideas as this model does but uses a different stochastic object (not a pair of dice).

CREDITS AND REFERENCES

Thanks to Dor Abrahamson for his work on the design of this model and the ProbLab curriculum. Thanks to Josh Unterman for building Dice Stalagmite and to Steve Gorodetskiy for converting it to the Dice Stalagmite HubNet.

HOW TO CITE

If you mention this model in a publication, we ask that you include these citations for the model itself and for the NetLogo software:

COPYRIGHT AND LICENSE

Copyright 2004 Uri Wilensky.

CC BY-NC-SA 3.0

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ 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 uri@northwestern.edu.

This activity and associated models and materials were created 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.

Comments and Questions

Click to Run Model

globals [
  generators             ;; patches where the dice (both singles & pairs) appear
  single-outcomes        ;; list of all the single dice rolls
  pair-outcomes          ;; list of all the sums from rolling pairs of dice
  top-row                ;; agentset of just the top row of patches
  rolls                  ;; the total number of rolls performed either by clients or random rolls
]

breed [paired-dice paired-die]   ;; dice that are paired (go to the right)
breed [single-dice single-die]   ;; dice that are alone (go to the left)
breed [stacked-dice stacked-die] ;; dice that are stationary in the histogram
breed [clients client]

patches-own [
  column     ;; what number (single die or sum of pair) this column of patches is for
]

paired-dice-own [
  die-value   ;; value of the die 1-6
  pair-sum    ;; sum with partner 2-12
]

single-dice-own [
  die-value   ;; value of the die 1-6
]

clients-own
[
  user-id     ;; hubnet identifier
  user-color  ;; color assigned to this user (though colors may be reused)
  die1        ;; values currently entered in the
  die2        ;; client choosers
]

;;
;; Setup Procedures
;;

to startup
  clear-all
  setup
  hubnet-reset
end 

to setup
  ;; get rid of all the existing dice
  ask single-dice [ die ]
  ask paired-dice [ die ]
  ask stacked-dice [ die ]
  clear-all-plots
  set single-outcomes []
  set pair-outcomes []
  set rolls 0

 ;; assign outcomes to columns
  ask patches with [pxcor > 0] [
    set column floor ((pxcor + 1) / 2)
  ]
  ask patches with [pxcor < 0] [
    set column pxcor - min-pxcor  + 1
  ]

  ;; color patches
  ask patches [ set pcolor gray + 2 ]
  ask patches with [column != 0 and (column != 1 or pxcor < 0) ] [
    ifelse column mod 2 = 0
      [ set pcolor gray - 3 ]
      [ set pcolor red - 4 ]
  ]

  ;; patches in the 1 column of the pairs histogram
  ;; are removed since 1 is not a possible sum.
  ask patches with [ pcolor = gray + 2 ]
  [ set column 0 ]

  ;; set up agentsets
  set top-row patches with [pycor = max-pycor]
  set generators top-row with [pxcor = 0 or pxcor = 1]
end 

;;
;; Runtime Procedures
;;

to go
  bump-down stacked-dice with [pxcor < 0]
  bump-down stacked-dice with [pxcor > 0]

  while [any? single-dice or any? paired-dice] [
    move-paired-dice
    move-single-dice
    display    ;; force the view to update, so we see the dice move smoothly
  ]

  ;; check to see if clients have sent any messages
  listen-clients

  display ;; force the view to update, so we see the dice move smoothly
end 

to move-paired-dice
  ;; if either of the two dice isn't at the right column yet,
  ;; both dice move
  ask paired-dice
  [
    ifelse pair-sum != column
    [ fd 2 ]
    [
        ;; if at the bottom of the view, check if we should go "underwater"
        if pycor = min-pycor
        [ paired-die-check-visible ]
        fall
     ]
  ]
end 

to move-single-dice
  ;; two single dice may be falling in the same column, so we have
  ;; to make sure that the bottom one moves before the top one,
  ;; otherwise they could get confused
  let how-many count single-dice
  if how-many > 0 [
    ask min-one-of single-dice [pycor] [ move-single-die ]
  ]
  if how-many > 1 [
    ask max-one-of single-dice [pycor] [ move-single-die ]
  ]
end 

to move-single-die  ;; single-die procedure
  ifelse die-value != column
    [ fd 1 ]
    [ ;; if at the bottom of the view, check if we should go "underwater"
      if pycor = min-pycor [ single-die-check-visible ]
      fall
    ]
end 

to fall  ;; single-die or paired-die procedure
  set heading 180
  ifelse (pycor > min-pycor) and (not any? stacked-dice-on patch-ahead 1)
    [ fd 1 ]
    ;; stop falling
    [ ;; changing breeds resets our shape, so we have to remember our old shape
      let old-shape shape
      set breed stacked-dice
      set shape old-shape
    ]
end 

;; determines if my column is tall enough to be seen

to single-die-check-visible  ;; single-die procedure
  if single-outcomes = [] [ stop ]
  let mode first modes single-outcomes
  let height-of-tallest-column length filter [? = mode] single-outcomes
  let height-of-my-column length filter [? = die-value] single-outcomes
  if (height-of-tallest-column - height-of-my-column) >= world-height - 2 [ die ]
end 

;; determines if my column is tall enough to be seen

to paired-die-check-visible  ;; paired-die procedure
  if pair-outcomes = [] [ stop ]
  let mode first modes pair-outcomes
  let height-of-tallest-column length filter [? = mode] pair-outcomes
  let height-of-my-column length filter [? = pair-sum] pair-outcomes
  if (height-of-tallest-column - height-of-my-column) >= world-height - 2 [ die ]
end 

to bump-down [candidates]
  while [any? candidates with [pycor = max-pycor - 2]] [
    ask candidates [
      if pycor = min-pycor [ die ]
      fd 1
    ]
  ]
end 

;;creates a new pair of dice (both singles and pairs) [given the die values]

to generate-roll [ die-1 die-2 the-color]
  let die-values (list die-1 die-2)
  let leftmost-pxcor min [pxcor] of generators

  ;;ask each generator patch to create a pair (one die, with breed pair), with the values
  ask generators [
    let index pxcor - leftmost-pxcor
    sprout-paired-dice 1 [
      set color the-color
      set die-value item index die-values
      set shape word "die " die-value
      set heading 90
    ]
  ]

  ;; clone the paired dice to make the single dice
  ask paired-dice [
    hatch-single-dice 1 [
      set heading 270
      ;; changing breeds resets our shape, so we must explicitly adopt
      ;; our parent's shape
      set shape [shape] of myself
    ]
  ]

  ;; set the sum variable of the pairs
  let total sum [die-value] of paired-dice
  ask paired-dice
  [
    set pair-sum total
  ]
  ;; add to outcomes lists
  set pair-outcomes lput total pair-outcomes
  ask single-dice [ set single-outcomes lput die-value single-outcomes ]

  set rolls rolls + 1
end 

;;
;; Procedures for generating sample outputs
;;

to random-roll
  ;; generates a random pair
  generate-roll (1 + random 6) (1 + random 6) white
  update-plots
end 

;; keep doing a random-roll continuously

to auto-fill
  random-roll
  repeat 3 [ go ]
end 

;; runs the simulation num times

to simulate [ num ]
  repeat num
  [
    random-roll
    repeat 2 [ go ]
  ]
 repeat 70 [ go ]
end 

;;
;; HubNet Procedures
;;

to listen-clients
  if hubnet-message-waiting?
  [
    hubnet-fetch-message
    ;;creates a new client turtle if new HubNet client joining
    ifelse hubnet-enter-message?
    [ create-client ]
    [
      ;;if a HubNet client quit, kill client turtle
      ifelse hubnet-exit-message?
      [
         ask clients with [ user-id = hubnet-message-source ]
          [ die ]
      ]
      ;;if just a message from the client, execute appropriately
      [
        ask clients with [ user-id = hubnet-message-source ]
          [ exe-cmd hubnet-message ]
      ]
    ]
  ]
end 

to create-client
  ;; makes a turtle to store the data specific to this particular
  ;; client , sets the values of dice to a default and sets
  ;; the user-id variable to the hubnet-source
  create-clients 1
  [
    ht
    set user-id hubnet-message-source
    set user-color item (count clients mod length base-colors) base-colors
    set die1 "--"
    set die2 "--"
  ]
end 

to exe-cmd [ message ] ;; client procedure
  if hubnet-message-tag = "Die_A"
  [ set die1 message stop ]
  if hubnet-message-tag = "Die_B"
  [ set die2 message stop ]
  if hubnet-message-tag = "Submit"
  [
    ;; if one of the choices is not a number
    ;; report an error
    ifelse die1 = "--" or die2 = "--"
    [
      hubnet-send user-id "Message:" "Please select values for both dice."
    ]
    [
      ;; clear the user's interface
      hubnet-send user-id "Die_A" "--"
      hubnet-send user-id "Die_B" "--"

      ;; generate the pair and the singles
      generate-roll die1 die2 ifelse-value colored-dice? [ user-color ][ white ]
      ;; send confirmation message to user
      hubnet-send user-id "Message:" (word "Thank you. Your input was " die1 "-" die2 ".")

      ;; reset the client-turtle's variables
      set die1 "--"
      set die2 "--"
      update-plots
    ]
  ]
end 


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

There are 7 versions of this model.

Uploaded by When Description Download
Uri Wilensky over 9 years ago Updated to NetLogo 5.0.4 Download this version
Uri Wilensky almost 10 years ago Updated version tag Download this version
Uri Wilensky almost 10 years ago Updated to version from NetLogo 5.0.3 distribution Download this version
Uri Wilensky over 10 years ago Updated to NetLogo 5.0 Download this version
Uri Wilensky over 12 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 12 years ago Dice Stalagmite HubNet Download this version
Uri Wilensky over 12 years ago Dice Stalagmite HubNet Download this version

Attached files

File Type Description Last updated
Dice Stalagmite HubNet.png preview Preview for 'Dice Stalagmite HubNet' over 9 years ago, by Uri Wilensky Download

This model does not have any ancestors.

This model does not have any descendants.