oTree Forum >

Getting the other player's decision in ResultPage and history table

#1 by EconMatics

I have a simple two players' game. 
Each of the two players will input a number named as "decision".
In the result page, I want to show the decision of both players. How to show opponent's decision and payoff.

I know first part of the result is:

In the round, your decision is {{player.decision}} but how to write the second part, your opponent's decision is{{?}}. I imitate the Cournot game's method here https://www.otreehub.com/code/, but it seems not working.

Thanks a lot!

#2 by coralio (edited )

Does this work?

{{ player.get_others_in_group.0.decision }}

If not, write this in your page python code:

class YourPage(Page):
    
    @staticmethod
    def vars_for_template(player: Player):
        return dict(
            other = player.get_others_in_group()[0]
            )
and add this to your template: {{ other.decision }}
  
Hope this helps

Write a reply

Set forum username