oTree Forum >

Randomize payment fields

#1 by Paula_Tovar


I'm creating a game where participants get paid if their belief about the other player's answer is correct. Each participant answers some questions and then, they answer them again trying to guess the other participant's answers, beliefs. They make several beliefs but for the payment, we only choose one field randomly. The name of the field denoting the player's answer is "S1op1", but the name of the field denoting the player's belief about the opponent's answer to the same question is "CS1op1". My code is the following:

def set_payoffs(group: Group):

    players = group.get_players()
    b = randint(1, 20)

    for p in players:
        a = choice(['S1op1', 'S1op2', 'S1op3', 'S1op4'])
        other = other_player(p)
        match = other.a == p.C+a
        if match:
            p.payoff = cu(100)
            p.payoff = cu(0)
But I get this error: 'list' object has no attribute 'a'

Thanks in advance for any kind of help.

Write a reply

Set forum username