Substitution Best-Shot Public Goods Game

Substitution Best-Shot Public Goods Game preview image

2 collaborators

Default-person Amanda Page (Author)
Default-person Darin England (Advisor)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.1.1 • Viewed 27 times • Downloaded 0 times • Run 0 times
Download the 'Substitution Best-Shot Public Goods 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.)


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

; a model for the 'best-shot' public goods game

globals [
  selected
  turtle1
  turtle2]

turtles-own [
  action        ; action (either 0 or 1)
  orig-action   ; each person's initially assigned action
  action-1-sum
]

to setup
  clear-all
  set-default-shape turtles "circle"
  ask patches [ set pcolor cyan + 1 ]
  set selected nobody
  make-turtles
  distribute-actions
  create-network
  select-nodes
  delete-nodes
  add-nodes
  reset-ticks
end 

; create the turtles in 1-dimensional lattice

to make-turtles
  create-turtles num-nodes [
    set color black
    set action 0 ]
  repeat 50 [layout]
  ask turtles [ setxy 0.95 * xcor 0.95 * ycor ]
end 

to layout
  layout-spring turtles links 0.5 2 1
end 


; initialize some individuals to start with action 1

to distribute-actions
  ask turtles [ set action 0 ]
  ask turtles [
    set orig-action action
    update-color
  ]
end 

to update-color
  set color ifelse-value action = 0 [black] [white]
end 


;; create the links in the network

to create-network
  ask turtles [
    let nbrs other turtles in-radius 10
    ; other omits the turtle itself
    create-links-with nbrs [ set color white ]
    ; only one undirected link between any two turtles is created
  ]
end 

to reset-nodes
  clear-all-plots
  ask turtles [
    set action orig-action
    update-color
  ]
  reset-ticks
end 

to redistribute-actions
  clear-all-plots
  distribute-actions
  reset-ticks
end 

to go
  ask turtles [check-neighbors]
  ask turtles [ take-action ]
  ask turtles [ update-color ]
  tick
  ;debg-actions
end 

to debg-actions
   ; debugging, show actions of all nodes
  foreach sort-by[ [a b] -> [xcor] of a < [xcor] of b ] turtles [ i ->
    ask i [ show action ]
  ]
end 

to check-neighbors
  set action-1-sum sum [action] of link-neighbors
end 

to take-action
  let num-neighbors count link-neighbors
  set action ifelse-value (action-1-sum >= 1) [0] [1]
end 

to select-nodes ; use the mouse to select which nodes take action 1
  set selected min-one-of turtles [distancexy mouse-xcor mouse-ycor]
  if mouse-down? [
    ask turtles with [distancexy mouse-xcor mouse-ycor < 2] [
      set action 1
      update-color
      display ; update the display
    ]
  ]
  set selected nobody
end 

to add-nodes
  if mouse-down? [
      create-turtles 1 [
        set color black
        set action 0
        setxy mouse-xcor mouse-ycor
        let nbrs other turtles in-radius 10
        create-links-with nbrs [set color white]
    ]
    stop
    ]
  display ; update the display
end 

to delete-nodes
  if mouse-down? [
    ask turtles with [distancexy mouse-xcor mouse-ycor < 2] [
      die
      display ; update the display
    ]
    stop
  ]
end 

There are 3 versions of this model.

Uploaded by When Description Download
Amanda Page about 1 month ago Update info tab Download this version
Amanda Page about 1 month ago Update info tab Download this version
Amanda Page about 1 month ago Initial upload Download this version

Attached files

File Type Description Last updated
Substitution Best-Shot Public Goods Game.png preview Preview for 'Substitution Best-Shot Public Goods Game' about 1 month ago, by Amanda Page Download

This model does not have any ancestors.

This model does not have any descendants.