Two-Thirds Guess Game

Two-Thirds Guess Game preview image

1 collaborator

Default-person Curtis Frye (Author)

Tags

game theory 

Tagged by Curtis Frye over 7 years ago

look ahead 

Tagged by Curtis Frye over 7 years ago

look ahead8 

Tagged by Curtis Frye over 7 years ago

look ahead_ 

Tagged by Curtis Frye over 7 years ago

Visible to everyone | Changeable by the author
Model was written in NetLogo 5.3.1 • Viewed 769 times • Downloaded 63 times • Run 0 times
Download the 'Two-Thirds Guess Game' modelDownload this modelEmbed this model

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


ACKNOWLEDGMENTS

I created this model for my final project in the Santa Fe Institute's Introduction to Agent-Based Modeling course offered during the Fall 2016 term.

My work is based on the El Farol model from Chapter Three of the book "Introduction to Agent-Based Modeling: Modeling Natural, Social and Engineered Complex Systems with NetLogo", by Uri Wilensky & William Rand.

  • Wilensky, U. & Rand, W. (2015). Introduction to Agent-Based Modeling: Modeling Natural, Social and Engineered Complex Systems with NetLogo. Cambridge, MA. MIT Press.

The El Farol model can be found in the IABM Textbook folder of the NetLogo Models Library. That model, as well as any updates to the model, can also be found on the textbook website: http://www.intro-to-abm.com/. This model (TwoThirdsGuess) can be found online at http://www.curtisfrye.com/two-thirds.nlogo.

WHAT IS IT?

Many popular logic problems ask solvers to think ahead several steps (and account for others' logical processes) to come to the correct answer. One example from this class of problems is the "Two-Thirds of the Average Guess" game. All players are asked to write down a number from 0 to 100 that will be two-thirds of the average guess. For example, if five players guess 20, 15, 10, 10, and 5, the average guess is 60 / 5 = 12, two-thirds of which is 8.

The logical chain for a skilled player runs as follows: I want to guess two-thirds of the average guess, so I'll start by thinking the other players will guess 66, which is two-thirds of the maximum. Therefore, I should guess 44. However, if the other players know that and will guess 44, then I should guess 30, which is two-thirds of 44. Of course, if the other players carry their logic that far, I should guess 20, which is two-thirds of 30. This line of reasoning continues to generate ever-decreasing values until all players realize they should guess zero.

The above description assumes all players are perfectly logical and identify the correct solution. That's not always the case, so the model lets you create a number of unskilled players who make random guesses within a range you identify.

HOW IT WORKS

The skilled agents in the model attempt to guess a number that will be two-thirds of the average guess, which is calculated by multiplying CROWD-GUESS (the mean of all agent guesses for the current turn) by 0.67. To formulate its guess, each agent has access to a set of prediction strategies and the actual CROWD-GUESS values from previous turns. A prediction strategy is represented as a list of weights that determines how the agent believes that each time period of the historical data affects the prediction for the current turn. One of these weights (the first one) is a constant term which allows the baseline of the prediction to be modified. This definition of a strategy is based on an implementation of Arthur's model (cited below under CREDITS AND REFERENCES) as revised by David Fogel et al. (1999). The agent decides which one of its strategies to use by determining which one would have done the best had they used it in the preceding turns.

The number of potential strategies an agent has is given by NUMBER-STRATEGIES, and these potential strategies are distributed randomly to the agents during SETUP. As the model runs, at any one tick each agent will only utilize one strategy, based on its previous ability to predict the winning guess. In this version of the model, skilled agents are given strategies and do not change them once they have them, however since they can change their strategies at any time based on performance, the ecology of strategies being used by the whole population changes over time. The length of the winning guess history the agents can use for a prediction or evaluation of a strategy is given by MEMORY-SIZE. This evaluation of performance is carried out in UPDATE-STRATEGIES, which does not change the strategies, but rather updates the performance of each strategy by testing it, and then selecting the strategy that has the best performance given the current data. In order to test each strategy its performance on MEMORY-SIZE past turns is computed. To make this work, the model actually records twice the MEMORY-SIZE historical data so that a strategy can be tested MEMORY-SIZE turns into the past still using the full MEMORY-SIZE data to make its prediction.

When the Two-Thirds-Guess game is played by humans, some (but not all) players are able to discern the logical reasoning chain. Some players give up after a couple of steps, while others guess more or less randomly within a range of values. The more unskilled players there are, the more randomly the winning guesses will be distributed. In the author's personal experience, the winning guess for a group of 60-100 players is around 23.

HOW TO USE IT

The NUMBER-STRATEGIES slider controls how many strategies each agent keeps in its memory. The MEMORY slider controls how far back, in turns, agents remember. The NUMBER-UNSKILLED-PLAYERS slider controls how many unskilled players occur within the total of 100 players, while the UNSKILLED-MINIMUM and UNSKILLED-MAXIMUM sliders set the upper and lower bounds for unskilled player guesses. To run the model, set the NUMBER-STRATEGIES, MEMORY size, NUMBER-UNSKILLED-PLAYERS, UNSKILLED-MINIMUM, and UNSKILLED-MAXIMUM sliders, click SETUP, and then click GO.

The GUESSES plot shows the mean crowd guess and value of the winning guess over time.

THINGS TO NOTICE

When all players are skilled, the winning guess quickly approaches and stays near zero. The variation from the purely rational result of zero appears to be a function of the random weights given to CROWD-GUESS values from previous turns.

As you increase the number of unskilled players, WINNING-GUESS settles at a value that appears to be a function of the number of unskilled players and their associated UNSKILLED-MINIMUM and UNSKILLED-MAXIMUM values.

THINGS TO TRY

Try running the model with different settings for MEMORY-SIZE and NUMBER-STRATEGIES. Does it take longer to settle at an equilibrium? If all players are skilled, how close does the model approach zero when it settles down? What happens to the variability in the winning guess as you decrease NUMBER-STRATEGIES? What happens to the variability in the plot if you decrease MEMORY-SIZE?

Try changing the settings for NUMBER-UNSKILLED-PLAYERS, UNSKILLED-MINIMUM, and UNSKILLED-MAXIMUM. How do these settings affect the equilibrium value range?

EXTENDING THE MODEL

Currently the weights that determine each strategy for skilled players are randomly generated during the model setup. Try altering the weights that are possible during setup so that they only reflect a mix of the following agent strategies:

  • always predict two-thirds of the previous guess
  • an average of the last several weeks' winning guesses
  • the guess that would have won two turns ago

Can you think of other simple rules one might follow?

Can you apply other machine learning techniques, such as genetic algorithms, to generate winning strategies?

Can you think of a better way to measure the success of strategies and calculate the best-strategy?

Can you predict the equilibrium winning guess value as a function of the input values, especially NUMBER-UNSKILLED-PLAYERS, UNSKILLED-MINIMUM, and UNSKILLED-MAXIMUM?

NETLOGO FEATURES

Lists are used to represent strategies and guess histories.

n-values is useful for generating random strategies.

RELATED MODELS

In the NetLogo models library:

The classic El Farol Model.

Arthur's original model (cited below) has been generalized as the Minority Game and is included in the Social Sciences section of the NetLogo models library.

Wilensky, U. (2004). NetLogo Minority Game model. http://ccl.northwestern.edu/netlogo/models/MinorityGame. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

There is also a participatory simulation version of the Minority Game model in the models library.

Stouffer, D. & Wilensky, U. (2004). NetLogo Minority Game HubNet model. http://ccl.northwestern.edu/netlogo/models/MinorityGameHubNet. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

There is an alternative implementation of the El Farol model with more parameters that is part of the NetLogo User Community Models.

CREDITS AND REFERENCES

This model is adapted from:

Rand, W. and Wilensky, U. (1997). NetLogo El Farol model. http://ccl.northwestern.edu/netlogo/models/ElFarol. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

The El Farol model was inspired by a paper by W. Brian Arthur. "Inductive Reasoning and Bounded Rationality", W. Brian Arthur, The American Economic Review, 1994, v84n2, p406-411.

David Fogel et al. also built a version of the El Farol model using a genetic algorithm. "Inductive reasoning and bounded rationality reconsidered", Fogel, D.B.; Chellapilla, K.; Angeline, P.J., IEEE Transactions on Evolutionary Computation, 1999, v3n2, p142-146.

HOW TO CITE

This model is a final project from the Fall 2016 edition of the Santa Fe Institute's Introduction to Agent-Based Modeling class. It is based in large part on the El Farol model, which is described in the textbook, “Introduction to Agent-Based Modeling: Modeling Natural, Social and Engineered Complex Systems with NetLogo.”

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

For the model itself:

Please cite the NetLogo software as:

Please cite the textbook as:

  • Wilensky, U. & Rand, W. (2015). Introduction to Agent-Based Modeling: Modeling Natural, Social and Engineered Complex Systems with NetLogo. Cambridge, MA. MIT Press.

COPYRIGHT AND LICENSE

Copyright 2016 Curtis Frye.

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 https://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 Curtis Frye at cfrye@techsoc.com.

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.

Uploaded by When Description Download
Curtis Frye over 7 years ago Select number that will be two-thirds of the average guess. Download this version
Curtis Frye almost 9 years ago Initial upload Download this version

Attached files

File Type Description Last updated
Two-Thirds Guess Game.png preview Two-Thirds Preview Image almost 9 years ago, by Curtis Frye Download

This model does not have any ancestors.

This model does not have any descendants.