List Info

Thread: Trouble with pairing up players




Trouble with pairing up players
country flaguser name
United States
2008-06-04 16:13:53

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.


__._,_.___
.

__,_._,___
Re: Trouble with pairing up players
country flaguser name
United States
2008-06-05 17:34:34

>>&gt;>> "jelaly" == jelaly < younesje%40grinnell.edu">younesjegrinnell.edu> writes:

jelaly&gt; I am trying to simulate a group of players playing the
jelaly> ultimatum bargaining game, with a selection process in which
jelaly> players pair up, with the more successful player reproducing
jelaly> and the less successful player being eliminated. I am having
jelaly> trouble pairing up players in NetLogo: it is simple to have a
jelaly> player select a random opponent, but I want this opponent, as
jelaly> well as the acting player, to be removed from the competition
jelaly> pool until the next turn.

jelaly> The following is the code that I am currently using:

jelaly>; ask turtles [

jelaly> set competed? 0 set birth? 0

jelaly> let opponent one-of other turtles let opponent2 one-of other
jelaly> turtles with [competed? = 0]

I'm not sure if this is the cause of your bug (or the only cause), but I
think you probably meant to use multiple ASK commands, like this:

ask turtles [ set competed? 0 ]
ask turtles [ let opponent ... ]

so that all of the turtles set their competed? variable to 0 before any
turtle chooses an opponent.

Also, while it will work fine to use 0 to mean false and 1 to mean true,
it's more idiomatic NetLogo to use the boolean true and false values
directly:

ask turtles [ set competed? false ]

then instead of writing:

ask turtles with [birth? = 1]

you can just write:

ask turtles with [birth?]

--
Seth Tisue / http://tisue.net
lead developer, NetLogo: http://ccl.northwestern.edu/netlogo/

__._,_.___
.

__,_._,___
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )