#1 by alid3mir
Hi all, I am trying to write a Rubinstein game which I will use in my experiment. I am getting the error message in the headline. The code in pycharm is as follows: ------------------------------------------------------------------------------------------------- from otree.api import * doc = """ Rubinstein Bargaining Game with follwing properties: The pie to bargain on: 100 ECU Two players: One proposes, one accepts/rejects If the responder accept the proposal, they recieve the relevant amount. If not in the next round: They swith roles and The pie dimnishes by 25 ECU If there is no agreement, the game stops after the 4th round. (When the total pie is over) In this game we will have two separate games. The players play the game twice with different partners. """ class C(BaseConstants): NAME_IN_URL = 'rubinstein' PLAYERS_PER_GROUP = 2 NUM_ROUNDS = 8 initial_pie = cu(100) dimnishing = cu(25) class Group(BaseGroup): offer = models.CurrencyField(min=0, label = "How much would you like to offer?") response = models.StringField(choices = ["accept", "reject"], label = "Please tell your response",) current_pie = models.CurrencyField() def offer_max(group: Group): group.current_pie = C.initial_pie - ((group.round_number - 1) % 4) * C.dimnishing return group.current_pie class Subsession(BaseSubsession): def creating_session(group: Group): if group.round_number in [1,5]: group.group_randomly() else: group.group_like_round(group.round_number -1) print(group.get_group_matrix()) # Here we add the print statement so we can actually see it. class Player(BasePlayer): def role(group: Group): if group.round_number % 2 == 1: return {1: 'proposer', 2: 'responder'}[group.id_in_group] else: return {2: 'proposer', 1: 'responder'}[group.id_in_group] class Offer(Page): form_model = 'group' form_fields = ['offer'] def is_displayed(group: Group): return group.player.role() == 'proposer' class Response(Page): form_model = 'group' form_fields = ['response'] def is_displayed(group: Group): return group.player.role() == 'responder' class Offer(Page): form_model = 'group' form_fields = ['offer'] def is_displayed(group: Group): return group.player.role() == 'proposer' class Response(Page): form_model = 'group' form_fields = ['response'] def is_displayed(group: Group): return group.player.role() == 'responder' class WaitOffer(WaitPage): pass class WaitResponse(WaitPage): pass class Results(Page): pass page_sequence = [Offer, WaitOffer, Response, WaitResponse, Results] ------------------------------------------------------------------------------------------------- It would be super nice if someone out there can help me :) Thanks in advance!
#2 by alid3mir
Is there anybody who can help me?