from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) import random import csv import numpy doc = """ Task 2 - CQ: Instructions and Control questions before Task 2: the series of "Infinitely Repeated Prisoner's Dilemma". """ class Constants(BaseConstants): name_in_url = 'code_task2_CQ_Dorder' players_per_group = 2 players_per_supergroup = 4 num_rounds = 1 other_players_in_group = 3 # rematch_prob = '33%' class Subsession(BaseSubsession): task1_order = models.IntegerField() task2_order = models.IntegerField() def creating_session(self): self.task1_order = self.session.config['task1_order'] self.task2_order = self.session.config['task2_order'] for p in self.get_players(): p.num_supergames = self.session.config['num_supergames'] p.continuation_prob = self.session.config['continuation_prob'] p.delta_limit = self.session.config['delta_limit'] p.conversion_rate = self.session.config['points100_value_eur'] # Payoff from mutual cooperation (Reward Payoff) p.payoff_R = self.session.config['payoff_R'] # Payoff from mutual cooperation (Punishment Payoff) p.payoff_P = self.session.config['payoff_P'] # Payoff from unilateral cooperation (Sucker Payoff) p.payoff_S = self.session.config['payoff_S'] # Payoff from unilateral defection (Temptation Payoff) p.payoff_T = self.session.config['payoff_T'] class Group(BaseGroup): pass class Player(BasePlayer): num_supergames = models.IntegerField() continuation_prob = models.CharField() delta_limit = models.IntegerField() conversion_rate = models.StringField() payoff_R = models.IntegerField() payoff_P = models.IntegerField() payoff_S = models.IntegerField() payoff_T = models.IntegerField() cq2_n1 = models.IntegerField( label="(a) Prima che il primo round abbia inizio verranno formati i gruppi. Quanti partecipanti\ ci saranno in ogni gruppo? ") cq2_n2 = models.IntegerField( label="(b) La durata di ciascun match è:", choices=[[1, 'Pre-determinata'], [2, 'Determinata casualmente']] ) cq2_n3 = models.IntegerField( label="(c) Dopo ciascun round, qual è la probabilità che il match continui per un altro round (in %)?", min=0, max=100) cq2_n4 = models.IntegerField( label="(d) Se un match dura per più di un round, giocherai con lo stesso partner per l’intero match?", choices=[[1, 'Si'], [2, 'No']]) cq2_n5 = models.IntegerField( label="(e) Qual è il tuo guadagno complessivo dal match n.3 - in punti - se il match n.3 dura due round e sia\ tu che la tua controparte avete scelto X in entrambi i round?") cq2_n6 = models.IntegerField( label="(f) Qual è il tuo guadagno complessivo dal match n.4 - in punti - se il match n.4 dura due round e sia\ tu che la tua controparte avete scelto Y in entrambi i round?") cq2_n7 = models.IntegerField( label="(g) Chi sta meglio alla fine del match n.1 se il match n.1 dura due round e in entrambi i round tu\ hai scelto X e la tua controparte Y?", choices=[[1, "Io"], [2, "L'altro partecipante"]] ) cq2_n1_solution = models.IntegerField() cq2_n2_solution = models.StringField() cq2_n2_to_show = models.StringField() cq2_n3_solution = models.IntegerField() cq2_n4_solution = models.StringField() cq2_n4_to_show = models.StringField() cq2_n5_solution = models.IntegerField() cq2_n6_solution = models.IntegerField() cq2_n7_solution = models.StringField() cq2_n7_to_show = models.StringField()