The Spatial Nash Bargaining Game

Dr J McKenzie Alexander

Department of Philosophy, Logic and Scientific Method
London School of Economics and Political Science

Description

This model implements the spatial Nash bargaining game of “Bargaining with Neighbors: Is Justice Contagious?” (Alexander and Skyrms, 1999), explored at greater length in both “Evolutionary Explanations of Distributive Justice” (Alexander, 2000) and The Structural Evolution of Morality (Alexander, 2007).

Consider an population of boundedly rational agents positioned on a two-dimensional lattice. (I.e., as if these agents were living in Manhattan.) Each agent is endowed with a strategy that they use to play the Nash bargaining game with their eight nearest neighbors. At the end of each round of play, agents compare their total payoff earned in the last round of interaction with the payoffs received by each of their nearest neighbors. If it should turn out that the maximal payoff earned by one of the agent's neighbours exceeds the payoff earned by the agent, then that agent will adopt a new strategy using the heuristic of Imitate-The-Best. (If there was a tie for the maximal payoff, then the agent chooses a new strategy a random from the set of maximally scoring strategies.)

The Nash Bargaining game.

In the form considered here, we assume that two players need to decide how to divide a resource (say, a cake) sliced into 10 pieces. Each agent’s strategy is simply the number of pieces of cake she wants. The two agents submit their strategies to a neutral third party who allocates cake according to the following rules:

  • If the sum of the two players’ strategies does not exceed the total amount of cake available, each agent receives the amount she wants.
  • If the sum of the two players’ strategies does exceed the total amount of cake available, neither agent receives anything (and the cake vanishes).
How to use it

Click on "Setup" to initialize the model. Once the model is initialised, clicking on "Step" will move the model forward in time one generation, and clicking on "Go" will tell the model to run indefinitely. The "Go" button will remain depressed until you click it again, at which point the simulation will stop.

You can set the initial configuration to some special states by clicking on the following buttons:

All greedy All agents are initially assigned the strategy 10 (asking for the entire cake).
All modest All agents are initially assigned the strategy 0 (asking for nothing).
Create polymorphism To the left of this button are two drop-down menus labelled “strategy1” and “strategy2”. This indicates the two strategies which will be randomly mixed in the initial population (with roughly equal frequencies). There is no difference to the order, so assigning 4 to strategy1 and 6 to strategy2 is the same as assigning 6 to strategy1 and 2 to strategy2.
Create frontier competition Initialises the world into two populations, divided right down the middle. If the switch frontier-polymorphism? is set to Off, then only left-strategy-a and right-strategy-a are used, in the obvious way. However, if frontier-polymorphism? is set to On, then the left half of the world is initialised to a random mix of left-strategy-a and left-strategy-b. (The same is done to the right.)

If you want, say, to have a frontier competition between a 3-7 polymorphism and a pure population of agents who ask for 5, then simply set both of the corresponding -a and -b strategies to 5.

Finally, you can manually insert mutants at selected positions. Set the value of type-to-insert to the strategy you want to insert, and then click on the button labeled “Insert mutants”. (Both “Go” and “Insert mutants” can be depressed at the same time.) As the simulation is running, move the mouse over the desired location and click and hold for about a second. (You need to wait because mutants can only be inserted by hand at a “safe” moment between generations — so if you click too quickly, the mutant might not appear because the click didn’t occur during that window.)

System Requirements.

The applet requires Java 5 or higher. Java must be enabled in your browser settings. Mac users must have Mac OS X 10.4 or higher. Windows and Linux users may obtain the latest Java from Sun's Java site.


View/download model file: Spatial nash.nlogo


Procedures

patches-own [
  strategy
  next-strategy
  score
]

to setup
  clear-all
  ask patches [
    set strategy (random 11)
    set pcolor (to-color strategy)
  ]
  update-plot
end

to go
  interact
  determine-next-strategy
  update
  if (allow-mutations?) [
    check-for-mutations
  ]
  update-plot
  tick
end

to interact
  ask patches [
    let new-score 0
    let my-strategy strategy
    
    ask neighbors [
      if ( [strategy] of self ) + my-strategy <= 10 [
        set new-score (new-score + my-strategy)
      ]
    ]
    
    set score new-score
  ]
end

;; This iterates through the list of neighbors and uses imitate-the-best to update
to determine-next-strategy
  ask patches [
    let my-score score
    let list-of-best-strategies []
    let best-score score
    
    ask neighbors [
      let neighbors-score ([score] of self)
      let neighbors-strategy ([strategy] of self)
      
      if-else (neighbors-score > best-score) [
        set list-of-best-strategies (list neighbors-strategy)
        set best-score neighbors-score
      ] 
      [
        if (neighbors-score = best-score) [
           set list-of-best-strategies (lput neighbors-strategy list-of-best-strategies)
        ] 
      ]
    ]
    
    if-else (best-score > my-score) [
      set next-strategy one-of list-of-best-strategies
    ]
    [
      set next-strategy strategy 
    ]
    
  ]
end

to update
  ask patches [
    set strategy next-strategy
    set pcolor (to-color strategy) 
  ]
end

to check-for-mutations
  ask patches [
    if (random-float 1.0) < mutation-rate [
      set strategy (random 11)
      set pcolor (to-color strategy)
    ]
  ]
end

to all-greedy
  ask patches [
    set strategy 10
    set pcolor (to-color strategy)    
  ]
  clear-all-plots
end

to all-modest
  ask patches [
    set strategy 0
    set pcolor (to-color strategy)    
  ]
  clear-all-plots
end

to create-polymorphism
  ask patches [
    if-else (random-float 1.0 < 0.5)
      [ set strategy strategy1 ]
      [ set strategy strategy2 ]
    set pcolor (to-color strategy)    
  ]
  clear-all-plots
end

to create-frontier-competition
  ask patches with [pxcor <= 0] 
  [
    ifelse frontier-polymorphism? [
      ifelse (random-float 1.0 < 0.5) 
        [ set strategy left-strategy-a ]
        [ set strategy left-strategy-b ]
    ]
    [
      set strategy left-strategy-a 
    ]
    
    set pcolor (to-color strategy)
  ]
  
  ask patches with [pxcor > 0] 
  [
    ifelse frontier-polymorphism? [
      ifelse (random-float 1.0 < 0.5) 
        [ set strategy right-strategy-a ]
        [ set strategy right-strategy-b ] 
    ]
    [
      set strategy right-strategy-a
    ]
    
    set pcolor (to-color strategy)
  ]
  
  clear-all-plots
end

to update-plot
  foreach [0 1 2 3 4 5 6 7 8 9 10] [plot-strategy ?]
end

to plot-strategy [s]
  set-current-plot-pen (word s)
  plot count patches with [strategy = s]
end

to-report to-color [s]
  report (item s [red orange brown yellow pink lime sky blue violet magenta gray])
end


to add-mutants-manually
  if mouse-down? [
    ask patch mouse-xcor mouse-ycor [
      set strategy type-to-insert
      set pcolor (to-color type-to-insert)
    ]
    display
  ]    
end