from otree.api import Currency as c, currency_range from . import pages from ._builtin import Bot from .models import Constants import random # pylint: disable=no-member class PlayerBot(Bot): def play_round(self): avail_markets = [ 'Corn', 'Wheat', 'Rice', 'Soybeans' ] if self.round_number == 1: yield (pages.Introduction) elif self.round_number == 2: print("Random Market Selection:") market_choice = random.choice(avail_markets) yield (pages.Decide, {'market_choice' : market_choice}) yield(pages.Results) # for whatever reason, this fails: # best_market in the previous round is returned as None # it works if the bots time out in a normal session, I feel like this # has something to do with the test database used by django/otree # all functions in the ResultsWaitPage() method get called, but no # values are being saved... else: market_choice = self.group.best_response() yield (pages.Decide, {'market_choice': market_choice}) yield(pages.Results)