from ._builtin import Page, WaitPage from otree.api import Currency as c, currency_range from .models import Constants class Initial_Page(Page): """Informs that the main experiment is starting""" def is_displayed(self): return self.round_number == 1 class Decision_Making(Page): """Makes a choice""" form_model = 'player' form_fields = ['contribution'] def before_next_page(self): self.player.calc_B() def vars_for_template(self): self.subsession.get_game() #from scipy import stats #current_disaster_prob = stats.beta.cdf(self.subsession.initial_trash/Constants.max_trash,Constants.alpha,Constants.beta,loc=0,scale=1) current_disaster_prob = (self.subsession.initial_trash / Constants.max_trash) ** 2 return dict( current_disaster_prob = round(current_disaster_prob*100), ) class Calc_Disaster(Page): timeout_seconds = 5 """Shows the accumulated amouont of trash B""" def vars_for_template(self): return dict( sum_trashB = self.player.total_trash_B - self.subsession.initial_trash ) def before_next_page(self): self.player.calc_disaster() class Result(Page): """Player: Shows the choices they had made""" def vars_for_template(self): return dict( sum_trashB=self.player.total_trash_B - self.subsession.initial_trash ) class Final(Page): """Player: Shows the choices they had made""" def is_displayed(self): return self.round_number == 2 page_sequence = [Initial_Page,Decision_Making,Calc_Disaster,Result,Final]