+x+x+xHi,
I made a recent post on inquisit 4 about how to program in this language very recently... I figured out many stuff, but now I'm lost again.
I tried something out but I'm not sure if the script is doing what I think it is, so I'll describe what I thin I'm doing.
The idea is:
first to retrieve a random response the participant makes (either ss or ll) see <trial 1>... I think I'm doing this in <list lotteryr>
then I generate 99 random numbers which I think I'm doing in <list lotterydist>...
then I think I append the number from <list lotteryr> into <list lotterydist> and create a list <list lotterytotal>
the next step would be to retrieve a random number from <list lotterytotal>
and if possible show the numbers on the screen as if it was a lottery... like a for loop for each item and then show the "winning number" if the number retrieved form <list lotterytotal> equals the one in the <list lotteryr>
<trial 1>
/ inputdevice=mouse
/ validresponse=(ss, ll)
/ stimulusframes = [1 = ss, ll, delayss, delayll, remind]
</trial>
<values>
/ pay = 0
</values>
<list lotteryr>
/ items=[values.pay = trial.1.response]
/ poolsize=1
/ selectionmode=random
</list>
<values>
/ myvalue = 0
</values>
<list lotterydist>
/ items=[values.myvalue = floor(rand(1,99))]
/ poolsize=99
/ selectionmode=random
</list>
<list lotterytotal>
/ items=[list.lotterydist.appenditem(values.pay);]
/ selectionmode=random
</list>
As I said, I'm new to this language, so I have no idea if what I want to do is even possible (a lottery where the participant has 1% chance to win one of the options he/she chose).
I would appreciate some help on this... I also read this thread
https://www.millisecond.com/forums/Topic17448.aspx (recommended by Dave on the post I mentioned earlier), but I don't understand most of it and I think what I want to do is different.
Another thing, I'm not sure if lists are the best way to do this in inquisit, any suggestion or help is welcome.
Thanks you for your time,
Andre
The syntax isn't at all correct will not do anything resembling your description.
#1: You are not retrieving anything from the lists anywhere.
#2: You are not adding anything to the lists on a trial-by-trial basis. Where do you think you are storing "a random response the participant makes"?
#3: The description of the lottery does not make any sense to me. Take a step back, forget the code, and simply provide a detailed description of how exactly you want this to work.
Hi Dave,
Thank you for your response, I'll try to be as clear as I can...
Mainly i want to create a lottery with a 1% chance of getting the number that was retrieved from one of the responses.... in other words I want to tell my participants that they have a 1/100 chance to win the amount of money of one of the choices they made in a delay discounting task.
I want to "store" in a list the responses (amount of money is the stimuli in my case), then I want to create another list that has 99 random numbers in it, then I want to append one of the responses (randomly chosen) that was stored in the first list, and then shuffle them so the order inside the list is random... finally I want to randomly choose one of the 100 numbers and compare it to the one that was appended, if it was the same the participant wins that amount of money if it was not, the participant doesn't win.
If possible I would like to show the participant the number that is going to be appended (randomly selected response), and then I would like to show all the numbers on the screen one appearing after the other, just to show the participants that there is "something" actually happening and that the amount of money of one of their choices is inside the list so they actually have a chance to win, finally I want to show them the result (the number that was randomly chosen from the 100 item list).
I hope I'm clear with what i would like to create.
Again thank you for your time.
#1: > I want to "store" in a list the responses (amount of money is the stimuli in my case)
This aspect is covered in
https://www.millisecond.com/forums/Topic17448.aspx . The example uses an <item> element to "store" the amount of money associated with each response. You will want to use a <list> instead. That works the same way.
<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>
#2: > I want to create another list that has 99 random numbers
Simply set up such a <list> then, with /items 1 to 99. Then run a <trial> that samples an item at random from the 1st, "storedwinnings" <list> and appends it to the "1 to 99" list you set up. That again works the same way as above. Note: You don't randomly "shuffle" lists in Inquisit syntax. How a list behaves, sampling-wise, is determined by its /selectionmode and /replace attributes, with random sampling without replacement being the default behavior. I.e.,
> and then shuffle them so the order inside the list is random
is actually unnecessary.
#3: > finally I want to randomly choose one of the 100 numbers and compare it to the one that was appended
A comparison is not necessary. You *know* the amount that was appended is the <list>'s 100th item. If the 100th item is randomly selected, you know that's a win. If any other item than the 100th one is sampled that's a loss.
#4: > If possible I would like to show the participant the number that is going to be appended (randomly selected response).
You do that in the <trial> that performs the actions sketched out under #2 above.
#5: > then I would like to show all the numbers on the screen one appearing after the other, just to show the participants that there is "something" actually happening and that
> the amount of money of one of their choices is inside the list so they actually have a chance to win, finally I want to show them the result (the number that was randomly
> chosen from the 100 item list).
I don't fully understand that part. You want to display the numbers 1 to 99 plus the amount that was appended (100th item) to the participant in sequential order? And after that you want to to display some randomly selected item out of the 100 again? Perhaps I'm too fixated by the word "lottery" -- I don't think I have ever seen a lottery that would proceed in that way.
At any rate. Based on the example referenced previously, all of the above can be done like this:
<values>
/ fixedwin = 100
/ randomwin = 0
/ winamount = 0
/ enteredintolottery = 0
/ drawnnumber = 0
/ index = 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 = [list.storedwinnings.appenditem(values.winamount);]
/ stimulusframes = [1=question,fixed_amount, random_amount]
/ inputdevice = mouse
/ validresponse = (fixed_amount, random_amount)
/ branch = [trial.resulttrial]
</trial>
<trial resulttrial>
/ stimulusframes = [1=winamount]
/ validresponse = (0)
/ trialduration = 1000
</trial>
<trial enterlotterytrial>
/ ontrialbegin = [values.enteredintolottery = list.storedwinnings.nextvalue;]
/ ontrialbegin = [list.1to99.appenditem(values.enteredintolottery);]
/ stimulusframes = [1=payoutmsg, trialmsg]
/ validresponse = (57)
</trial>
<trial showlistcontents>
/ ontrialbegin = [values.index += 1]
/ ontrialbegin = [text.listentry.item.1 = list.1to99.item(values.index)]
/ stimulusframes = [1=listentry]
/ trialduration = 200
</trial>
<text listentry>
/ items = (" ")
</text>
<trial drawnumber>
/ ontrialbegin = [list.1to99.reset(); values.drawnnumber = list.1to99.nextvalue;]
/ ontrialbegin = [if (list.1to99.currentindex == 100) text.wonorlost.item.1 = "You won :)" else text.wonorlost.item.1 = "You lost :("]
/ stimulusframes = [1=drawresult, wonorlost]
/ validresponse = (57)
</trial>
<text drawresult>
/ items = ("Number drawn: <%values.drawnnumber%>")
</text>
<text wonorlost>
/ items = (" ")
/ position = (50%, 60%)
</text>
<block choiceblock>
/ trials = [1-8=choicetrial]
</block>
<block payoutblock>
/ trials = [1=enterlotterytrial; 2-101=showlistcontents; 102=drawnumber]
</block>
<expt>
/ blocks = [1=choiceblock; 2=payoutblock]
</expt>
<list storedwinnings>
</list>
<list 1to99>
/ items = (1,2,3,4,5,6,7,8,9,10,
11,12,13,14,15,16,17,18,19,20,
21,22,23,24,25,26,27,28,29,30,
31,32,33,34,35,36,37,38,39,40,
41,42,43,44,45,46,47,48,49,50,
51,52,53,54,55,56,57,58,59,60,
61,62,63,64,65,66,67,68,69,70,
71,72,73,74,75,76,77,78,79,80,
81,82,83,84,85,86,87,88,89,90,
91,92,93,94,95,96,97,98,99)
</list>
<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 winamount>
/ items = ("You won <%values.winamount%>.")
</text>
<text payoutmsg>
/ items = ("The amount <%values.enteredintolottery%>")
/ position = (50%, 40%)
</text>
<text trialmsg>
/ items = ("you won in trial #<%list.storedwinnings.currentindex%> was entered into the lottery.")
/ position = (50%, 60%)
</text>