from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) import random author = 'Your name here' doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'game_ai' players_per_group = None num_rounds = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): offer = models.PositiveIntegerField(min=0, max=100) info_value = models.PositiveIntegerField(min=0, max=100) chosen_digit = models.PositiveIntegerField( choices=[ ( 0 , 'zero (0)' ), ( 1 , 'one (1)' ), ( 2 , 'two (2)' ), ( 3 , 'three (3)' ), ( 4 , 'four (4)' ), ( 5 , 'five (5)' ), ( 6 , 'six (6)' ), ( 7 , 'seven (7)' ), ( 8 , 'eigth (8)' ), ( 9 , 'nine (9)' ) ], widget=widgets.RadioSelectHorizontal) q1 = models.PositiveIntegerField(initial=None, choices=[ ( 0 , 'Climate change is a serious threat that demands urgent action' ), ( 1 , 'Climate change is exaggerated and instrumentalized to push actions that harm the economy' ) ], widget=widgets.RadioSelect) q2 = models.PositiveIntegerField(initial=None, choices=[ ( 0 , 'Freedom' ), ( 1 , 'Solidarity' ) ], widget=widgets.RadioSelect) q3 = models.PositiveIntegerField(initial=None, choices=[ ( 0 , 'Republicans' ), ( 1 , 'Democrats' ) ], widget=widgets.RadioSelect) audio1 = models.PositiveIntegerField(initial=None, choices=[ ( 0 , 'Yanney' ), ( 1 , 'Laurel' ) ], widget=widgets.RadioSelect) audio2 = models.PositiveIntegerField(initial=None, choices=[ ( 1 , 'Laurel' ), ( 0 , 'Yanney' ) ], widget=widgets.RadioSelect) w_audio = models.PositiveIntegerField() #check_iq = models.CharField(initial=None, max_length=50) check_q = models.CharField(initial=None, max_length=50) def set_payments(self): self.chosen_digit = 9 if self.offer >= self.info_value: self.participant.vars['i_lottery'] = 1 self.participant.vars['i_price'] = self.info_value #self.participant.vars['i_digit'] = self.chosen_digit else: self.participant.vars['i_lottery'] = 0 self.participant.vars['i_price'] = 0