from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants ##################################################################################### ##################################################################################### ############################# ############################# ############################# PART 1 ############################# ############################# ############################# ##################################################################################### ##################################################################################### ############################################################ # WELCOME ############################################################ class Intro(Page): #pass after_all_players_arrive = 'creating_session' ############################################################ # SEQUENTIAL PD ############################################################ class Send_SPD(Page): form_model = 'player' form_fields = ['sent_amount_SPD'] #PASSING ON PREDICTION TO THE PAGE def vars_for_template(self): pass #return dict(pred_oppo=self.player.prediction_oppo) ############################################################ # NO MACHINE strategy method decision of second mover ############################################################ class SendBack_SPD(Page): form_model = 'player' form_fields = ['sent_back_amount_SPD_coop', 'sent_back_amount_SPD_defect'] def vars_for_template(self): pass ############################################################ # Calculate income SPD ############################################################ class WaitPageIncomeSpd(WaitPage): after_all_players_arrive = 'set_payoffs_SPD' class End_SPD(Page): pass ##################################################################################### ##################################################################################### ############################# ############################# ############################# PART 2 ############################# ############################# ############################# ##################################################################################### ##################################################################################### ############################################################ # QUESTIONNAIRE + AI ############################################################ class Questionnaire(Page): def is_displayed(self): return self.round_number == 1 form_model = 'player' form_fields = [ 'q_1', 'q_2', 'q_3', 'q_4', 'q_5', 'q_6', 'q_7', 'q_8', 'q_9', 'q_13', 'q_12', 'q_10', 'q_11' ] class Questionnaire2(Page): form_model = 'player' form_fields = [ 'q_tech_anxiety_1', 'q_tech_anxiety_2', 'q_tech_anxiety_3', 'q_tech_anxiety_4', 'q_cs_study', 'q_coding_skill', 'q_subscr', 'q_reco' ] class ShuffleWaitPage(WaitPage): after_all_players_arrive = 'creating_session' ############################################################ # instructions ############################################################ class Introduction(Page): pass #calls the prediction function #after all players arrive calls group 'FUNCTIONS' and #group FUNCIONS calls PLAYER FUNCTION class IntroWaitPage(WaitPage): pass # player.prediction = self.player.in_round(self.round_number - 1).prediction # player.prediction_oppo = self.player.in_round(self.round_number - 1).prediction_oppo class Instructions_1(Page): pass # no machine class Instructions_2(Page): pass # only SM is informed class Instructions_3(Page): pass # both are informed class Instructions_4(Page): pass # both are informed - random machine class Instructions_5(Page): pass ############################################################ # NO MACHINE first mover decision indep ############################################################ class Send(Page): form_model = 'player' form_fields = ['sent_amount'] #PASSING ON PREDICTION TO THE PAGE #def vars_for_template(self): # return dict(pred_oppo=self.player.prediction_oppo) #is not used class SendBackWaitPage(WaitPage): pass ############################################################ # NO MACHINE strategy method decision of second mover ############################################################ class SendBack(Page): form_model = 'player' form_fields = ['sent_back_amount_no_machine'] class BeliefNoMachine(Page): form_model = 'player' form_fields = ['belief_no_machine'] #PAYOFFS FOR TRUST GAME WIHTOUT MACHINES class WaitPageIncomeTrustNoMachine(WaitPage): after_all_players_arrive = 'set_payoffs_trust_no_machine' #defining variables to be passed to the html file #def vars_for_template(self): # tripled_amount = self.player.sent_amount * Constants.multiplier # # return dict( # tripled_amount=tripled_amount, # prompt='Please an amount from 0 to {}'.format(tripled_amount), # ) ############################################################ # WITH MACHINE ############################################################ # random rematching class ShuffleWaitPage(WaitPage): wait_for_all_groups = True after_all_players_arrive = 'creating_session' # creation of predictions for oneself class IntroWaitPage2(WaitPage): after_all_players_arrive = 'functions' # getting the prediction for the assigned opponent class IntroWaitPage3(WaitPage): after_all_players_arrive = 'functions_oppo' # ============================================================================= # With Machine - only second mover informed # ============================================================================= ############################################################ # WITH MACHINE first mover decision indep ############################################################ class Send_with_machine_only_second(Page): form_model = 'player' form_fields = ['sent_amount_with_machine_only_second'] #PASSING ON PREDICTION TO THE PAGE def vars_for_template(self): return dict(pred_oppo=self.player.prediction_oppo) ############################################################ # WITH MACHINE strategy method decision of second mover ############################################################ class SendBack_with_machine_only_second(Page): form_model = 'player' form_fields = ['sent_back_amount_machine_trust_only_second', 'sent_back_amount_machine_no_trust_only_second'] class BeliefMachine_only_second(Page): form_model = 'player' form_fields = ['belief_machine_trust_only_second', 'belief_machine_no_trust_only_second'] class WaitPageIncomeTrustWithMachine_only_second(WaitPage): after_all_players_arrive = 'set_payoffs_trust_machine_only_second' # ============================================================================= # With Machine - both informed # ============================================================================= ############################################################ # WITH MACHINE first mover decision indep ############################################################ class Send_with_machine(Page): form_model = 'player' form_fields = ['sent_amount_with_machine'] #PASSING ON PREDICTION TO THE PAGE def vars_for_template(self): return dict(pred_oppo=self.player.prediction_oppo) ############################################################ # WITH MACHINE strategy method decision of second mover ############################################################ class SendBack_with_machine(Page): form_model = 'player' form_fields = ['sent_back_amount_machine_trust', 'sent_back_amount_machine_no_trust'] class BeliefMachine(Page): form_model = 'player' form_fields = ['belief_machine_trust', 'belief_machine_no_trust'] class WaitPageIncomeTrustWithMachine(WaitPage): after_all_players_arrive = 'set_payoffs_trust_machine' ############################################################ # WITH Random MACHINE first mover decision indep ############################################################ class Send_with_random_machine(Page): form_model = 'player' form_fields = ['sent_amount_with_random_machine'] #PASSING ON PREDICTION TO THE PAGE def vars_for_template(self): return dict(pred_oppo=self.player.prediction_random_oppo) ############################################################ # WITH RANDOM MACHINE strategy method decision of second mover ############################################################ class SendBack_with_random_machine(Page): form_model = 'player' form_fields = ['sent_back_amount_random_machine_trust', 'sent_back_amount_random_machine_no_trust'] class BeliefRandomMachine(Page): form_model = 'player' form_fields = ['belief_random_machine_trust', 'belief_random_machine_no_trust'] class WaitPageIncomeTrustWithRandomMachine(WaitPage): after_all_players_arrive = 'set_payoffs_trust_random_machine' ############################################################ # RESULTS ############################################################ #is not used class ResultsWaitPage(WaitPage): after_all_players_arrive = 'set_payoffs' #displaying the earnings of players class Results(Page): # TODO: Include novel stage 3 calculations! -->Done def vars_for_template(self): return dict( payoff_spd=self.player.payoff_spd, role_spd=self.player.role_spd, oppo_spd=self.player.dec_opponent_spd, payoff_trust_no_machine=self.player.payoff_trust_no_machine, role_trust_no_machine=self.player.role_trust_no_machine, oppo_trust_no_machine=self.player.dec_opponent_trust_no_machine, payoff_trust_machine=self.player.payoff_trust_machine, role_trust_machine=self.player.role_trust_machine, oppo_trust_machine=self.player.dec_opponent_trust_machine, income=self.player.income, op_return_no_machine=self.player.oppo_return_no_machine, op_return_machine_trust=self.player.oppo_return_machine_trust, op_return_machine_no_trust=self.player.oppo_return_machine_no_trust, op_return_no_machine_plus=3+self.player.oppo_return_no_machine, op_return_machine_trust_plus=3+self.player.oppo_return_machine_trust, op_return_machine_no_trust_plus=3+self.player.oppo_return_machine_no_trust, op_return_no_machine_minus=self.player.oppo_return_no_machine-3, op_return_machine_trust_minus=self.player.oppo_return_machine_trust-3, op_return_machine_no_trust_minus=self.player.oppo_return_machine_no_trust-3, payoff_trust_machine_only_second=self.player.payoff_trust_machine_only_second, role_trust_machine_only_second=self.player.role_trust_machine_only_second, oppo_trust_machine_only_second=self.player.dec_opponent_trust_machine_only_second, op_return_machine_trust_only_second=self.player.oppo_return_machine_trust_only_second, op_return_machine_no_trust_only_second=self.player.oppo_return_machine_no_trust_only_second, op_return_machine_trust_plus_only_second=3+self.player.oppo_return_machine_trust_only_second, op_return_machine_no_trust_plus_only_second=3+self.player.oppo_return_machine_no_trust_only_second, op_return_machine_trust_minus_only_second=self.player.oppo_return_machine_trust_only_second-3, op_return_machine_no_trust_minus_only_second=self.player.oppo_return_machine_no_trust_only_second-3, payoff_trust_random_machine=self.player.payoff_trust_random_machine, role_trust_random_machine=self.player.role_trust_random_machine, oppo_trust_random_machine=self.player.dec_opponent_trust_random_machine, op_return_random_machine_trust=self.player.oppo_return_random_machine_trust, op_return_random_machine_no_trust=self.player.oppo_return_random_machine_no_trust, op_return_random_machine_trust_plus=3+self.player.oppo_return_random_machine_trust, op_return_random_machine_no_trust_plus=3+self.player.oppo_return_random_machine_no_trust, op_return_random_machine_trust_minus=self.player.oppo_return_random_machine_trust-3, op_return_random_machine_no_trust_minus=self.player.oppo_return_random_machine_no_trust-3 ) ############################################################ # SEQUENCE OF PAGES ############################################################ # TODO: Include novel stage 3! --> Done page_sequence = [ Intro, Instructions_1, Send_SPD, SendBack_SPD, WaitPageIncomeSpd, End_SPD, Questionnaire, ShuffleWaitPage, Instructions_2, Send, BeliefNoMachine, SendBack, WaitPageIncomeTrustNoMachine, ShuffleWaitPage, IntroWaitPage2, IntroWaitPage3, Instructions_3, Send_with_machine_only_second, BeliefMachine_only_second, SendBack_with_machine_only_second, WaitPageIncomeTrustWithMachine_only_second, Instructions_4, Send_with_machine, BeliefMachine, SendBack_with_machine, Questionnaire2, WaitPageIncomeTrustWithMachine, ResultsWaitPage, Results, ] if Constants.page_sequence > 5 else [ Intro, Instructions_1, SendBack_SPD, Send_SPD, WaitPageIncomeSpd, End_SPD, Questionnaire, ShuffleWaitPage, Instructions_2, SendBack, Send, BeliefNoMachine, WaitPageIncomeTrustNoMachine, ShuffleWaitPage, IntroWaitPage2, IntroWaitPage3, Instructions_3, Send_with_machine_only_second, BeliefMachine_only_second, SendBack_with_machine_only_second, WaitPageIncomeTrustWithMachine_only_second, Instructions_4, SendBack_with_machine, Send_with_machine, BeliefMachine, WaitPageIncomeTrustWithMachine, Questionnaire2, ResultsWaitPage, Results, ]