oTree Forum >

Payoff generation for group members

#1 by Anwesha

Hi there,

Hope you are well. I have a problem in generating payments for group members. So this is what we intend to do. Each group has two players and each one of then can select two assets:  A and B. If both players select asset A or asset B and a random number gets generated, they get paid accordingly. However, if one player selects A and the other B and the same random number gets generated, the player who selected asset A gets paid for that asset and the player who selected asset B, gets paid for asset B. This is where things are not working. My code is mentioned below. What the code is doing is that if one player selects A and the other player selects B, one of them gets a payoff of 30, which is something we don't want. The ultimate decision variable is decision2. Could you please help me?

class Results(Page):
    def vars_for_template(player: Player):
        pchoice = np.random.random()
        if pchoice <= 0.5:
            Group.get_payoff = 1
            Group.get_payoff = 0
        if player.decision2 == True:
            player.payoff = C.payment_assetA * Group.get_payoff
        if player.decision2 == False:
            player.payoff = C.payment_assetB * Group.get_payoff
        if Group.get_payoff == 0:
            player.payoff = C.payment_otherwise
        player.earning = Decimal(player.payoff) / Decimal(10)
        return dict(
            earning1=format(Decimal(player.earning), '.2f')

Write a reply

Set forum username