Hi!
I am having a hard time trying to define the payoff of players based on some user entry and I appreciate if I can get some help on this:
1. For all the players in the group (p1, p2.....p20) I generate a random id_in_group for them so they can be a sequence of integers from 1-20 randomly. So for (p1, p2.....p20) they can have an id_in_group as one of them
1) [10, 7, 1, 13, 16, 8, 3, 5, 11, 2, 6, 15, 12, 4, 14, 9]
2) [2, 12, 8, 16, 14, 4, 11, 3, 10, 1, 6, 7, 5, 9, 13, 15]
#Code:
subsession.group_randomly()
print(subsession.group_randomly)
2. I define an integer field for each player to make a decision of under the four scenerios
1) Allocate some money between two participants who both has a participant id>10 : morethanten11,morethanten12
2) Allocate some money between two participants who both has a participant id<10:lessthanten21,lessthanten22
3) Allocate some money between two participants one >=10 and one <10:morethanten31,lessthanten32
3. The first number in the sequence will be the ID number of the person who allocates to the second and third IDs. The second ID drawn will allocate to the third and fourth IDs, , and so on. The second to last ID will allocate to the last and first IDs.
For example, if the sequence is[10, 7, 1, 13, 16, 8, 3, 5, 11, 2, 6, 15, 12, 4, 14, 9]. Then
Payoff of P2(Id in group=7) will be P1's entry of lessthanten21
Payoff of P3(Id in group=1) will be P1's entry lessthanten22
Payoff of P16(Id in group=9) will be P15's entry of lessthanten32
Payoff of P1(Id in group=10) will be P15's entry of morethanten31
4. I m having a hard time of trying to put all my stuff to codes and I have difficulty in how to refer to the entry of the specific player and refer the int of the the id of the two followings players.I have written the following code but I think they can't work and I don't know how to adjust them.
#Code:
@staticmethod
def after_all_players_arrive(player: Player):
players = group.get_players()
if i=range(len(players)-2)
if int(players[i+1].id)>10 and int(players[i+2].id)>10
player[i+1].payoff=player[i].morethanten11
p1.payoff=player[i].morethanten12
if int(players[i+1].id)<5 and int(players[i+2].id)>5
player[i+1].payoff=player[i].lessthanten21
p1.payoff=player[i].morethanten22
if int(players[i+1].id)>=10 and int(players[i+2].id)<10
player[i+1].payoff=player[i].morethanten31
p1.payoff=player[i].lessthanten32
if int(players[i+1].id)<10 and int(players[i+2].id)>=10
player[i+1].payoff=player[i].lessthanten31
p1.payoff=player[i].morethanten32
elif i in range(len(players)-2):
if i>=1 and i<range(len(players)-2)and int(players[i+1].id)>10 and int(players[i+2].id)>10
player[i+1].payoff=player[i].morethanten11
player[i+2].payoff=player[i].morethanten12
if i>=1 and i<range(len(players)-2) and i<range(len(players)-2) and int(players[i+1].id)<5 and int(players[i+2].id)>5
player[i+1].payoff=player[i].lessthanten21
player[i+2].payoff=player[i].morethanten22
else i>=1 and int(players[i+1].id)>=10 and int(players[i+2].id)<10
player[i+1].payoff=player[i].morethanten31
player[i+2].payoff=player[i].lessthanten32
Thanks for the feedback!