from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) # Model number 8 author = 'Joseph Lee' doc = """ NTUEXP: seven_tworing for Task 2 """ class Constants(BaseConstants): name_in_url = 'seven_tworing_t4' players_per_group = 7 num_rounds = 5 deletelink = c(110) remainlink = c(100) totime = 60 player1 = 'J' player2 = 'N' player3 = 'T' player4 = 'Y' player5 = 'E' player6 = 'C' player7 = 'A' class Subsession(BaseSubsession): # Group the participants def creating_session(self): if self.round_number == 1: self.group_randomly() else: self.group_like_round(1) # Initialize the network for g in self.get_groups(): g.AB = 1 g.BA = 1 g.AC = 0 g.CA = 0 # BC changed to CA - ws May g.AD = 1 g.DA = 1 g.AE = 0 g.EA = 0 # BE changed to EA - ws May g.BC = 1 g.CB = 1 g.BD = 0 g.DB = 0 g.BE = 0 g.EB = 0 g.CD = 1 g.DC = 1 g.CE = 0 g.EC = 0 g.DE = 1 g.ED = 1 g.AF = 0 g.FA = 0 g.DF = 1 g.FD = 1 g.DG = 0 g.GD = 0 g.FG = 1 g.GF = 1 g.EG = 1 g.GE = 1 # initialize the counter to see how many people have chosen not to delete any link g.CO = 0 g.done = 0 for p in self.get_players(): p.rpayoff = c(0) p.participant.vars['PayoffT4b'] = c(0) class Group(BaseGroup): AB = models.IntegerField() AC = models.IntegerField() AD = models.IntegerField() AE = models.IntegerField() BA = models.IntegerField() BC = models.IntegerField() BD = models.IntegerField() BE = models.IntegerField() CA = models.IntegerField() CB = models.IntegerField() CD = models.IntegerField() CE = models.IntegerField() DA = models.IntegerField() DB = models.IntegerField() DC = models.IntegerField() DE = models.IntegerField() EA = models.IntegerField() EB = models.IntegerField() EC = models.IntegerField() ED = models.IntegerField() # additional links for seven AF = models.IntegerField() FA = models.IntegerField() DF = models.IntegerField() FD = models.IntegerField() DG = models.IntegerField() GD = models.IntegerField() FG = models.IntegerField() GF = models.IntegerField() EG = models.IntegerField() GE = models.IntegerField() CO = models.IntegerField() done = models.IntegerField() p1sel = models.StringField( widget=widgets.RadioSelect ) p2sel = models.StringField( widget=widgets.RadioSelect ) p3sel = models.StringField( widget=widgets.RadioSelect ) p4sel = models.StringField( widget=widgets.RadioSelect ) p5sel = models.StringField( widget=widgets.RadioSelect ) p6sel = models.StringField( widget=widgets.RadioSelect ) p7sel = models.StringField( widget=widgets.RadioSelect ) def check_empty(self): if self.AB == 0 and self.AD == 0 and self.BC == 0 and self.BD == 0 and \ self.CD == 0 and self.CE == 0 and self.DE == 0 and self.AF == 0 \ and self.DF == 0 and self.FG == 0 and self.DG == 0 and self.EG == 0: return 1 else: return 0 def set_var_1(self): p1 = self.get_player_by_id(1) if self.p1sel == 'Delete the link with Participant ' + Constants.player2: p1.participant.vars['PayoffT4b'] += Constants.deletelink for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = 0 g.AB = 0 g.BA = 0 elif self.p1sel == 'Delete the link with Participant ' + Constants.player3: p1.participant.vars['PayoffT4b'] += Constants.deletelink for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = 0 g.AC = 0 g.CA = 0 elif self.p1sel == 'Delete the link with Participant ' + Constants.player4: p1.participant.vars['PayoffT4b'] += Constants.deletelink for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = 0 g.AD = 0 g.DA = 0 elif self.p1sel == 'Delete the link with Participant ' + Constants.player5: p1.participant.vars['PayoffT4b'] += Constants.deletelink for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = 0 g.AE = 0 g.EA = 0 elif self.p1sel == 'Delete the link with Participant ' + Constants.player6: p1.participant.vars['PayoffT4b'] += Constants.deletelink for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = 0 g.AF = 0 g.FA = 0 else: for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO += 1 # check for empty network if self.check_empty() == 1: for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = Constants.players_per_group def set_var_2(self): p2 = self.get_player_by_id(2) if self.p2sel == 'Delete the link with Participant ' + Constants.player1: p2.participant.vars['PayoffT4b'] += Constants.deletelink for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = 0 g.AB = 0 g.BA = 0 elif self.p2sel == 'Delete the link with Participant ' + Constants.player3: p2.participant.vars['PayoffT4b'] += Constants.deletelink for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = 0 g.BC = 0 g.CB = 0 elif self.p2sel == 'Delete the link with Participant ' + Constants.player4: p2.participant.vars['PayoffT4b'] += Constants.deletelink for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = 0 g.BD = 0 g.DB = 0 elif self.p2sel == 'Delete the link with Participant ' + Constants.player5: p2.participant.vars['PayoffT4b'] += Constants.deletelink for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = 0 g.BE = 0 g.EB = 0 else: for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO += 1 if self.check_empty() == 1: for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = Constants.players_per_group def set_var_3(self): p3 = self.get_player_by_id(3) if self.p3sel == 'Delete the link with Participant ' + Constants.player1: p3.participant.vars['PayoffT4b'] += Constants.deletelink for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = 0 g.AC = 0 g.CA = 0 elif self.p3sel == 'Delete the link with Participant ' + Constants.player2: p3.participant.vars['PayoffT4b'] += Constants.deletelink for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = 0 g.BC = 0 g.CB = 0 elif self.p3sel == 'Delete the link with Participant ' + Constants.player4: p3.participant.vars['PayoffT4b'] += Constants.deletelink for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = 0 g.CD = 0 g.DC = 0 elif self.p3sel == 'Delete the link with Participant ' + Constants.player5: p3.participant.vars['PayoffT4b'] += Constants.deletelink for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = 0 g.CE = 0 g.EC = 0 else: for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO += 1 if self.check_empty() == 1: for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = Constants.players_per_group def set_var_4(self): p4 = self.get_player_by_id(4) if self.p4sel == 'Delete the link with Participant ' + Constants.player1: p4.participant.vars['PayoffT4b'] += Constants.deletelink for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = 0 g.AD = 0 g.DA = 0 elif self.p4sel == 'Delete the link with Participant ' + Constants.player2: p4.participant.vars['PayoffT4b'] += Constants.deletelink for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = 0 g.BD = 0 g.DB = 0 elif self.p4sel == 'Delete the link with Participant ' + Constants.player3: p4.participant.vars['PayoffT4b'] += Constants.deletelink for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = 0 g.CD = 0 g.DC = 0 elif self.p4sel == 'Delete the link with Participant ' + Constants.player5: p4.participant.vars['PayoffT4b'] += Constants.deletelink for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = 0 g.DE = 0 g.ED = 0 elif self.p4sel == 'Delete the link with Participant ' + Constants.player6: p4.participant.vars['PayoffT4b'] += Constants.deletelink for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = 0 g.DF = 0 g.FD = 0 elif self.p4sel == 'Delete the link with Participant ' + Constants.player7: p4.participant.vars['PayoffT4b'] += Constants.deletelink for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = 0 g.DG = 0 g.GD = 0 else: for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO += 1 if self.check_empty() == 1: for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = Constants.players_per_group def set_var_5(self): p5 = self.get_player_by_id(5) if self.p5sel == 'Delete the link with Participant ' + Constants.player1: p5.participant.vars['PayoffT4b'] += Constants.deletelink for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = 0 g.AE = 0 g.EA = 0 elif self.p5sel == 'Delete the link with Participant ' + Constants.player2: p5.participant.vars['PayoffT4b'] += Constants.deletelink for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = 0 g.BE = 0 g.EB = 0 elif self.p5sel == 'Delete the link with Participant ' + Constants.player3: p5.participant.vars['PayoffT4b'] += Constants.deletelink for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = 0 g.CE = 0 g.EC = 0 elif self.p5sel == 'Delete the link with Participant ' + Constants.player4: p5.participant.vars['PayoffT4b'] += Constants.deletelink for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = 0 g.DE = 0 g.ED = 0 elif self.p5sel == 'Delete the link with Participant ' + Constants.player7: p5.participant.vars['PayoffT4b'] += Constants.deletelink for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = 0 g.GE = 0 g.EG = 0 else: for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO += 1 if self.check_empty() == 1: for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = Constants.players_per_group def set_var_6(self): p6 = self.get_player_by_id(6) if self.p6sel == 'Delete the link with Participant ' + Constants.player1: p6.participant.vars['PayoffT4b'] += Constants.deletelink for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = 0 g.AF = 0 g.FA = 0 elif self.p6sel == 'Delete the link with Participant ' + Constants.player4: p6.participant.vars['PayoffT4b'] += Constants.deletelink for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = 0 g.DF = 0 g.FD = 0 elif self.p6sel == 'Delete the link with Participant ' + Constants.player7: p6.participant.vars['PayoffT4b'] += Constants.deletelink for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = 0 g.GF = 0 g.FG = 0 else: for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO += 1 if self.check_empty() == 1: for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = Constants.players_per_group def set_var_7(self): p7 = self.get_player_by_id(7) if self.p7sel == 'Delete the link with Participant ' + Constants.player4: p7.participant.vars['PayoffT4b'] += Constants.deletelink for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = 0 g.DG = 0 g.GD = 0 elif self.p7sel == 'Delete the link with Participant ' + Constants.player5: p7.participant.vars['PayoffT4b'] += Constants.deletelink for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = 0 g.EG = 0 g.GE = 0 elif self.p7sel == 'Delete the link with Participant ' + Constants.player6: p7.participant.vars['PayoffT4b'] += Constants.deletelink for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = 0 g.GF = 0 g.FG = 0 else: for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO += 1 if self.check_empty() == 1: for g in self.in_rounds(self.round_number, Constants.num_rounds): g.CO = Constants.players_per_group def set_payoff(self): p1 = self.get_player_by_id(1) p2 = self.get_player_by_id(2) p3 = self.get_player_by_id(3) p4 = self.get_player_by_id(4) p5 = self.get_player_by_id(5) p6 = self.get_player_by_id(6) p7 = self.get_player_by_id(7) if self.AB == 1: p1.participant.vars['PayoffT4b'] += Constants.remainlink p2.participant.vars['PayoffT4b'] += Constants.remainlink if self.AC == 1: p1.participant.vars['PayoffT4b'] += Constants.remainlink p3.participant.vars['PayoffT4b'] += Constants.remainlink if self.AD == 1: p1.participant.vars['PayoffT4b'] += Constants.remainlink p4.participant.vars['PayoffT4b'] += Constants.remainlink if self.AE == 1: p1.participant.vars['PayoffT4b'] += Constants.remainlink p5.participant.vars['PayoffT4b'] += Constants.remainlink if self.BC == 1: p2.participant.vars['PayoffT4b'] += Constants.remainlink p3.participant.vars['PayoffT4b'] += Constants.remainlink if self.BD == 1: p2.participant.vars['PayoffT4b'] += Constants.remainlink p4.participant.vars['PayoffT4b'] += Constants.remainlink if self.BE == 1: p2.participant.vars['PayoffT4b'] += Constants.remainlink p5.participant.vars['PayoffT4b'] += Constants.remainlink if self.CD == 1: p3.participant.vars['PayoffT4b'] += Constants.remainlink p4.participant.vars['PayoffT4b'] += Constants.remainlink if self.CE == 1: p3.participant.vars['PayoffT4b'] += Constants.remainlink p5.participant.vars['PayoffT4b'] += Constants.remainlink if self.DE == 1: p4.participant.vars['PayoffT4b'] += Constants.remainlink p5.participant.vars['PayoffT4b'] += Constants.remainlink if self.AF == 1: p1.participant.vars['PayoffT4b'] += Constants.remainlink p6.participant.vars['PayoffT4b'] += Constants.remainlink if self.DF == 1: p4.participant.vars['PayoffT4b'] += Constants.remainlink p6.participant.vars['PayoffT4b'] += Constants.remainlink if self.FG == 1: p7.participant.vars['PayoffT4b'] += Constants.remainlink p6.participant.vars['PayoffT4b'] += Constants.remainlink if self.DG == 1: p4.participant.vars['PayoffT4b'] += Constants.remainlink p7.participant.vars['PayoffT4b'] += Constants.remainlink if self.EG == 1: p5.participant.vars['PayoffT4b'] += Constants.remainlink p7.participant.vars['PayoffT4b'] += Constants.remainlink for p in self.get_players(): p.rpayoff = p.participant.vars['PayoffT4b'] p.payoff = p.rpayoff # - ws Apr def set_done(self): pass class Player(BasePlayer): rpayoff = models.CurrencyField()