from . import * from enum import Enum class Case(Enum): LOWEST_POSSIBLE_PROFIT = "end Lowest possible profit" MEDIUM_PROFIT = "end Medium profit" HIGHEST_POSSIBLE_PROFIT = "end Highest possible profit" class PlayerBot(Bot): cases = [case.value for case in [Case.LOWEST_POSSIBLE_PROFIT, Case.MEDIUM_PROFIT, Case.HIGHEST_POSSIBLE_PROFIT]] def play_round(self): if self.player.participant.timeout: print(f"Skipping case {self.case}") return print(f"Playing case {self.case}") if self.case == Case.LOWEST_POSSIBLE_PROFIT.value: self.player.participant.nr_correct_answers_subtractions = 0 self.player.participant.sft_pay = 0 self.player.participant.crt_score = 0 self.player.participant.raven_selection = False self.player.participant.num_correct_words_delay = 0 elif self.case == Case.MEDIUM_PROFIT.value: self.player.participant.nr_correct_answers_subtractions = 3 self.player.participant.sft_pay = 2 self.player.participant.crt_score = 4 self.player.participant.raven_selection = True self.player.participant.num_correct_words_delay = 7 else: # Highest possible profit self.player.participant.nr_correct_answers_subtractions = 5 self.player.participant.sft_pay = 2 self.player.participant.crt_score = 7 self.player.participant.raven_selection = True self.player.participant.num_correct_words_delay = 10 yield Submission(GoToSummary) # As the otree testing setup messes up the values set above, run 'test_helpers.py' # separately and check here based on the observed participant field values. if (self.player.participant.nr_correct_answers_subtractions == 0 and self.player.participant.sft_pay == 0 and self.player.participant.crt_score == 0 and self.player.participant.raven_selection is False and self.player.participant.num_correct_words_delay == 0): expect(self.player.participant.payoff_performance, 0) expect(self.player.payoff, 1) # participation fee expect("In the quiz task you answered 0 out of 7 questions correctly and therefore " "earned 0", "in", self.html) expect("In the matrix selection task, you answered the randomly chosen task " "incorrectly", "in", self.html) expect("earned 0 points in the matrix", "in", self.html) expect("final answer was false and you therefore earned 0 point(s)", "in", self.html) expect("memory task you submitted 0 correct answer(s) and therefore earned 0.0 " "point(s).", "in", self.html) expect("In the strategy following task you did not follow the strategy correctly", "in", self.html) expect("In total you earned 0.0 point(s)", "in", self.html) expect("equal to 0", "in", self.html) expect("fee of $1", "in", self.html) expect("you will receive $1", "in", self.html) elif (self.player.participant.nr_correct_answers_subtractions == 5 and self.player.participant.sft_pay == 2 and self.player.participant.crt_score == 7 and self.player.participant.raven_selection == True and self.player.participant.num_correct_words_delay == 10): # Highest profit expect(self.player.participant.payoff_performance, 4.25) expect(self.player.payoff, 5.25) # participation fee expect("In the quiz task you answered 7 out of 7 questions correctly and therefore " "earned 2", "in", self.html) expect("In the matrix selection task, you answered the randomly chosen task " "correctly", "in", self.html) expect("earned 1 points in the matrix", "in", self.html) expect("final answer was correct and you therefore earned 1 point(s)", "in", self.html) expect("memory task you submitted 10 correct answer(s) and therefore earned 2.5 " "point(s).", "in", self.html) expect("In the strategy following task you followed the strategy correctly and " "therefore earned 2 point(s).", "in", self.html) expect("In total you earned 8.5 point(s)", "in", self.html) expect("equal to 4.25", "in", self.html) expect("fee of $1", "in", self.html) expect("you will receive $5.25", "in", self.html) else: if self.player.participant.crt_score == 7: expect("In the quiz task you answered 7 out of 7 questions correctly and therefore " "earned 2", "in", self.html) else: expect(f"In the quiz task you answered {self.player.participant.crt_score} out of 7 questions correctly and therefore " "earned 0", "in", self.html) if self.player.participant.raven_selection: expect("In the matrix selection task, you answered the randomly chosen task " "correctly", "in", self.html) expect("earned 1 points in the matrix", "in", self.html) else: expect("In the matrix selection task, you answered the randomly chosen task " "incorrectly", "in", self.html) expect("earned 0 points in the matrix", "in", self.html) if self.player.participant.nr_correct_answers_subtractions == 5: expect("final answer was correct and you therefore earned 1 point(s)", "in", self.html) else: expect("final answer was false and you therefore earned 0 point(s)", "in", self.html) expect(f"memory task you submitted {self.player.participant.num_correct_words_delay} correct answer(s) and therefore earned {self.player.participant.audio_pay} " "point(s).", "in", self.html) if self.player.participant.sft_pay != 0: expect("In the strategy following task you followed the strategy correctly and " "therefore earned 2 point(s).", "in", self.html) else: expect("In the strategy following task you did not follow the strategy correctly", "in", self.html) expect(f"In total you earned {self.player.participant.points} point(s)", "in", self.html) expect(f"equal to {self.player.participant.payoff_performance}", "in", self.html) expect("fee of $1", "in", self.html) expect(f"you will receive ${round(self.player.participant.payoff_performance+1,2)}", "in", self.html)