from otree.api import * c = cu doc = '人相手のじゃんけん\n' class C(BaseConstants): NAME_IN_URL = 'PRSvshuman' PLAYERS_PER_GROUP = 2 NUM_ROUNDS = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): my_field = models.IntegerField() def set_payoffs(group: Group): for p in group.get_players(): p.Choice_other = p.get_others_in_group()[0].Choice if p.Choice == p.Choice_other: p.Win = 0 elif p.Choice == p.Choice_other - 1 or (p.Choice == 3 and p.Choice_other == 1): p.Win = 1 else: p.Win = -1 class Player(BasePlayer): Choice_other = models.IntegerField(choices=[[1, 'ぐー'], [2, 'ちょき'], [3, 'ぱー']]) Choice = models.IntegerField(choices=[[1, 'ぐー'], [2, 'ちょき'], [3, 'ぱー']]) Win = models.IntegerField() class Decision(Page): form_model = 'player' form_fields = ['Choice'] class MyWaitPage(WaitPage): after_all_players_arrive = set_payoffs class Result(Page): form_model = 'player' page_sequence = [Decision, MyWaitPage, Result]