Competition and learning in a recreational game community - proof of concept

Competition and learning in a recreational game community - proof of concept preview image

1 collaborator

Joe_wasserman_face_cropped_square Joe Wasserman (Author)

Tags

competition 

Tagged by Joe Wasserman about 5 years ago

Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.0.1 • Viewed 226 times • Downloaded 10 times • Run 0 times
Download the 'Competition and learning in a recreational game community - proof of concept' 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

extensions [nw rnd]

turtles-own [strategy plays plays-to-99 wins played?]
links-own [matches-real matches-for-choosing]

to setup
  clear-all

  ;; seed agents
  crt num-nodes
  layout-circle turtles (world-width / 2 - 1)
  ask turtles
  [
    set shape "person"
    set strategy random-float start-strat-max
    set color scale-color green strategy 1 0
    set plays 0
    set plays-to-99 0
    set wins 0
    set played? false
    create-links-with other turtles ;; make all possible links
  ]

  ;; setup networks
  ask links
  [
    set matches-for-choosing start-wt ;; adds one dummy match to links for selecting opponents
    set matches-real 0 ;; the real tracker of number of matches
  ]

  ask patches
  [
    set pcolor gray
  ]

  reset-ticks
end 

to go

  ;; runs ONE turtle at a time
  ask one-of turtles with [ not played? ] ;; chooses a player1 randomly who hasn't played this round
  [ let player1 self  ;; sets player1 as self
    let player2 nobody
    let match-link rnd:weighted-one-of (my-links with [[not played?] of other-end]) [matches-for-choosing] ;; lottery to choose an opponent weighted by previous plays
    ask self [ ask match-link [set player2 other-end]]
    update-match-link match-link ;; updates match-link's variables
    compete player1 player2 ;; compete!
]

  ;; when no potential matches remain, tick and reset played? flags
  if count turtles with [not played?] < 2
  [
    ask turtles [set played? false]
    visualize
    tick
  ]

  ;; aborts when minimum strategy asymptotyically approaches 1
  if min([strategy] of turtles) >= .999 [ visualize stop ]
end 

;; increments matches between the paired players

to update-match-link [match-link]
  ask match-link
  [
    set matches-for-choosing matches-for-choosing + match-wt
    set matches-real matches-real + 1
  ]
end 

;; match opponents, compete, and learn

to compete [player1 player2]
  ;; identifies players visually
  ask player1
  [
    set color red
    set played? true
    set plays plays + 1
  ]

  ask player2
  [
    set color blue
    set played? true
    set plays plays + 1
  ]

  ;; compete between opponents and update skill etc.
  let strategy1 [strategy] of player1
  let strategy2 [strategy] of player2
  ;; base learning regardless of game outcome
  ask player1
    [ set strategy strategy + ((1 - strategy) * base-learn) ]
  ask player2
    [ set strategy strategy + ((1 - strategy) * base-learn) ]

  ;; player1 > player2, increase player2 strategy proportional to difference in strategy
  if strategy1 > strategy2
  [
    ask player1
    [ set wins wins + 1 ]
    ask player2
    [ set strategy strategy + ((strategy1 - strategy2) * partner-learn) ]
  ]

  ;; player 2 > player1, increase player1 strategy proportional to difference in strategy
  if strategy1 < strategy2
  [
    ask player2
    [ set wins wins + 1 ]
    ask player1
    [ set strategy strategy + ((strategy2 - strategy1) * partner-learn) ]
  ]

  ;; counts how many ticks it takes for every player to reach strategy >= .99
  ask (turtle-set player1 player2)
  [
    if strategy < .99
    [ set plays-to-99 plays-to-99 + 1 ]
  ]
end 

to visualize
  ;; visualizes density of matches between opponents: darker = more
  ask links
  [
    set color scale-color green matches-real max [matches-real] of links min [matches-real] of links
    ifelse matches-real = 0 [hide-link] [show-link]
  ]

  ;; visualizes current strategy of all turtles: darker = more
  ask turtles
    [ set color scale-color green strategy 1 0 ]
end 

There is only one version of this model, created about 5 years ago by Joe Wasserman.

Attached files

File Type Description Last updated
Competition and learning in a recreational game community - proof of concept.png preview Preview for 'Competition and learning in a recreational game community - proof of concept' about 5 years ago, by Joe Wasserman Download

This model does not have any ancestors.

This model does not have any descendants.