I am trying to simulate a group of players playing the ultimatum
bargaining game, with a selection process in which players pair up,
with the more successful player reproducing and the less successful
player being eliminated. I am having trouble pairing up players in
NetLogo: it is simple to have a player select a random opponent, but
I want this opponent, as well as the acting player, to be removed
from the competition pool until the next turn.
The following is the code that I am currently using:
ask turtles [
set competed? 0
set birth? 0
let opponent one-of other turtles
let opponent2 one-of other turtles with [competed? = 0]
ifelse random 2 = 0 ;; "coin-flip"
[if offer >= [bottom-line] of opponent [set money money + 100 -
offer]]
[if bottom-line <= [offer] of opponent [set money money + [offer]
of opponent]]
set money money - 25 - .25 * money
if opponent2 != nobody
[
if money = [money] of opponent2
[set competed? 1 set [competed?] of opponent2 1]
if money > [money] of opponent2
[set birth? 1 set competed? 1 set [kill?] of opponent2 1 set
[competed?] of opponent2 1]
if money < [money] of opponent2
[set kill? 1 set competed? 1 set [birth?] of opponent2 1 set
[competed?] of opponent2 1]
]
]
ask turtles with [kill? = 1] [die]
ask turtles with [birth? = 1] [hatch 1 [forward random 5 right
random 360 set money 0]]
With this code, players find a random opponent. If they have equal
money to the opponent, both survive. If one player has more money,
that player hatches and the other dies after all turtles have played.
I would expect this program to keep the population constant. However,
when I run it, the population decreases on the first turn, then is
maintained for the remainder of the game.
Any help on this would be greatly appreciated. I would be happy to
forward the entire file to someone if it would be helpful.
.