from otree.api import Bot, Submission from . import ( Age, AssocBelief, AssocBeliefIntro, AssocBenefit, AssocBudget, Children, CompensationIntro, ConditionPicker, Consent, C, Decision, DecisionAfterEvaluation, DecisionBeliefGive, DecisionBeliefRating, DecisionIntro, DecisionIntroAfterEvaluation, DecisionObserversInfo, DecisionObserversInfoAfterEvaluation, DecisionObserversType, DecisionObserversTypeAfterEvaluation, DecisionRecorded, DecisionRecordedAfterEvaluation, Education, EvalInfoChoice, EvalInfoDefaultChoice, Employment, EvalShowARUP, EvalInfoNoChoice, Evaluation, EvaluationBeliefGive, EvaluationBeliefRating, EvaluationIntro, FamilySupport, FinalCode, Gender, GlobalPreference, HelpedStrangerLastMonth, Income, InfoChoice, InfoChoiceAfterEvaluation, InfoDefaultChoice, InfoDefaultChoiceAfterEvaluation, InfoDelay, InfoNoChoice, InfoNoChoiceAfterEvaluation, MaritalStatus, MathAgreement, AttentionCheck, PostIntro, Results, ShowARUP, ShowARUPAfterEvaluation, VolunteeredLastMonth, WelcomeA, ) class PlayerBot(Bot): def play_round(self): condition_cycle = list(C.DEBUG_CONDITION_MAP) condition_count = len(condition_cycle) participant_index = self.player.id_in_subsession - 1 condition_index = participant_index % condition_count condition_pass = participant_index // condition_count forced_condition = condition_cycle[condition_index] mapping = C.DEBUG_CONDITION_MAP donation_choice = 'keep' if condition_pass % 2 == 0 else 'donate' expected_moral_rating = 4 if condition_pass % 2 == 0 else 2 expected_give_rate = 50 if condition_pass % 2 == 0 else 75 choose_to_see_arup = C.INFO_CHOICE_YES if condition_pass % 2 == 0 else C.INFO_CHOICE_NO opt_out_of_arup = condition_pass % 2 == 1 yield Consent, {'consent': True} if ConditionPicker.is_displayed(self.player): yield ConditionPicker, {'debug_condition_choice': forced_condition} game, inf = mapping[forced_condition] else: game = self.player.participant.vars['game'] inf = self.player.participant.vars['inf'] if WelcomeA.get_form_fields(self.player): yield WelcomeA, {'yapper_id': 123456} else: yield WelcomeA yield InfoDelay yield CompensationIntro yield Age, {'age': 30} yield Education, {'education': 'BAC d’enseignement général'} yield Employment, {'employment_status': 'En emploi'} yield Income, {'income_monthly': 'De 2001 à 2500 euros par mois'} yield Gender, {'gender': 'Homme'} yield MaritalStatus, {'marital_status': 'Célibataire'} yield Children, {'children': 'Non'} yield MathAgreement, {'math_agreement': 7} yield GlobalPreference, {'global_preference': 'Comme moi'} yield HelpedStrangerLastMonth, {'helped_stranger_last_month': 'Oui'} yield VolunteeredLastMonth, {'volunteered_last_month': 'Non'} yield FamilySupport, {'family_support': 6} yield AttentionCheck, {'attention_check': 5} if game in [1, 2, 4]: yield DecisionIntro if inf == C.INF_NOINFO: yield InfoNoChoice elif inf == C.INF_INFO: yield InfoChoice, {'info_choice': choose_to_see_arup} yield ShowARUP elif inf == C.INF_INFO_DEFAULT: yield InfoDefaultChoice, {'info_default_opt_out': opt_out_of_arup} yield ShowARUP yield DecisionObserversInfo yield DecisionObserversType yield Decision, {'donation_choice': donation_choice} if game in [1, 2]: yield DecisionRecorded yield DecisionBeliefRating, {'expected_moral_rating': expected_moral_rating} yield DecisionBeliefGive, {'expected_give_rate': expected_give_rate} elif game == 4: yield DecisionRecorded if game in [3, 4]: yield EvaluationIntro if inf == C.INF_NOINFO: yield EvalInfoNoChoice elif inf == C.INF_INFO: yield EvalInfoChoice, {'eval_info_choice': choose_to_see_arup} yield EvalShowARUP elif inf == C.INF_INFO_DEFAULT: yield EvalInfoDefaultChoice, {'eval_info_default_opt_out': opt_out_of_arup} yield EvalShowARUP yield Evaluation, {'moral_rating': expected_moral_rating, 'moral_comment': 'RAS'} if game == 3: yield DecisionIntroAfterEvaluation if inf == C.INF_NOINFO: yield InfoNoChoiceAfterEvaluation elif inf == C.INF_INFO: yield InfoChoiceAfterEvaluation, {'info_choice': choose_to_see_arup} yield ShowARUPAfterEvaluation elif inf == C.INF_INFO_DEFAULT: yield InfoDefaultChoiceAfterEvaluation, {'info_default_opt_out': opt_out_of_arup} yield ShowARUPAfterEvaluation yield DecisionObserversInfoAfterEvaluation yield DecisionObserversTypeAfterEvaluation yield DecisionAfterEvaluation, {'donation_choice': donation_choice} yield DecisionRecordedAfterEvaluation yield PostIntro if game in [3, 4]: yield EvaluationBeliefRating, {'expected_peer_rating': expected_moral_rating} yield EvaluationBeliefGive, {'expected_peer_give': expected_give_rate} yield AssocBeliefIntro yield AssocBelief, {'arup_belief_1': 60, 'arup_belief_2': 40} yield AssocBenefit, {'arup_beneficial': 4} yield AssocBudget, {'arup_budget_percent': 20} if Results.get_form_fields(self.player): yield Results, {'share_contact_consent': True} else: yield Results yield Submission(FinalCode, check_html=False)