from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) import itertools author = 'Your name here' doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'simulation' players_per_group = 3 # Policy Expert, Cyber Expert, and Military Expert num_rounds = 3 rapid = itertools.cycle([True, False]) options_1 = [ [1, 'Watch and Wait', 'Collect more information about the cyber attack.'], [2, 'Private Attribution', 'Privately attribute the source of the cyber attack to Vadare.'], [3, 'Public Attribution', 'Publicly attribute the source of the cyber attack to Vadare.'], [4, 'Cyber Offensive', 'Retaliate against the sources of the cyber attack in Vadare.'] ] options_2 = [ [1, 'Yield', 'Yield to the demands and pay the ransom.'], [2, 'Criminal Indictments', 'File criminal indictments against officials in Vadare.'], [3, 'Economic Sanctions', 'Impose immediate economic sanctions on Vadare.'], [4, 'Cyber Offensive', 'Retaliate against equivalent systems in Vadare.'], [5, 'Military Stand-By', 'Place military forces on alert as a signal to Vadare.'], ] options_3 = [ [1, 'Suspend Decision', 'Suspend the previous decision in order to collect more information.'], [2, 'Continue with Decision', ''] ] class Subsession(BaseSubsession): # Maintain groupings across rounds. def creating_session(self): if self.round_number == 1: pass else: self.group_like_round(1) class Group(BaseGroup): # Group decision per round decision = models.IntegerField() # Dissent, at least one individual does not agree dissent = models.BooleanField() # Chaos, each participant has a different preference chaos = models.BooleanField() # Rapid escalation rapid = models.BooleanField() class Player(BasePlayer): # Participant choice per round, temporary variable choice = models.IntegerField() def get_choice(self): return self.choice def role(self): if self.participant.vars['role'] == 1: return 'policy' elif self.participant.vars['role'] == 2: return 'cyber' else: return 'military'