from otree.api import ( <<<<<<< HEAD models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) ======= models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) >>>>>>> 0982dc5566ffb7cb2176b6338e4f4497a3d00fc3 doc = """ This is a one-shot "Prisoner's Dilemma". Two players are asked separately whether they want to cooperate or defect. Their choices directly determine the payoffs. """ class Constants(BaseConstants): name_in_url = 'prisoner' players_per_group = 2 num_rounds = 1 <<<<<<< HEAD instructions_template = 'prisoner/instructions.html' ======= instructions_template = 'prisoner/Instructions.html' >>>>>>> 0982dc5566ffb7cb2176b6338e4f4497a3d00fc3 # payoff if 1 player defects and the other cooperates""", betray_payoff = c(300) betrayed_payoff = c(0) # payoff if both players cooperate or both defect both_cooperate_payoff = c(200) both_defect_payoff = c(100) class Subsession(BaseSubsession): pass class Group(BaseGroup): <<<<<<< HEAD def set_payoffs(self): for p in self.get_players(): p.set_payoff() ======= pass >>>>>>> 0982dc5566ffb7cb2176b6338e4f4497a3d00fc3 class Player(BasePlayer): decision = models.StringField( <<<<<<< HEAD choices=[['Cooperate', 'Cooperate'], ['Defect', 'Defect']], doc="""This player's decision""", widget=widgets.RadioSelect, ======= choices=['Cooperate', 'Defect'], doc="""This player's decision""", widget=widgets.RadioSelect >>>>>>> 0982dc5566ffb7cb2176b6338e4f4497a3d00fc3 ) def other_player(self): return self.get_others_in_group()[0] def set_payoff(self): <<<<<<< HEAD payoff_matrix = dict( Cooperate=dict( Cooperate=Constants.both_cooperate_payoff, Defect=Constants.betrayed_payoff, ), Defect=dict( Cooperate=Constants.betray_payoff, Defect=Constants.both_defect_payoff ), ) self.payoff = payoff_matrix[self.decision][self.other_player().decision] ======= payoff_matrix = { 'Cooperate': { 'Cooperate': Constants.both_cooperate_payoff, 'Defect': Constants.betrayed_payoff }, 'Defect': { 'Cooperate': Constants.betray_payoff, 'Defect': Constants.both_defect_payoff } } self.payoff = payoff_matrix[self.decision][self.other_player().decision] >>>>>>> 0982dc5566ffb7cb2176b6338e4f4497a3d00fc3