# Shuffle Board

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

## WHAT IS IT?

Shuffle Board investigates distributions of favored events in a series of outcomes. The basic analogy is that there are a lot of candy boxes, but only some have prizes in them. You are buying one candy box after another, waiting for prizes, and keeping track of two things: how many boxes do you need to buy until you get a prize? When you had lucky streaks, how long were they?

A possibly counter-intuitive result in this simulation is that the shorter the "waiting time," the more frequently it occurs. Another result is that the shorter the "lucky streak," the more frequently it occurs.

Shuffle Board explores the relation between the length of the "waiting time" and its frequency, and between the length of a lucky streak and its frequency. This exploration is designed to help learners understand the mathematical functions associated with these distributions.

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

The basic analogy underlying Shuffle Board is that there are a lot of candy boxes, but only some of them have prizes in them (like a blue teddy bear). You know how long it should take you, on average, to get a prize, because this information is announced by the candy manufacturer. You are buying one candy box after another and keeping track of two things:

- How many boxes did you need to buy since last prize until you got the next prize?
- When you had lucky streaks, how long were they?

Both are plotted automatically in the "Frequency of Distances to Prizes" and "Frequency of Streaks by Length" graphs.

The view features yellow lines that are broken by blue dots (candy boxes without prizes) and colored squares (candy boxes with prizes). Each blue dot or colored square is an "outcome". So think of a very long string with 121 outcomes that has been chopped up into 11 shorter strings, each with 11 outcomes, so as to fit into the View. The string runs from the top left spot on the board (the first outcome) towards the right. When it gets to the end of the top row, it skips to the left-most spot on the second row from top, and so on. When it gets to the bottom-right corner, it counts on to the top left corner, as though the string is closed in a necklace.

When you first open the model and whenever you press Setup, prizes are distributed uniformly across the View according to the settings of the slider 'average-distance'. For instance, if this slider is set to '5', then literally every 5th outcome will be a prize. Next, the prizes shuffle randomly to new locations on the board, so this initial uniform distribution is upset.

Why do we shuffle? We are exploring for hidden distribution patterns. Sometimes it takes a lot of data to find hidden patterns. If we had space in the view for thousands of boxes, we would have enough data to find any patterns that might be there. But there is not enough room in the view to make the boxes big enough so you can see the prizes. So, instead, we shuffle. It is as though each time we get another bit out of a larger population -- it is as though each shuffle gives us a new sample. After each shuffle, you can track individual prizes as they move from one location to another.

Note that the string of outcomes is forms a loop. So if at the tail end of the string -- towards the bottom-right corner -- there are 4 boxes without prizes, these will count towards the first prize in the top row.

## HOW TO USE IT

Sliders:

AVERAGE-DISTANCE -- If set at, say, 5, then every 5th square will bear a prize, when you press Setup.

TRUNCATE-AFTER-COLUMN -- determines how many of the "Distances to Prizes" histogram columns, beginning from left, will be included in the calculation of the mean ratio between consecutive columns. For instance, if this slider is set at "4", then the program will calculate the quotients of Column 2 divided by Column 1, Column 3 divided by Column 2, and Column 4 divided by Column 3. Next, the program will determine the mean of these three quotients and report them in the "Columns-Factor" monitor.

Switches:

PRIZE-SHAPES? -- if set to 'On', you will see what prize is waiting for you in each candy box. When set to 'Off', you will know that there is a prize in the box, but you will not know what it is.

LABELS? -- if set to 'On', each prize box will show how many boxes had to be bought since the previous box so as to get this prize.

Buttons:

SETUP -- initializes variables, creates a collection of prizes in accordance with the value of 'average-distance', and represents the distances to prizes and the lucky streaks in their respective plots.

GO ONCE -- Runs the program through a single 'Go' procedure, in which prizes are shuffled and their distances and streaks are calculated and plotted.

GO -- Runs the program over and over.

Monitors:

Columns Factor -- the height of each column in the histogram is divided by the height of the column immediately to its left. The monitor shows the mean of all these quotients. The total number of columns included in this calculation is determined by the slider 'truncate-after-column'.

Plots:

FREQUENCY OF DISTANCES TO PRIZES -- shows the accumulating distribution of distances between prizes in repeated samples.

FREQUENCY OF STREAKS BY LENGTH -- shows the accumulating distribution of streaks of consecutive successes

Note that after you press Setup, when you first click on 'Go' or 'Go Once', the plots initialize, but later they accumulate information from previous runs.

Set the 'average-distance' slider and press 'Setup'. Now press 'Go Once' and watch the histograms appear in the plots. If you press 'Go', the program will run indefinitely, until you press 'Go' again.

## THINGS TO NOTICE

When you press 'Go Once' the prizes rearrange on the board. Choose your favorite prize and track it. This way, you'll be sure that no prizes vanish!

After a single shuffle, what is the most common distance between every two consecutive prizes? You can see this in the View -- the number labels show these distances, and so you can count up how many "1"s you see, and how many "2"s, "3"s, etc. Also, look at the plot to see which bar is the highest. Keep looking at the plot over more runs. See the typical graph shape that forms.

As the program runs over and over, the value in the Column Factor monitor gradually converges.

## THINGS TO TRY

When you press Setup, you get a uniform distribution of prizes. After you shuffle the prizes, the distribution is not uniform. But what is the average distance between prizes now? In the Command Center, type

```
show precision mean target-color-differences-list 2
```

Now press Enter. This code calculates for you the mean distance between each two consecutive white patches. Can you explain the value you received?

Watch the value in the 'Column Factor' monitor. Can you find a relation between these relative heights and the 'average-distance' setting?

Play with the 'truncate-columns' slider. What does including more columns do as compared to including fewer columns? What, if any, is the relation of these actions to the value in the 'Columns Factor' monitor?

What is the relation between the value of average-distance and the curves you get in the plot 'Frequency of Streaks by Length'? Does this make sense to you?

Here is an experiment you can try without NetLogo that might shed more light on the model:

Set up a deck of cards that has 13 face cards and 39 number cards. That is a 1:3 ratio of faces to numbers. One fourth of the cards are faces. Thus, the probability that any random card drawn from this deck is a face is 1 out of 4 -- that is, a 25% chance. Now distribute the face cards uniformly in the deck so that literally every fourth card is a face. Next, shuffle the cards thoroughly. Still, every fourth card on average will be a face. But what is hiding behind this sense of "average" in "every fourth card on average is a face"? Count up to each face card and create a histogram of the frequencies of each number of attempts until success. What have you learned? Can you explain this? Note that two decks put together with the same "number:face" ratio (for a total of 26:78) will bring quicker results.

Shuffle Board is a NetLogo analogy to shuffling a deck of cards and then going through the cards one by one and counting how long it takes to find each face. To be precise, the shuffling procedure in this model is less rule governed than standard shuffling of cards (see for example http://www.sciencenews.org/articles/20001014/mathtrek.asp).

## EXTENDING THE MODEL

Add a plot to show how the Columns Factor value changes over time.

Add pens to the plots to represent the averages of the outcomes.

Add a switch that flips the orientation of the shuffle board so that distances to prizes are counted vertically instead of horizontally.

Choose a specific location on the View (one of the "patches") and monitor how often that location gets a prize over repeated shuffles. Design an experiment to determine any possible relationships between the frequency of getting a prize in that location and the setting of the 'average-distance' slider.

## RELATED MODELS

The model is closely related to Prob Graphs Basic, and especially to the middle graph in that model. That middle graph looks at distances or 'attempt-until-success' ("waiting time") between consecutive "hits" that are determined randomly according to a sample-space setting. Shuffle Board shows the same idea, but it does so using a more visible analogy that allows you to scan for yourself the distances between all of the favored events. This helps us understand that the shorter distances are more ubiquitous as compared to the longer distances. In particular, we see that the distance "1" is relatively dominant.

## CREDITS AND REFERENCES

This model is a part of the ProbLab curriculum. The ProbLab Curriculum is currently under development at Northwestern's Center for Connected Learning and Computer-Based Modeling. . For more information about the ProbLab Curriculum please refer to http://ccl.northwestern.edu/curriculum/ProbLab/.

Thanks to Ethan Bakshy for his extensive work on this model.

## 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:

- Abrahamson, D. and Wilensky, U. (2004). NetLogo Shuffle Board model. http://ccl.northwestern.edu/netlogo/models/ShuffleBoard. Center for Connected Learning and Computer-Based Modeling, Northwestern Institute on Complex Systems, Northwestern University, Evanston, IL.
- Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern Institute on Complex Systems, Northwestern University, Evanston, IL.

## COPYRIGHT AND LICENSE

Copyright 2004 Uri Wilensky.

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 model was 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

globals [ ;; the patch color that will signify a favored event. target-color ;; the patch color that will signify an unfavored event other-color ;; list of colors of all patches in the graphic window. pcolor-list ;; list of positions, in the graphic window, of all patches with the target-color ;; (the positions begin at the top-left corner, run across to the left, and then ;; hop to the beginning of the second-from-top row, and so on) target-color-list ;; list of the differences between each two consecutive patches with the target color ;; for instance, if the first three items in the target-color-list are 4, 9, and 11, ;; then the first two items in the target-color-differences-list will be 5 (9 - 4) and 2 (11 - 9) target-color-differences-list ;; cumulative list of consecutive blocks of successes of 1 or more target-color-successive-list just-started? ;; Boolean variable that indicates in Go if this is the first time through shape-names ;; list of shapes of prizes colors ;; list of colors of prizes max-possible-codes ;; number of shape/color combinations ] ;; lines are either straight "lines" with a circle in the center, representing a failed event ;; or "outlines" if they are a target event ;; prizes are the icons that appear inside the outlines breed [ lines line ] breed [ prizes prize ] patches-own [ ;; num is the a running number beginning from 0 at the top-left corner, ;; then running across the top row, then to the next row, etc. num next-patch ;; patch that is the "right" neighbor previous-patch ;;patch that is the "left" neighbor ;; steps-to-me shows, for a white patch, how many steps there are from the previous white patch up to it steps-to-me ] to initialize clear-all set target-color yellow set other-color black set target-color-differences-list [] set target-color-successive-list [] set just-started? true setup-colors-and-shapes set-plot-range end to setup initialize ask patches ;;set up [ set steps-to-me 0 sprout 1 [ set breed lines set shape "lines" set label-color black ] sprout 1 [ set breed prizes set size 0.5 set shape "blank"] ] assign-neighbors distribute-prizes count-steps-to-colored-patches collect-data re-label reset-ticks do-plot end to go ask patches [ set steps-to-me 0 ] if just-started? [ clear-plot set-plot-range set just-started? false set target-color-differences-list [] set target-color-successive-list [] ] shuffle-prizes tick count-steps-to-colored-patches re-label ask prizes [ ifelse prize-shapes? [ show-turtle ] [ hide-turtle ] ] collect-data do-plot end to setup-colors-and-shapes set shape-names ["box" "star" "target" "cat" "dog" "butterfly" "leaf" "car" "airplane" "monster" "key" "cow skull" "ghost" "cactus" "moon" "heart"] set colors [ gray brown green sky blue violet orange ] set colors lput ( gray - 2 ) colors set colors lput ( green - 2 ) colors set colors lput ( blue + 2 ) colors set colors lput ( red - 2 ) colors set colors lput ( turquoise - 1 ) colors set colors lput ( lime - 1 ) colors set colors lput ( cyan - 2 ) colors set colors lput ( magenta - 1 ) colors end ;; assign patches "next" and "previous" patches ;; patches essentially form a circular doubly linked list to assign-neighbors let i 0 ask patches [ set num i set i i + 1 ;;if we are at the edge, wrap around to determine the NEXT neighbor ifelse pxcor = max-pxcor [ ifelse pycor = min-pycor ;;if we are in the lower right corner, next neighbor is upper left [ set next-patch patch min-pxcor max-pycor ] ;;if we are all the way to the right, the next neighbor is one row below, on right [ set next-patch patch min-pxcor ( pycor - 1 ) ] ] [ set next-patch patch-at 1 0 ] ;;if we are at the edge, wrap around to determine the PREVIOUS neighbor ifelse pxcor = min-pxcor [ ifelse pycor = ( max-pycor ) ;;if we are in the upper left corner, previous neighbor is lower right [ set previous-patch patch ( max-pxcor ) min-pycor ] ;;if we are in the upper left corner, previous neighbor is lower right [ set previous-patch patch ( max-pxcor ) ( pycor + 1 ) ] ] [ set previous-patch patch-at -1 0 ] ] end ;; creates a uniform distribution of prizes patches according to the setting of 'average-distance' to distribute-prizes ask patches with [ num mod average-distance = 0 ] [ ask one-of lines-here [ set shape "outline" ] ask one-of prizes-here [ set shape one-of shape-names set color one-of colors if (not prize-shapes?) [hide-turtle] ] set pcolor target-color ] end ;; each target-colored patch swaps its prize's shape and color with a randomly chosen ;; other-colored patch. the target-colored cell is then replaced with a line shape and other-color. to shuffle-prizes ask patches with [pcolor = target-color] [ let prize1 one-of prizes-here ask one-of patches with [pcolor = other-color] [ set pcolor target-color ask one-of lines-here [ set shape "outline" ] ask one-of prizes-here [ set color [color] of prize1 set shape [shape] of prize1 ] ] set pcolor other-color ask one-of lines-here [ set shape "lines" ] ask one-of prizes-here [ set shape "blank" ] ] end ;; gathers histogram information to collect-data set target-color-differences-list sentence ( [ steps-to-me ] of patches with [ steps-to-me > 0 ] ) target-color-differences-list set target-color-successive-list sentence ( [ consecutive-targets 0 ] of patches with [ pcolor = target-color and patch-at -1 0 != target-color ] ) target-color-successive-list end to count-steps-to-colored-patches ask patches with [ pcolor = target-color ] [ set steps-to-me step-count 0 ] end ;; patch procedure ;; counts the number of previous patches that aren't the target-color to-report step-count [previous-count] ifelse [pcolor] of previous-patch != target-color [ report [ 1 + step-count previous-count ] of previous-patch ] [ report 1 ] end ;; patch procedure ;; counts the number of consecutive patches with prizes to-report consecutive-targets [num-previous-targets] ifelse [pcolor] of next-patch = target-color [ report [ 1 + consecutive-targets num-previous-targets ] of next-patch ] [ report 1 ] end ;; procedures for determining the mean ratio between consecutive columns in a histogram list ;; The logic is to create one list of all the columns heights and from that list create ;; a copy of it with the first item missing. Then we can 'map' one list onto the other ;; so that each item in one list divides an item in the other list that is in the corresponding position. ;; Also, we don't want columns that have zero items in them, because we cannot divide by zero. ;; Finally, we don't use more columns than is indicated by the value of the 'truncate-columns' slider. to-report relative-heights [ listerama ] if listerama = [] [ report "N/A" ] let binned-list but-first bin-list listerama let stop-bin min (list (position 0 binned-list) (position 1 binned-list) truncate-after-column) if stop-bin = 0 ;; if the smallest bin is 0, we cannot calculate relative-heights [ report "N/A" ] let list-of-divisors first-n stop-bin binned-list let list-of-dividends list-of-divisors set list-of-divisors but-last list-of-divisors set list-of-dividends but-first list-of-dividends if empty? list-of-divisors ;; if there are no divisors (or similarly, dividends) [ report "N/A" ] ;; it is not possible to calculate relative-heights report mean ( map [ ?1 / ?2 ] list-of-dividends list-of-divisors ) end to-report first-n [index full-list] ifelse (index > 0 and not empty? full-list) [ report sentence ( first full-list ) ( first-n ( index - 1 ) ( butfirst full-list ) ) ] [ report [] ] end to-report bin-list [input-list] if input-list = [] [ report [] ] let result [] let bin 0 foreach n-values ( max input-list + 1 ) [?] [ set bin ? set result lput ( length filter [ ? = bin ] input-list ) result ] report result end ;; after a shuffle, the number labels are updated to re-label ask lines [ ifelse label? [ if steps-to-me > 0 [ set color black set label steps-to-me ] ] [ set label "" ] ] end ;; code for plotting outcomes as histograms to set-plot-range set-current-plot "Frequency of Distances to Prizes" set-plot-x-range 1 ( 5 * average-distance ) set-current-plot "Frequency of Streaks by Length" ;; the following line uses a "magic number". The code used to be "15 - average-distance" ;; but that crashes when a user resets the average-distance slider to a higher maximum. set-plot-x-range 1 ( average-distance + round ( 20 / average-distance ) ) end to do-plot set-current-plot "Frequency of Distances to Prizes" histogram target-color-differences-list let maxbar modes target-color-differences-list let maxrange length ( filter [ ? = item 0 maxbar ] target-color-differences-list ) set-plot-y-range 0 max list 10 maxrange set-current-plot "Frequency of Streaks by Length" histogram target-color-successive-list set maxbar modes target-color-successive-list set maxrange length ( filter [ ? = item 0 maxbar ] target-color-successive-list ) set-plot-y-range 0 max list 10 maxrange end ; Copyright 2004 Uri Wilensky. ; See Info tab for full copyright and license.

There are 15 versions of this model.

## Attached files

File | Type | Description | Last updated | |
---|---|---|---|---|

Shuffle Board.png | preview | Preview for 'Shuffle Board' | about 10 years ago, by Uri Wilensky | Download |

This model does not have any ancestors.

This model does not have any descendants.