from otree.api import * from random import choice import random class C(BaseConstants): NAME_IN_URL = 'Start' PLAYERS_PER_GROUP = 12 NUM_ROUNDS = 1 VOTES = cu(1) # 報酬 exchange_rate = 1 #定義:輪、階段數 num_subsession = 1 num_cycle = 2 num_game_round = 15 #定義乘數 MULTIPLIER1 = 1.2 MULTIPLIER2 = 0.9 MULTIPLIER3 = 0.2 class Subsession(BaseSubsession): pass class Group(BaseGroup): num_vote_alpha = models.IntegerField() num_vote_beta = models.IntegerField() num_vote_gamma = models.IntegerField() vote_result = models.IntegerField(min=1, max=3, initial=1) vote_result_str = models.StringField(initial='a') individual_share = models.CurrencyField() class Player(BasePlayer): vote = models.IntegerField( choices=[[1, ' α '], [2, ' β '], [3, ' γ ']], widget=widgets.RadioSelectHorizontal, label="您想要投給哪一位候選人?", ) #定義is_winner判斷誰是贏家 is_winner = models.BooleanField() #定義random_table變數在class Player random_table = models.IntegerField() #定義每一個受試者的每一個type subject_type1 = models.IntegerField(min=1, max=3, initial=1) subject_type2 = models.IntegerField(min=1, max=3, initial=1) subject_type3 = models.IntegerField(min=1, max=3, initial=1) #累積報酬 accumulate_pay = models.IntegerField(initial=0) # PAGES class Start(Page): pass page_sequence = [ Start, ]