from otree.api import * import random doc = """ Your app description """ class C(BaseConstants): NAME_IN_URL = 'Results' PLAYERS_PER_GROUP = None NUM_ROUNDS = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): pass #FUNCTIONS # PAGES class Results(Page): ''' I presents the results of the model by invoking the participants fields. I take the biggest payoff in each round to present the menu of payoff to the players. The final payoff is the determined by randomisation. ''' @staticmethod def vars_for_template(player: Player): participant = player.participant bribe_game_token_payoff = participant.bribe_game_token_payoff bribe_game_decision_payoff = participant.bribe_game_payoff total_bribe_game_payoff = (bribe_game_token_payoff + random.choice(bribe_game_decision_payoff)) corruption_game_token_payoffs = [random.choice(el) for el in participant.corruption_game_token_payoff] corruption_game_decision_payoffs = [] for payoff_in_round in participant.corruption_game_payoffs: corruption_game_decision_payoffs.append(random.choice([random.choice(el) for el in payoff_in_round])) total_corruption_game_payoff = [corruption_game_token_payoffs[el] + corruption_game_decision_payoffs[el] for el in [0, 1, 2]] return dict(bribe_game_token_payoff=bribe_game_token_payoff, bribe_game_decision_payoff=bribe_game_decision_payoff, total_bribe_game_payoff=total_bribe_game_payoff, corruption_game_token_payoffs=corruption_game_token_payoffs, corruption_game_decision_payoffs=corruption_game_decision_payoffs, total_corruption_game_payoff=total_corruption_game_payoff) page_sequence = [Results]