# Public Goods Game with spatial diversity

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

## WHAT IS IT?

This model implements Public Goods Game with modifications enabling the randomized selection of the interaction neighbourhoods. Players, implemented using NetLogo patches, are located on 2D lattice. They can interact with agents in their neighbourhoods, which can be selected using from von Neumann neighbourhood, from Moore neighbourhood, or from any agents on the grid.

## HOW IT WORKS

Each agent is assigned initial strategy contributor or free rider/defector. Some players are assigned status of roaming agents, and the are allowed to change their interaction neighbourhood after each round.

The rules of the elementary game are based on the Public Goods Game. A player contributes 1 (contributor) or 0 (free rider/defector) to a common pool. Next, the total amount is multiplied by the *synergy-factor*, and the result is divided equally among the participating agents. The income of each player is increased by this divided amount and decreased by its contribution.

Each agent is engaged in a number of elementary games. Payoffs from each game are accumulated into an income after a round.

After all the elementary games are finalized, the agent starts the imitation phase. Each agent chooses a neighbour from its interaction neighbourhood. The income of the agent is compared with the income of the selected neighbour, and the difference is used to calculate the probability of the agent to imitate the strategy of the selected neighbour.

There are two aspects of diversity introduced in the model.

The first aspect is the interaction diversity, which means that each agent can have the different number of neighbours to interact with and to learn from. This is reflected by the initial assignment of the groups of agents to interact with.

The second aspect is used to introduce the possibility of reevaluation of the interaction neighbourhood. This is achieved by introducing the subpopulation of roaming agents, which can alter their interaction neighbourhood. For the sake of simplicity, we fix a probability of reevaluation to 1/2. Furthermore, agents are assigned a status of roaming during the initialization, and the status remains unchanged during the simulation.

## HOW TO USE IT

The parameters for controlling the model are:

- slider
*world-size*- used to set the size of the grid; - slider
*noise-factor*- controlling of the noise parameter used in the Fermi-Dirac imitation function; - slider
*synergy-factor*- controlling the synergy factor used in the payoff calculation in each elementary PGG; - chooser
*neighborhood-type*- used to select the type of the neighbourhood assigned to each agent; - slider
*random-patches-number*- controlling the size of the interaction neighbourhood selected for*neighborhood-type*set to*K patches*or*random K patches*; - chooser
*imitation-policy*- used to control the function used in the imitation phase; can be set to:*Fermi-Dirac*,*differences*or*linear*; - slider
*roaming-agents*- used to control the fraction of agents who are roaming, i.e. they can change their interaction neighbourhoods;

## THINGS TO NOTICE

There are two things distinguishing the presented model from the standard Public Good Game on 2D lattice.

First, diversification of the interaction neighbourhoods leads to a decrease of the synergy factor required to achieve cooperation. This can be observed by chooising *neighborhood-type* as "random von Neumann" or "random Moore".

Second, by introducing a subpopulation of roaming agents, one can also decrease the synergy factor requited to achieve cooperation. To observe this one needs to choose *neighborhood-type* as "random von Neumann", "random Moore", "K patches" or "random K patches. Netx, the participarion of the roaming agents can be controlled using *roaming-agents* slider.

## THINGS TO TRY

The interesting behaviour of the model can observed by altering the neighbourhood type. There is a visible difference between the von Neumann and Moore neighbourhood.

The formation of the collaboration can be facilitated by the increase in the number of roaming agents. However, for a very large fraction of roaming agents, the effect is negative, and the collaboration cannot be achieved.

## EXTENDING THE MODEL

The simplest extension of the model can be done by including new methods for selecting neighbours. This can be done by extending *choose-neighborhood* function and including a new variant in the *neighborhood-type* chooser.

## NETLOGO FEATURES

Agents in the model are implemented using NetLogo patches. Even if some of them are described as *roaming*, not changes in location is necessary, as roaming agents move between the interaction neighbourhoods.

The implementation based on patches limits the control over the connectivity of the interaction links. At the moment, only local links or links from the full graph are used.

## RELATED MODELS

Implementation of Public Goods Game on a square lattice. http://www.modelingcommons.org/browse/one_model/7074

## CREDITS AND REFERENCES

[1] Lihui Shang, Sihao Sun, Jun Ai, and Zhan Su. Cooperation enhanced by the interaction diversity for the spatial public goods game on regular lattices. Physica A: Statistical Mechanics and its Applications, 593:126999 DOI:10.1016/j.physa.2022.126999

[2] M. Jusup et al, Social physics, Physics Reports, vol. 948, pp. 1-148 (2022)

## Comments and Questions

;;------------------------------------------------------------------------------------ ;; patches atributes ;;------------------------------------------------------------------------------------ patches-own [ contribution ;; player's contribution: 1 - contributor, green, 0 - free-rider, black income ;; income from the last round neighborhood ;; group of players used for playing the game roaming? ;; should the agent reevaluate the neighborhood ] ;;------------------------------------------------------------------------------------ ;; global variables ;;------------------------------------------------------------------------------------ globals [ cooperators1k inv-noise-factor cooperator freerider ] ;;------------------------------------------------------------------------------------ ;; setup the world ;;------------------------------------------------------------------------------------ to setup ;; initial cleanup clear-all ;; strategy set cooperator 1 set freerider 0 ;; other constants set inv-noise-factor ( 1 / noise-factor ) ;; data collected during the game set cooperators1k [] ;; main setup setup-world setup-patches reset-ticks end ;;------------------------------------------------------------------------------------ ;; main subroutine ;;------------------------------------------------------------------------------------ to go ;; check if the neighborhoods should be chooes each round ask patches [ if roaming? [ choose-neighborhood ] ] ;; play the public goods game for all patches ask patches [ play-pgg ] ;; imitate the strategy using the seleced policy, using the cumulative income from the round ask patches [ ;; strategy imitation method (ifelse imitation-policy = "fermi-dirac" [ imitate-strategy-fermi-dirac ] imitation-policy = "linear" [ imitate-strategy-linear ] imitation-policy = "differences" [ imitate-strategy-differences ]) ;; update colors of the visual representation - NOTE: this could be commented out update-colors ;; reset the income for the next round set income 0 ] ;; update the list with cooperators-fraction update-cooperators1k ;; finish the round tick end ;;------------------------------------------------------------------------------------ ;; world initialization ;;------------------------------------------------------------------------------------ to setup-world ;; make the world with custom size resize-world 0 (world-size - 1) 0 (world-size - 1) ;; heuristic scaling of the patch size set-patch-size floor ( 50 / (sqrt world-size) ) ask patches [ ;; make all patches white set pcolor white ] end ;;------------------------------------------------------------------------------------ ;; setup routine ;; contains ;; - initial interaction neighborhood ;; - selection of the initial strategies ;; - assignemet of the roaming status ;;------------------------------------------------------------------------------------ to setup-patches ask patches [ ;; initail assignement of the neighborhood choose-neighborhood ;; initialize the income set income 0 ;; randomly assign initial strategies ifelse random-float 1.0 < 0.5 [ set contribution 1 ;; cooperator ] [ set contribution 0 ;; no contribution, free-rider ] ;; assign roaming status to a subpopulation ifelse random-float 1.0 < roaming-agents [ set roaming? true ;; agent changing the neighbours set plabel "*" ] [ set roaming? false ;; no reevaluation ] update-colors ] end ;;------------------------------------------------------------------------------------ ;; select patches to interact with ;;----------------------------------------------------------------------------------- to choose-neighborhood ;; choose which neighborhood to use (ifelse neighborhood-type = "von Neumann" [ set neighborhood neighbors4 ] neighborhood-type = "Moore" [ set neighborhood neighbors ] neighborhood-type = "random von Neumann" [ set neighborhood n-of (1 + random 4 ) neighbors4 ] neighborhood-type = "random Moore" [ set neighborhood n-of (1 + random 8 ) neighbors ] neighborhood-type = "random von Neumann or Moore" [ ifelse random 1 = 0 [ set neighborhood n-of (1 + random 8 ) neighbors ][ set neighborhood n-of (1 + random 4 ) neighbors4 ] ] neighborhood-type = "von Neumann or Moore" [ ifelse random 1 = 0 [ set neighborhood neighbors ][ set neighborhood neighbors4 ] ] neighborhood-type = "random K patches" [ set neighborhood n-of (1 + random random-patches-number ) patches ] neighborhood-type = "K patches" [ set neighborhood n-of ( random-patches-number ) patches ]) end ;;------------------------------------------------------------------------------------ ;; helper function to update visual aspects of turtles ;;------------------------------------------------------------------------------------ to update-colors ifelse contribution = 1 [ set pcolor green ][ set pcolor black ] end ;;------------------------------------------------------------------------------------ ;; evolution routine ;;------------------------------------------------------------------------------------ to play-pgg ;; calculate the payoff let game-gain ( synergy-factor * (contribution + sum [ contribution ] of neighborhood) / (1 + count neighborhood) ) ;; assign my income set income income + game-gain - contribution ;; assign incomes of the agents in the interaction neighbourhood ask neighborhood [ set income income + game-gain - contribution ] end ;;------------------------------------------------------------------------------------ ;; strategy update policies ;;------------------------------------------------------------------------------------ ;;------------------------------------------------------------------------------------ ;; version with F-D function ;;------------------------------------------------------------------------------------ to imitate-strategy-fermi-dirac ;; select one of the neighbors let my-neighbor one-of neighborhood let my-neighbor-income [ income ] of my-neighbor ;; select new strategy using Fermi-Dirac function if ( random-float 1.0 ) * (1 + exp ( ( income - my-neighbor-income ) * inv-noise-factor ) ) < 1 [ set contribution [ contribution ] of my-neighbor ] end ;;------------------------------------------------------------------------------------ ;; version with linear imitation ;;------------------------------------------------------------------------------------ to imitate-strategy-linear ;; select one of the neighbors let my-neighbor one-of neighborhood let my-neighbor-income [ income ] of my-neighbor ;; select new strategy using linear imitation if income < my-neighbor-income [ if random-float 1.0 < ( my-neighbor-income - income ) / (1 + synergy-factor ) [ set contribution [ contribution ] of my-neighbor ] ] end ;;------------------------------------------------------------------------------------ ;; version with imitation based on payoff differences ;;------------------------------------------------------------------------------------ to imitate-strategy-differences ;; select one of the neighbors let my-neighbor one-of neighborhood let my-neighbor-income [ income ] of my-neighbor ;; select new strategy using the difference of payyofs rule (ifelse income < my-neighbor-income [ ;; always imitate from the neighbour with higer income set contribution [ contribution ] of my-neighbor ] income > my-neighbor-income [ ;; do nothing ] income = my-neighbor-income[ ;; imitate from the neighbour with higer income with p=1/2 if random-float 1.0 < 0.5 [ set contribution [ contribution ] of my-neighbor ] ]) end ;;------------------------------------------------------------------------------------ ;; reporters ;;------------------------------------------------------------------------------------ ;; fraction of cooperators to-report cooperators-fraction report count patches with [ contribution = 1 ] / count patches end ;; fraction of cooperators whcih reevaluate their neigbourhoods to-report roaming-cooperators-fraction report count patches with [ roaming? = true and contribution = 1 ] / count patches with [ roaming? = true ] end ;; fraction of cooperators in last 1000 steps to update-cooperators1k ;; add current vale of cooperators-fraction to the list cooperators1k set cooperators1k fput cooperators-fraction cooperators1k end ;; average fraction of cooperators in last 1000 steps to-report mean-cooperators1k ifelse ticks >= 1024 [ report mean ( sublist cooperators1k 0 1024 ) ][ report 0 ] end

There is only one version of this model, created 4 months ago by Jaroslaw Miszczak.

## Attached files

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

Public Goods Game with spatial diversity.png | preview | Preview for 'Public Goods Game with spatial diversity' | 4 months ago, by Jaroslaw Miszczak | Download |

This model does not have any ancestors.

This model does not have any descendants.