from otree.api import Currency as c, currency_range from . import pages from ._builtin import Bot from .models import Constants import random class PlayerBot(Bot): cases = ['greedy_case', 'random', 'generous'] #different bot cases will be created for each of these names, based on the condition stated below def play_round(self): if self.round_number == 1: yield pages.Intro if self.case == 'greedy_case': contribution = 0 elif self.case == 'random': contribution = random.randint(0, self.player.endowment) else: contribution = self.player.endowment #since we have one treatment, whicih gives random endowment, we have not included constant.endow here yield pages.Contribution, {'contribution': contribution} yield pages.Results if self.round_number == Constants.num_rounds: yield pages.FinalResults