# -*- coding: utf-8 -*- from __future__ import division import random from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) from ._builtin import Bot from .models import Constants from . import views import random class PlayerBot(Bot): def play_round(self): if self.round_number == 1: yield (views.Introduction) # results if self.round_number == 13: yield (views.FinalResults) else: # Decide page: # units to produce # in an actual expirament, we'll determine total capacity based on the number of players # since we are using bots in a test case I've hard-coded the capacity to 4 (the number of bots) total_capacity = (self.session.config['total_capacity'] / 4) if self.round_number == 1: units = random.randrange(1, total_capacity, 1) yield (views.Decide, {'units' : units}) else: previous_round_units = self.player.in_round(self.round_number -1) units = self.group.best_response(previous_round_units.units) units = int(units) yield (views.Decide, {'units' : units}) yield (views.Results) def validate_play(self): pass