from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) import random doc = """ This is Ultimatum Game, conducted in January 2020 on Yahoo!. It didn't work well; some reported the server error and some reported that their game started in the middle of a game. There was a problem with Yahoo!/Heroku, but not with this game itself. Participants play UG with the bot but they believe that they play with another participant. The bot always becomes a proposer and participants become a responder. In the bc condition, the bot seems to change its choice randomly-- it actually chooses 2 'Cooperate' and 8 'Defect.' """ class Constants(BaseConstants): name_in_url = 'myugbc' players_per_group = None num_rounds = 10 unfair_accept_payoff = c(200) fair_accept_payoff = c(500) reject_payoff = c(0) class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): treatment = models.StringField( choices=['certain', 'uncertain'] ) decision = models.StringField( choices=['Cooperate', 'Defect'], doc="""This player's decision""", widget=widgets.RadioSelect ) bot_decision = models.StringField( choices=['Cooperate', 'Defect'] ) totalpayoff = models.CurrencyField() def condition(self): if self.round_number == 1: self.treatment = random.choice(['certain', 'uncertain']) else: self.treatment = self.in_round(self.round_number - 1).treatment def set_payoff(self): payoff_matrix = dict( Cooperate=dict( Cooperate=Constants.fair_accept_payoff, Defect=Constants.unfair_accept_payoff ), Defect=dict( Cooperate=Constants.reject_payoff, Defect=Constants.reject_payoff ) ) self.payoff = payoff_matrix[self.decision][self.bot_decision] nice_or_nasty = models.IntegerField( label='相手に対する印象の良し悪し', min=0, max=100) certainty = models.IntegerField( label='相手に対する印象の確信度', min=0, max=100) quiz1 = models.StringField( choices=['0コイン', '200コイン', '500コイン', '800コイン', '1000コイン'], label='下から正解を選んでください.', widget=widgets.RadioSelect) quiz3 = models.StringField( choices=['0コイン', '200コイン', '500コイン', '800コイン', '1000コイン'], label='クイズ(1) もし相手(「赤い人」)があなた(「青い人」)に200コインを渡すと提案して, あなたがそれを受け入れたら, あなたはいくら獲得しますか.', widget=widgets.RadioSelect) quiz4 = models.StringField( choices=['0コイン', '200コイン', '500コイン', '800コイン', '1000コイン'], label='クイズ(2) もし相手(「赤い人」)があなた(「青い人」)に200コインを渡すと提案して, あなたがそれを拒否したら, あなたはいくら獲得しますか.', widget=widgets.RadioSelect) motivation1 = models.StringField( choices=['まったく当てはまらない', '少し当てはまらない', 'どちらでもない', 'やや当てはまる', 'とても当てはまる', '※相手の提案を拒否していない場合はこちらをクリックしてください'], label='質問(1) あなたが相手の提案を拒否したのは, そのような提案をしたことに対して相手を罰するためでしたか.', widget=widgets.RadioSelect) motivation2 = models.StringField( choices=['まったく当てはまらない', '少し当てはまらない', 'どちらでもない', 'やや当てはまる', 'とても当てはまる', '※相手の提案を拒否していない場合はこちらをクリックしてください'], label='質問(2) あなたが相手の提案を拒否したのは, それ以降のゲームで相手が同じ提案をしないようにするためでしたか.', widget=widgets.RadioSelect) motivation3 = models.StringField( choices=['まったく当てはまらない', '少し当てはまらない', 'どちらでもない', 'やや当てはまる', 'とても当てはまる', '※相手の提案を拒否していない場合はこちらをクリックしてください'], label='質問(3) あなたが相手の提案を拒否したのは, 相手があなたより多くお金を獲得するのを避けるためでしたか.', widget=widgets.RadioSelect) motivation4 = models.StringField( label='質問(4) あなたが相手の提案を拒否した理由として, 他にありますか. 特になければ「なし」とご記入ください.') concentration1 = models.StringField( choices=['まったく集中できなかった', '少し集中できなかった', 'どちらでもない', 'おおむね集中できた', 'とても集中できた'], label='質問(5) ゲームにどの程度集中できましたか.', widget=widgets.RadioSelect) concentration2 = models.StringField( choices=['今回のデータを分析の対象にするには心配がある', '今回のデータを分析の対象にしても問題ないと思う', 'わからない'], label='質問(6) あなたのデータは, 研究のための分析の対象となる予定です. もしゲームに集中できなかったなどして今回のデータを分析の対象にするには心配がある場合は, お知らせください.', widget=widgets.RadioSelect) comment = models.StringField( label='質問(7) ゲーム全体に関して, 何かご意見やご感想などがあれば, 下の欄にご記入ください. 特になければ「なし」とご記入ください.') sex = models.StringField( choices=['男性', '女性', 'その他'], label='質問(8) あなたの性別を教えてください.', widget=widgets.RadioSelect) age = models.IntegerField( label='質問(9) あなたの年齢を, 半角数字でご入力ください.', min=19, max=99)