multi-agent signaling game

No preview image

1 collaborator

Fc-cr-low Fabrizio Cariani (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.0.3 • Viewed 310 times • Downloaded 15 times • Run 0 times
Download the 'multi-agent signaling 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.)


WHAT IS IT?

This is a multi-agent generalization of the signaling game model. Signaling games are meant to show that conventional associations between signals and states of the world may emerge as a result of repeated interaction without explicit agreement, and only on the basis of simple updates resulting from prior interactions.

The present generalization extends the model from the case of two-player signaling games to a whole community of agents.

HOW IT WORKS

The agents in the model are people moving around a torus. The torus is generated by an array of 21x21 equal-sized patches.

In thye default setting, agents move around the world at random.

When two or more agents share a patch, a signaling game can happen on that patch. In particular, in such circumstances one of the agents on the patch is designated as "sender" and the other agent is designated as receiver.

In a signaling game, each agent observes a state. In the standard version of signaling games, states are features of the world (i.e. global variable). In the present version, states are "internal" properties of agents. (We may imagine for instance an agent trying to communicate "I need food" or "I need water".) Neither the difference in interpretation (external vs. internal) nor the difference in structural representation (global vs. owned variable) should make a difference to the relevant emergent patterns.

HOW TO USE IT

The model shares two parameters with the standard signaling game model:

  • NUM-STATES (how many possible states could agents be in)
  • NUM-SIGNALS (how many possible signals are available)

in addition, there are a few new parameters that are special to the present setting;

  • NUM-AGENTS: total number of agents.
  • SUCCESS-THRESHOLD: on any given run of the model, we can indicate a success-threshold. The model will output to a monitor the number of games it took to hit this threshold (note that the threshold is not a stop condition).on the same patch as a signaling game update on the results of the interaction vs. (ii) any agents nearby update on the results of the interaction.
  • FAILURE-UPDATE?: this toggles an option between (i) standard signaling game in which the probabilities of signal association are only updated after a successful interaction vs. (ii) every interaction results in an update).
  • BIASED-MOVEMENT?: biased movement forces the agents to move in a non-random way.

THINGS TO NOTICE

Run the model in its default setting and check that signaling conventions tend to emerge in this setting just as they do in the standard signaling model.

But note that the more agents you add, the slower it takes for a robust conventional association to develop.

Note also that this can be sped up by allowing agents to eavesdrop on other agents' conversation.

Also check out the Levelspace addition in which we flip perspective and visualize the dialects the agents speak as objects in their own right. Notice how, as ticks pass, the number of spoken dialects diminishes (see the code of this model for how dialects are identified).

THINGS TO TRY

Try increasing the MOVEMENT-AIM-RADIUS: under the BIASED-MOVEMENT? option this allows agents to set a target turtle and move towards it.

EXTENDING THE MODEL

There is a large variety of alternate movement options we might consider. We would like BIASED-MOVEMENT? to become a chooser.

Similarly, while the model currently forces one update dynamics, there are many others we might experiment with based on the literature.

NETLOGO FEATURES

Etensive use of the table extension to netlogo and initial use of the levelspace extension.

RELATED MODELS

The model extends and generalizes

CREDITS AND REFERENCES

For the levelspace extension, see:

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

; 1. variable declarations

extensions [table
  ;ls
]

;  the original game has an elegant, if slightly non-modular way of keeping

globals [
  times-right ; how many signaling games were successful
  games-played ; how many signaling games were played
  success?  ; whether we have reached the goal
  all-signals
  all-states
  nearby   ; proximity for eavesdropping
  around-me  ; proximity for movement
  ma-sig-net ; for storing the levelspace model
]


turtles-own [
  my-sender-table ; probabilistic association between states and signals
  my-receiver-table ; probabilistic association between signals and states
  sender ; "on" / "off" variable to designate a sender
  receiver; "on" / "off" variable to designate a receiver
  my-state ; states are internal turtle features (e.g. "I need food")
]

to setup
  ca
  initialize-globals
  populate  ; create the turtles on the board
            ; outputs the initial average tables to the output box
  if print-probabilities? [print-probabilities]
  ; setup-levelspace
  reset-ticks
end 

; 2. setup procedures

to initialize-globals
  set times-right 0
  set games-played 0
  set success? "No"
  set all-signals (range num-signals)
  set all-states (range num-states)
  ; nearby and around-me are similar but
  set nearby moore-offsets eavesdropping-radius  ;one is for eavesdropping
  set around-me moore-offsets movement-aim-radius ;and one is for movement
                                                  ; ma-sig-net is initialized in the levelspace initialization
end 

to populate
  create-turtles num-agents [
    setxy random-xcor random-ycor
    set shape "person"
    set sender 0
    set receiver 0
    initialize-tables  ;initialize each turtle's sender and receiver tables
  ]
  reset-ticks
end 

to initialize-tables
  ; the sender table assigns to each state the range of signals
  set my-sender-table table:make
  foreach all-states [x -> table:put my-sender-table x all-signals]
  ; the receiver table assigns to each signal the range of states
  set my-receiver-table table:make
  foreach all-signals [x -> table:put my-receiver-table x all-states]
end 


; end of setup procedures  (except for "print-probabilities" and "setup-levelspace", below)

; 3. go procedure

to go
  ; stop condition for the model
  if success? != "No" [stop]
  ; non-signaling part of the model
  ask turtles[
    move
    ; at each tick, the state of a turtle changes, randomly for now
    set my-state random num-states
  ]
  ; signaling part of the model
  ;this is the procedure for playing signaling games
  setup-and-play-game
  ; output to the outputbox
  clear-output
  ; print to the output box if the switch is set to on
  if print-probabilities? [print-probabilities]
  check-success ; check whether we were successful
 ; go-levelspace; runs any updates in the levelspace model
  tick
end 

; 4. movement procedures

to wiggle
  ;; turn right then left, so the average is straight ahead
  rt random 90
  lt random 90
end 

;;

to move
  ifelse biased-movement?[
    let targets other turtles at-points around-me
    if any? targets [ face min-one-of targets [distance myself]  ]
    forward 1
  ]
  [wiggle
    forward 1]
end 


; 5. signaling game procedures

;  first we characterize when games happen and who is involved

to setup-and-play-game
  ; games can only be played on patches with at least two turtles
  ask patches with [count turtles-on self > 1] [
    ask one-of turtles-here[
      set sender 1 ; we designate a turtle as a sender
      play-game ]
  ]
end 

; next, we specify how we play the game

to play-game
  set games-played (games-played + 1) ;
  let partner-guess "dummy" ; initializing the partner guess
  let partner one-of other turtles-here   ; choose a partner
                                          ; choose a signal
  let my-signal (one-of (table:get my-sender-table my-state))
  ; have the partner guess
  ask partner [  ; we ask the partner to set their guess
    set receiver 1
    set partner-guess one-of (table:get my-receiver-table my-signal)
  ]
  ; now compare the guess and the initial state
  ; if we got it right...
  ifelse my-state = partner-guess
  [
    ; we add one more successful game to our count
    set times-right (times-right + 1)
    ; next, we each update **all** our tables
    ; first the sender's tables
    update-both-tables my-sender-table my-receiver-table my-state my-signal
    ; next the tables of any other turtles within earshot
    let target-turtles (other turtles-here) ; initialized as the turtles here
    ; but if there are eavesdroppers, it is reset as the turtles in radius
    if eavesdroppers? [set target-turtles (other turtles at-points nearby)]
    ; target turtles are asked to update both their sender and receiver tables
    ask target-turtles [
      update-both-tables my-sender-table my-receiver-table
      ; the "myself" here ought to refer to the sender, I hope it does.
      ([my-state] of myself) my-signal
    ]
  ]
  ; if we got it wrong...
  [ if failure-update? ; if the option to update on failures is on
                       ; we create restricted signal/state lists by removing my-signal
                       ; and my-state
    [
      let restricted-signals remove-item my-signal all-signals
      let restricted-states remove-item my-state all-states
      ; for each of the other signals we add one thing to the urn
      foreach restricted-signals [
        sig ->
        update-both-tables my-sender-table my-receiver-table my-state sig
        ask partner [update-both-tables my-sender-table my-receiver-table
          ([my-state] of myself) my-signal]
      ]
    ]
  ]
  set sender 0
  ask partner [set receiver 0]
end 

; 6. some assorted helper procedures and reporters

; for updating tables

to update-both-tables [ s-table r-table state sig ]
  table:put s-table state (lput sig (table:get s-table state))
  table:put r-table sig (lput state (table:get r-table sig))
end 

; for characterizing moore neighborhoods (plus the center patch)

to-report moore-offsets [n]
  report [list pxcor pycor] of patches with
  [abs pxcor <= n and abs pycor <= n]
end 

; 7. Output reporters

; helper

to-report num-rep [sequence i]  ; this takes a sequence and a value
                                ; and ...
                                ; ... reports the number of occurrences of i in the sequence,
                                ; divided by the length of the sequence
  report (length filter [x ->  x = i] sequence) / (length sequence)
end 

; 7.1 Average Reporters

; 7.1.1 Average Receiver Table

; main definition
; this exploits the helper below to compute an average receiver table
; for each signal

to-report average-receiver-table [sig]
  let target-table table:make
  ; that is, we look at each state and store the average degree of
  ; association between the input signal and the state
  foreach all-states [state -> table:put target-table state
    (average-rec-association sig state)]
  report target-table
end 

; helper

to-report average-rec-association [sig state]
  ;  asks the receiver tables of the turtles for the frequencies
  ; of state/signal association, then reports averages across turtles
  report precision (mean map [s -> num-rep s state]
    ([table:get my-receiver-table sig] of turtles)) 3
end 

; 7.1.2 Average Sender Table

; main definition
; same structure as above but for sender tables instead of receiver tables
; this means also inverting the relative roles of states and signals

to-report average-sender-table [state]
  let target-table table:make
  foreach all-signals [sig -> table:put target-table sig
    (average-send-association sig state)]
  report target-table
end 

; helper for main

to-report average-send-association [sig state]
  ; it asks the sender tables of the turtles for the frequencies
  ; of state/signal association,
  ;then averages across turtles, approximating to 3 decimal digits
  report precision (mean map [s -> num-rep s sig]
    ([table:get my-sender-table state] of turtles)) 3
end 

; 7.2 Standard Deviation Reporting Proceure

; 7.2.1. Standard Deviation of Receiver

; exploits the helper below to compute a sd receiver table for each signal

to-report sd-receiver-table [sig]
  let target-table table:make
  ; that is, we look at each state and find the sd of the rec association
  ;  between input signal and state
  foreach all-states [state -> table:put target-table state
    (sd-rec-association sig state)]
  report target-table
end 

; helper  asks the receiver tables of the turtles for the frequencies
; of state/signal association,

to-report sd-rec-association [sig state]
  ; then computes the sd across turtles, approximating to 3 decimal digits
  report precision (standard-deviation map [s -> num-rep s state]
    ([table:get my-receiver-table sig] of turtles)) 3
end 


; 7.2.2. Standard deviation of Sender

; main definition. as above it mirrors 7.2.1 but for sender tables,
; with roles of state and signals reversed

to-report sd-sender-table [state]
  let target-table table:make
  foreach all-signals [sig -> table:put target-table sig
    (sd-send-association sig state)]
  report target-table
end 

; helper for main

to-report sd-send-association [sig state]
  report precision (standard-deviation map [s -> num-rep s sig]
    ([table:get my-sender-table state] of turtles)) 3
end 

; 8. Expected Success Reporter

; we define an expectation function as in three steps. First

; say I get a signal and I have a target-state in mind...

to-report expected-success-rec [target-state signal]
  ; ... report how likely we are to get the target-state right ...
  ; ... given the average-receiver table.
  report (table:get average-receiver-table signal target-state)
end 

; suppose we are in a state, how likely are we to succeed?
; this function computes this based on average-send-table.

to-report expected-success-send [state]
  report sum map [sig ->  ; we take the weighted average of ...
    (expected-success-rec state sig) *  ; ... the average probability
                                        ; ...of success in state sig.
    (table:get average-sender-table state sig) ; ... weighted by how likely
                                               ; we are to send sig in state
  ] all-signals
end 

to-report expected-success ; mean of the expected success for each state
  report mean map [sta -> (expected-success-send sta)] all-states
end 
; note we are assuming that the states are equiprobable

; 9. Scorekeeping procedures

; 9.1 Output procedures

to print-probabilities
  output-type "average receiver table (+ sd) \n \n"
  foreach n-values num-signals [i -> i] [sig ->
    let target-table (average-receiver-table sig)
    let sd-table (sd-receiver-table sig)
    output-type "signal: " output-print sig
    foreach table:keys target-table [state -> output-type state
      output-type "  " output-type table:get target-table state
      output-type " (" output-type table:get sd-table state output-type ")\n"
    ]
  ]
  output-type "\n*********\n"
  output-type "average sender table (+ sd) "
  output-type "\n\n"
  foreach n-values num-states [i -> i] [sta ->
    let target-table (average-sender-table sta)
    let sd-table (sd-sender-table sta)
    output-type "state: " output-print sta
    foreach table:keys target-table [sig -> output-type sig
      output-type "  " output-type table:get target-table sig
      output-type " (" output-type table:get sd-table sig output-type ")\n"    ]
  ]
end 

; 9.2 other reporters and procedures to check the status of the game

to check-success
  if expected-success > (success-threshold / 100) and success? = "No"
  [
    set success? games-played
  ]
end 

to-report times-wrong
  report games-played - times-right
end 

; 10. dialect identification procedures

; this reporter takes an agent's sender table and coarsens it by
; taking for each state...

to-report coarsen-table [input-table] ; ... the mode of the signals
  let target-table table:make
  foreach (table:keys input-table)
  [x -> table:put target-table x modes (table:get input-table x)]
  report target-table
end 

; a dialect is a coarsened table according to the prior procedure

; this reporter outputs a list of dialects and a matching list of how many agents speak them

to-report dialects
  let dialect-list []
  let weight-list []
  ask turtles [
    ifelse not member? (coarsen-table my-sender-table) dialect-list
    [
      set dialect-list lput (coarsen-table my-sender-table) dialect-list
      set weight-list lput 1 weight-list
    ]
    [
      let target-position position (coarsen-table my-sender-table) dialect-list
      let old-value item target-position weight-list
      set weight-list replace-item target-position weight-list (old-value + 1)
    ]
  ]
  let combined-list list dialect-list weight-list
  report combined-list
end 

to-report count-dialects
  report length (item 0 dialects)
end 

; return an agent dialect

to-report dialect-of [agent];arthur suggested mods but I haven't yet gotten this to work
  report coarsen-table my-sender-table
end 

; return true if the two turtles have the same dialect

to-report same-dialect [agent1 agent2]
  report (dialect-of agent1)=(dialect-of agent2)
end 



;; levelspace procedures
;
;to setup-levelspace
;  ls:reset
;  ls:create-interactive-models 1 "dialects-as-objects.nlogo"
;  set ma-sig-net last ls:models
;  ls:assign ls:models dialects-info (item 1 dialects)
;  ls:assign ls:models master-tick ticks
;  ls:ask ls:models [setup]
;end
;
;to go-levelspace
;  ls:assign ls:models dialects-info (item 1 dialects)
;  ls:assign ls:models master-tick ticks
;  ls:ask ls:models [go]
;end

There are 2 versions of this model.

Uploaded by When Description Download
Fabrizio Cariani almost 6 years ago removed levelspace Download this version
Fabrizio Cariani almost 6 years ago Initial upload Download this version

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.