# Two-Thirds Guess Game

Model was written in NetLogo 5.3.1
•
Viewed 481 times
•
Downloaded 29 times
•
Run 0 times

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

Info tab cannot be displayed because of an encoding error

## Comments and Questions

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

Click to Run Model

globals [ crowd-guess ;; the current guess of the crowd winning-guess ;; 2/3 of the crowd-guess value history ;; list of past correct values (2/3 of average guess) winning-guess-patch ;; patch where we show the last winning guess as a label ] breed [ skilled a-skilled ] breed [ unskilled an-unskilled ] skilled-own [ strategies ;; list of strategies best-strategy ;; index of the current best strategy prediction ;; current prediction of the winning value ] unskilled-own [ prediction ;; current prediction of the winning value ] to setup clear-all set-default-shape turtles "person" ;; initialize the previous crowd guesses randomly so the agents have a history ;; to work with from the start set history n-values (memory-size * 2) [random 100] ;; the history is twice the memory, because we need at least a memory worth of history ;; for each point in memory to test how well the strategies would have worked set crowd-guess first history set winning-guess (crowd-guess * 0.67) ;; use one of the patch labels to visually indicate the guess ask patch (0.75 * max-pxcor) (0.5 * max-pycor) [ set winning-guess-patch self set plabel-color red ] ;; create the agents and give them random strategies ;; these are the only strategies these agents will ever have though they ;; can change which of this "bag of strategies" they use every tick create-skilled 100 - number-unskilled-players [ set color white move-to-empty-one-of patches set strategies n-values number-strategies [random-strategy] set best-strategy first strategies update-strategies ] create-unskilled number-unskilled-players [ set color orange move-to-empty-one-of patches ] ;; start the clock reset-ticks end to go ;; update the global variables ask winning-guess-patch [ set plabel winning-guess ] ;; each agent predicts attendance at the bar and decides whether or not to go ask turtles [ if breed = skilled [ set prediction predict-crowd-guess best-strategy sublist history 0 memory-size ] ] ;; update the guess history ;; remove oldest average guess and prepend latest average guess set history fput crowd-guess but-last history ;; the agents decide what the new best strategy is ask turtles [ update-strategies ] ;; display the new crowd-guess and winning-guess set crowd-guess abs (mean [prediction] of turtles) set winning-guess crowd-guess * 0.67 ;; advance the clock tick end ;; determines which strategy would have predicted the best results had it been used this round. ;; the best strategy is the one that has the sum of smallest differences between the ;; current crowd-guess and the predicted crowd-guess for each of the preceding ;; weeks (going back MEMORY-SIZE weeks) ;; this does not change the strategies at all, but it does (potentially) change the one ;; currently being used and updates the performance of all strategies to update-strategies ;; separate skilled from unskilled players ifelse breed = skilled [ ;; initialize best-score to a maximum, which is the lowest possible score let best-score memory-size * 100 + 1 foreach strategies [ ?1 -> let score 0 let week 1 repeat memory-size [ set prediction predict-crowd-guess ?1 sublist history week (week + memory-size) set prediction prediction * 0.67 set score score + abs (item (week - 1) history - prediction) set week week + 1 ] if (score <= best-score) [ set best-score score set best-strategy ?1 ] ] ] ;; now do the unskilled prediction [ set prediction (unskilled-minimum + (unskilled-maximum - unskilled-minimum) * random-float 1) ] end ;; this reports a random strategy. a strategy is just a set of weights from -1.0 to 1.0 which ;; determines how much emphasis is put on each previous time period when making ;; an attendance prediction for the next time period to-report random-strategy report n-values (memory-size + 1) [1.0 - random-float 2.0] end ;; This reports an agent's prediction of the current crowd-guess ;; using a particular strategy and portion of the attendance history. ;; More specifically, the strategy is then described by the formula ;; p(t) = x(t - 1) * a(t - 1) + x(t - 2) * a(t -2) +.. ;; ... + x(t - MEMORY-SIZE) * a(t - MEMORY-SIZE) + c * 100, ;; where p(t) is the prediction at time t, x(t) is the crowd-guess at time t, ;; a(t) is the weight for time t, c is a constant, and MEMORY-SIZE is an external parameter. to-report predict-crowd-guess [strategy subhistory] ;; the first element of the strategy is the constant, c, in the prediction formula. ;; one can think of it as the the agent's prediction of the crowd-guess ;; in the absence of any other data ;; then we multiply each week in the history by its respective weight report 100 * first strategy + sum (map [ [?1 ?2] -> ?1 * ?2 ] butfirst strategy subhistory) end ;; In this model it doesn't really matter exactly which patch ;; a turtle is on. Nonetheless, to make a nice visualization ;; this procedure is used to ensure that we only have one ;; turtle per patch. to move-to-empty-one-of [locations] ;; turtle procedure move-to one-of locations while [any? other turtles-here] [ move-to one-of locations ] end ; Elements of the El Farol model Copyright 2007 Uri Wilensky. ; Remaining elements Copyright 2016 by Curtis Frye ; See Info tab for full copyright and license.

There are 2 versions of this model.

## Attached files

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

Two-Thirds Guess Game.png | preview | Two-Thirds Preview Image | over 7 years ago, by Curtis Frye | Download |

This model does not have any ancestors.

This model does not have any descendants.