from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) import random class Constants(BaseConstants): name_in_url = "Game_Other_Cheating" players_per_group = 2 num_rounds = 1 num_tasks = 3 Win_rate_Piecerate = 0.5 Win_rate_Self_tournament = 1 coinflip = 0 compete_against_current = 0 DEBUGSESSION = False new_1984_testing_template = "Game_Other_Cheating/new_1984_testing.html" class Subsession(BaseSubsession): def creating_session(self): self.group_randomly() class Group(BaseGroup): pass class Player(BasePlayer): Choice = models.StringField( choices=[["1", "方案(1):如果您选择此任务进行补偿并且此任务最终被随机选上,您将获得按报告的数据每个矩阵0.5元计的赢利。"], ["2", "方案(2):如果随机选择此任务进行补偿,您将在三个任务结束时将与另一个参与者匹配。 如果您报告了比您的对手的任务2更多的矩阵,您将获得按每个矩阵1元计的赢利,否则什么都没有。如果出现平局,按照每一个矩阵获得0.5元奖励。"]], label="请选择您希望通过方案(1)或方案(2)来获得补偿。", widget=widgets.RadioSelect, ) paying_round = models.IntegerField(initial=0) payout_round1 = models.CurrencyField(initial=-1) payout_round2 = models.CurrencyField(initial=-1) payout_round3 = models.CurrencyField(initial=-1) coinflip_if_equal_task2 = models.FloatField(initial=0) coinflip_if_equal_task3 = models.FloatField(initial=0) Nsolved1NEW = models.IntegerField(label="我解决了", max=20, min=0) Nsolved2NEW = models.IntegerField(label="我解决了", max=20, min=0) Nsolved3NEW = models.IntegerField(label="我解决了", max=20, min=0) OpponentSolved2 = models.IntegerField(initial=-1) OpponentSolved3 = models.IntegerField(initial=-1) Coinflip_task2 = models.LongStringField(initial=" ") Coinflip_task3 = models.LongStringField(initial=" ") Choice_boolean_is_tournament = models.BooleanField(initial=False) Experiment_ID = models.IntegerField(label="请输入您的编号") def Final_Payout(self): if self.paying_round == 1: return self.payout_round1 if self.paying_round == 2: return self.payout_round2 if self.paying_round == 3: return self.payout_round3 pass