from otree.api import Currency as c, currency_range from . import pages from ._builtin import Bot from otree.api import Submission from .models import Constants import random import numpy as np decision_type_arr = ["Baseline1", "Extreme1","Control", "EI_only", "EP_only", "Inbetween", "ShiftedBaseline"] p1_Baseline1 = np.array([3.0, 2.5, 2.0, 1.5, 1.0, 0.5, 0.0]) p2_Baseline1 = np.array([0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0]) p1_Baseline2 = 2*p1_Baseline1 p2_Baseline2 = 2*p2_Baseline1 p1_Extreme1 = np.array([7.5, 7.0, 6.5, 6.0, 5.5, 5.0, 4.5])/2 p2_Extreme1 = np.array([1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5])/2 p1_Extreme2 = p1_Extreme1/2 p2_Extreme2 = p2_Extreme1/2 p1_Control = p1_Baseline1 p2_Control = p2_Baseline1 p1_EI_Extreme = np.array([6.0, 5.5, 5.0, 4.5, 4.0, 3.5, 3.0]) p2_EI_Extreme = np.array([0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0]) p1_EP_Extreme = np.array([5.0, 4.5, 4.0, 3.5, 3.0, 2.5, 2.0]) p2_EP_Extreme = np.array([1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0]) p1_EI_only = np.array([4.0, 3.75, 3.5, 3.25, 3.0, 2.75, 2.5]) p2_EI_only = np.array([2.0, 2.25, 2.5, 2.75, 3.0, 3.25, 3.5]) p1_EP_only = np.array([5.5, 5.25, 5.0, 4.75, 4.5, 4.25, 4.0]) p2_EP_only = np.array([0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0]) p1_Inbetween = 0.5*np.array([9.5, 9.0, 8.5, 8.0, 7.5, 7.0, 6.5]) p2_Inbetween = 0.5*np.array([2.5, 3.0, 3.5, 4.0, 3.5, 5.0, 5.5]) p1_EI_only = np.array([4.0, 3.5, 3.0, 2.5, 2.0, 1.5, 1.0]) p2_EI_only = np.array([0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0]) p1_EP_only = np.array([5.6, 5.0, 4.4, 3.8, 3.2, 2.6, 2.0]) p2_EP_only = np.array([0.4, 1.0, 1.6, 2.2, 2.8, 3.4, 4.0]) p1_ShiftedBaseline = np.array([3.0, 2.5, 2.0, 1.5, 1.0, 0.5, 0.0])+0.5 p2_ShiftedBaseline = np.array([0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0])+0.25 p1_dict = {"Baseline1": p1_Baseline1, "Baseline2": p1_Baseline2, "Extreme1": p1_Extreme1, "Extreme2": p1_Extreme2, "Control": p1_Control, "EI_Extreme": p1_EI_Extreme, "EP_Extreme": p1_EP_Extreme, "EI_only": p1_EI_only, "EP_only": p1_EP_only, "Inbetween": p1_Inbetween, "ShiftedBaseline" : p1_ShiftedBaseline} p2_dict = {"Baseline1": p2_Baseline1, "Baseline2": p2_Baseline2, "Extreme1": p2_Extreme1, "Extreme2": p2_Extreme2, "Control": p2_Control, "EI_Extreme": p2_EI_Extreme, "EP_Extreme": p2_EP_Extreme, "EI_only": p2_EI_only, "EP_only": p2_EP_only, "Inbetween": p2_Inbetween, "ShiftedBaseline" : p2_ShiftedBaseline} p1_prize_dict = {"Baseline1": 5.0, "Baseline2": 5.0, "Extreme1": 5.0, "Extreme2": 5.0, "Control": 3.0, "EI_Extreme": 5.0, "EP_Extreme": 5.0, "EI_only": 5.0, "EP_only": 5.0, "Inbetween": 5.0, "ShiftedBaseline": 5.0} p2_prize_dict = {"Baseline1": 1.0, "Baseline2": 1.0, "Extreme1": 1.0, "Extreme2": 1.0, "Control": 3.0, "EI_Extreme": 1.0, "EP_Extreme": 1.0, "EI_only": 1.0, "EP_only": 1.0, "Inbetween": 1.0, "ShiftedBaseline": 1.0} rel_answer_dict = {"Baseline1": 2, "Baseline2": 2, "Extreme1": 1, "Extreme2": 1, "Control": 4, "EI_Extreme": 3, "EP_Extreme": 1, "EI_only": 2, "EP_only": 2, "Inbetween": 1, "ShiftedBaseline": 2} abs_answer_dict = {"Baseline1": 4, "Baseline2": 4, "Extreme1": 7, "Extreme2": 7, "Control": 4, "EI_Extreme": 7, "EP_Extreme": 5, "EI_only": 5, "EP_only": 5, "Inbetween": 7, "ShiftedBaseline": 4} class PlayerBot(Bot): def play_round(self): if self.player.round_number == 1: yield pages.Welcome, dict(name="name", email="a@b.de", iban="DE22120300001060942669", bic="BYLADEM1001") yield pages.Intro yield pages.Introduction_Quiz yield pages.Comprehension_Quiz, dict(comprehension_tries_quiz_1=0, comprehension_tries_quiz_2=0) yield pages.Ready yield pages.Quiz, dict(score=np.random.randint(0, 30)) yield pages.Introduction_Decision yield pages.Comprehension,dict (comprehension_tries_1=0, comprehension_tries_2=0, comprehension_tries_3=0, comprehension_tries_4=0,) yield pages.Before_Decision if self.player.round_number in [1,2,3,4,5,6,7]: type = self.player.decision_type if self.player.in_round(1).debug_follows_type == 0: answer = random.choice([1,2,3,4,5,6,7]) if self.player.in_round(1).debug_follows_type == 1: if self.player.treatment == "Relative": if np.random.binomial(n=1, p=0.5) == 1: answer = rel_answer_dict[type] else: answer = random.choice([1,2,3,4,5,6,7]) if self.player.treatment == "Absolute": if np.random.binomial(n=1, p=0.5) == 1: answer = abs_answer_dict[type] else: answer = random.choice([1,2,3,4,5,6,7]) p1_w = p1_prize_dict[type]+p1_dict[type][answer-1] p2_w = p2_prize_dict[type]+p2_dict[type][answer-1] yield pages.Decision_slim, dict (p1_wealth = p1_w, p2_wealth = p2_w, option_chosen = answer) if self.player.round_number == 7: yield pages.Motive, dict(motive="BLA") yield pages.Advantage, dict(advantage_answer="winner") yield pages.Meritocracy, dict(meritocracy_answer = random.choice([1,0])) yield pages.Guess_2, dict(p1_guess= 6.5, p2_guess=2.5) yield pages.Introduction_Calibration yield pages.Comprehension_Calibration, dict(comprehension_tries_calibration_1=0) if self.player.round_number == 8: yield pages.Calibration_1, dict(calibration_1_p1_wealth = 6.5, calibration_1_p2_wealth= 2.5) yield pages.Calibration_2, dict(calibration_2_p1_wealth = 7.5, calibration_2_p2_wealth= 1.5) yield pages.Final_Questions, dict(knew_difference = 1, would_change=0)