from otree.api import Currency as c, currency_range, expect, Bot from . import * import random class PlayerBot(Bot): def play_round(self): if self.player.period == 1: yield p01_Introduction if self.player.type == '1.consumer.2.producer': if self.player.period == 1: yield p03_MarketA_Consumer, dict(Spend1Red=round(random.uniform(0, 5), 2), Spend1Green=round(random.uniform(0, 5), 2)) else: yield p03_MarketA_Consumer, dict(Spend1Red=round(random.uniform(0, self.player.BalanceRed), 2), Spend1Green=round(random.uniform(0, self.player.BalanceGreen), 2)) yield p06_MarketA_SummaryPage yield p08_MarketB_Producer, dict(Produce2Red=round(random.uniform(0, 10), 2), Produce2Green=round(random.uniform(0, 10), 2)) yield p10_MarketB_SummaryPage else: yield p04_MarketA_Producer, dict(Produce1Red=round(random.uniform(0, 10), 2), Produce1Green=round(random.uniform(0, 10), 2)) yield p06_MarketA_SummaryPage yield p07_MarketB_Consumer, dict(Spend2Red=round(random.uniform(0, self.player.BalanceRed), 2), Spend2Green=round(random.uniform(0, self.player.BalanceGreen), 2)) yield p10_MarketB_SummaryPage if self.player.period == C.block_length: yield p11_BlockCheck if self.player.period >= C.block_length: end_in_round = is_end_within_the_block(self.player.group) if end_in_round > 0 and self.player.sequence <= 2: yield p12_SequenceTransition