from otree.api import Currency as cu, currency_range from . import * from otree.api import Bot import random as random import json as json from otree.api import SubmissionMustFail pairs = [1, 2, 3, 4, 5, 6, 7, 8] moves = list(range(1,24)) class PlayerBot(Bot): def play_round(self): def make_max(self): """Reverse engineers which of the choices is the right math answer.""" choice_results = [] # Convert them back into a list choice_list = json.loads(self.player.choices_nums) for i in choice_list: # Make list of actual results choice_results.append(Constants.results_list[i]) max_num = choice_list[choice_results.index(max(choice_results))] return max_num #yield Introduction if self.player.id_in_group == 1: # Bot is configured to achieve the maximum payoff if self.player.order_tasks == 'ABB': yield ABB, dict(math_task=make_max(self), moves_1=random.choice(moves), moves_2=random.choice(moves), memory_1=8, memory_2=8, timer_task1=1, new_timer_task1=1, timer_task2=1, new_timer_task2=1, timer_task3=1, new_timer_task3=1, total_time=1) if self.player.order_tasks == 'BAB': yield BAB, dict(math_task=make_max(self), moves_1=random.choice(moves), moves_2=random.choice(moves), memory_1=8, memory_2=8, timer_task1=1, new_timer_task1=1, timer_task2=1, new_timer_task2=1, timer_task3=1, new_timer_task3=1, total_time=1) if self.player.order_tasks == 'BBA': yield BBA, dict(math_task=make_max(self), moves_1=random.choice(moves), moves_2=random.choice(moves), memory_1=8, memory_2=8, timer_task1=1, new_timer_task1=1, timer_task2=1, new_timer_task2=1, timer_task3=1, new_timer_task3=1, total_time=1) else: if self.player.order_tasks == 'ABB': yield ABB, dict(math_task=random.choice(json.loads(self.player.choices_nums)), moves_1=random.choice(moves), moves_2=random.choice(moves), memory_1=random.choice(pairs), memory_2=random.choice(pairs), timer_task1=1, new_timer_task1=1, timer_task2=1, new_timer_task2=1, timer_task3=1, new_timer_task3=1, total_time=1) if self.player.order_tasks == 'BAB': yield BAB, dict(math_task=random.choice(json.loads(self.player.choices_nums)), moves_1=random.choice(moves), moves_2=random.choice(moves), memory_1=random.choice(pairs), memory_2=random.choice(pairs), timer_task1=1, new_timer_task1=1, timer_task2=1, new_timer_task2=1, timer_task3=1, new_timer_task3=1, total_time=1) if self.player.order_tasks == 'BBA': yield BBA, dict(math_task=random.choice(json.loads(self.player.choices_nums)), moves_1=random.choice(moves), moves_2=random.choice(moves), memory_1=random.choice(pairs), memory_2=random.choice(pairs), timer_task1=1, new_timer_task1=1, timer_task2=1, new_timer_task2=1, timer_task3=1, new_timer_task3=1, total_time=1) yield RoundOverview if self.round_number == Constants.num_rounds: yield CompleteOverview