Group: Administrators
Posts: 13K,
Visits: 104K
|
You need to store every trial's payout amount somewhere (in a <list> or <item> element) at runtime and then retrieve one of the entries at random at the end of the experiment. Simple example:
<values> / fixedwin = 100 / randomwin = 0 / winamount = 0 / score = 0 </values>
<list randomwins> / items = (10, 25, 50, 75, 150, 300, 450, 600) </list>
<trial choicetrial> / ontrialbegin = [values.randomwin=list.randomwins.nextvalue] / ontrialend = [if (trial.choicetrial.response=="fixed_amount") values.winamount = values.fixedwin else values.winamount = values.randomwin; ] / ontrialend = [item.storedwinnings.appenditem(values.winamount); values.score+=values.winamount; ] / stimulusframes = [1=question,fixed_amount, random_amount, score] / inputdevice = mouse / validresponse = (fixed_amount, random_amount) / branch = [trial.resulttrial] </trial>
<trial resulttrial> / stimulusframes = [1=winamount, score] / validresponse = (0) / trialduration = 1000 </trial>
<trial payouttrial> / stimulusframes = [1=payoutmsg, payout, trialmsg] / validresponse = (57) </trial>
<block choiceblock> / trials = [1-8=choicetrial] </block>
<block payoutblock> / trials = [1=payouttrial] </block>
<expt> / blocks = [1=choiceblock; 2=payoutblock] </expt>
<item storedwinnings> </item>
<text fixed_amount> / items = ("FIXED WIN") / position = (25%, 75%) </text>
<text random_amount> / items = ("RANDOM WIN") / position = (75%, 75%) </text>
<text question> / items = ("Would you like to win a FIXED or RANDOM amount?") </text>
<text score> / items = ("Total: <%values.score%>") / position = (50%, 25%) </text>
<text winamount> / items = ("You won <%values.winamount%>.") </text>
<text payoutmsg> / items = ("Your payout is") / position = (50%, 40%) </text>
<text payout> / items = storedwinnings </text>
<text trialmsg> / items = ("which is the amount you won in trial #<%text.payout.currentitemnumber%>.") / position = (50%, 60%) </text>
|