Using a counter to draw from a list


Author
Message
nashby
nashby
Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)
Group: Forum Members
Posts: 78, Visits: 159
As always thanks Dave got it working now.
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 104K
You can also frame the problem differently and assign positions to objects: https://www.millisecond.com/forums/Topic5501.aspx

Instead of using a <counter> directly in /hposition and /vposition, I would recommend (1) the use of <list> instead of <counter> and (2) using <values> to store a given element's' position.

Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 104K
For example:

<values>
/ location1item = 1
/ location2item = 1
/ location3item = 1
/ location4item = 1
</values>

<block myblock>
/ trials = [1-4=mytrial]
</block>

<trial mytrial>
/ ontrialbegin = [values.location1item=list.itemlist.nextindex; values.location2item=list.itemlist.nextindex;
    values.location3item=list.itemlist.nextindex; values.location4item=list.itemlist.nextindex; ]
/ ontrialend = [list.itemlist.reset(); ]
/ stimulusframes = [1=pic1, desc1, pic2, desc2, pic3, desc3, pic4, desc4]
/ validresponse = (57)
</trial>

<text pic1>
/ items = picitems
/ select = values.location1item
/ position = (20%, 50%)
</text>

<text pic2>
/ items = picitems
/ select = values.location2item
/ position = (40%, 50%)
</text>

<text pic3>
/ items = picitems
/ select = values.location3item
/ position = (60%, 50%)
</text>

<text pic4>
/ items = picitems
/ select = values.location4item
/ position = (80%, 50%)
</text>

<text desc1>
/ items = descitems
/ select = values.location1item
/ position = (20%, 55%)
</text>

<text desc2>
/ items = descitems
/ select = values.location2item
/ position = (40%, 55%)
</text>

<text desc3>
/ items = descitems
/ select = values.location3item
/ position = (60%, 55%)
</text>

<text desc4>
/ items = descitems
/ select = values.location4item
/ position = (80%, 55%)
</text>

<item picitems>
/ 1 = "cat.jpg"
/ 2 = "dog.jpg"
/ 3 = "cow.jpg"
/ 4 = "bird.jpg"
/ 5 = "fish.jpg"
</item>

<item descitems>
/ 1 = "A cute cat"
/ 2 = "A happy dog"
/ 3 = "A big cow"
/ 4 = "A colorful bird"
/ 5 = "An exotic fish"
</item>

<list itemlist>
/ poolsize = 5
/ selectionrate = always
</list>


nashby
nashby
Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)
Group: Forum Members
Posts: 78, Visits: 159
So I am stuck again but with a different problem.

I have 16 locations that need to have 16 different pictures randomly assigned to them but I also have the 16 text descriptions of those pictures that need to be assigned to the correct picture. So whatever place Picture 1 ends up Text 1 needs to end up there as well, but again the where needs to be random.

I have tried everything I can think of (spent the last 4 days working on this one issue) but nothing is matching the text up with the proper picture and I keep getting repeats of text and pictures.

Can anyone show me a simple way to do this?
nashby
nashby
Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)
Group: Forum Members
Posts: 78, Visits: 159
Ok I get it now. I just hate inquist syntax its very counter intuitive :)
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 104K
And to avoid any confusion, there is *no* need for operating with index values. It works the same with any type of item:

<values>
/ a1 = 0
/ a2 = 0
/ b1 = 0
/ b2 = 0
</values>

<block myblock>
/ trials = [1=mytrial]
</block>

<list mylist>
/ items = (0%, 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%, 100%)
/ selectionmode = random
/ selectionrate = always
</list>

<trial mytrial>
/ ontrialbegin = [values.a1=list.mylist.nextvalue; values.a2=list.mylist.currentvalue;
    values.b1=list.mylist.nextvalue; values.b2=list.mylist.currentvalue; ]
/ stimulusframes = [1=mytext]
/ validresponse = (57)
</trial>

<text mytext>
/ items = ("<%values.a1%>, <%values.a2%>, <%values.b1%>, <%values.b2%>")
</text>

Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 104K
> But that doesnt assign that doesnt assign them randomly.I need position 1 to be a random item, not item 1 in the list.

Of course it does assign items randomly:

<values>
/ a1 = 0
/ a2 = 0
/ b1 = 0
/ b2 = 0
</values>

<block myblock>
/ trials = [1=mytrial]
</block>

<list mylist>
/ poolsize = 16
/ selectionmode = random
/ selectionrate = always
</list>

<trial mytrial>
/ ontrialbegin = [values.a1=list.mylist.nextindex; values.a2=list.mylist.currentindex;
    values.b1=list.mylist.nextindex; values.b2=list.mylist.currentindex; ]
/ stimulusframes = [1=mytext]
/ validresponse = (57)
</trial>

<text mytext>
/ items = ("<%values.a1%>, <%values.a2%>, <%values.b1%>, <%values.b2%>")
</text>

How is this not random?

nashby
nashby
Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)Guru (8.8K reputation)
Group: Forum Members
Posts: 78, Visits: 159
But that doesnt assign that doesnt assign them randomly.I need position 1 to be a random item, not item 1 in the list.

Here is the bits of my experiment that should be relevant to understand what I am trying to do.


<list a2option>
/ items = (1 2)
/ selectionmode = random
/ selectionrate = always
</list>

<list a2optiono1>
/ items = (70 100)
</list>

<list a2optiono2>
/ items = (60 30)
</list>

<list a2optionp>
/ items = (50 20)
</list>


<trial mytrial2>
/ stimulusframes = [1= InPlay, LabelA, LabelB, O1, O2]
/ validresponse = (LabelA, LabelB)
/ inputdevice = mouse
/ ontrialend = [values.samples += 1]
/ ontrialbegin = [values.condition = 4]
/ ontrialbegin = [values.ran = round(rand(1,100))]
/ ontrialend = [ if (trial.mytrial2.response == "LabelA" && values.ran <= values.o1p) {values.outcome=(values.o1a); values.spicked = 0; }]
/ ontrialend = [ if (trial.mytrial2.response == "LabelA" && values.ran > values.o1p) {values.outcome=(values.o1b); values.spicked = 0; }]
/ ontrialend = [ if (trial.mytrial2.response == "LabelB" && values.ran <= values.o2p) {values.outcome=(values.o2a); values.spicked = 1; }]
/ ontrialend = [ if (trial.mytrial2.response == "LabelB" && values.ran > values.o2p){values.outcome=(values.o2b); values.spicked = 1; }]
/ ontrialend = [ if (trial.mytrial2.response == "LabelA") {text.o1.item.1=(values.outcome);text.o2.item.1=(" "); text.o3.item.1=(" "); text.o4.item.1=(" ");text.o5.item.1=(" ");text.o6.item.1=(" "); text.o7.item.1=(" "); text.o8.item.1=(" ");text.o9.item.1=(" "); text.o10.item.1=(" "); text.o11.item.1=(" ");text.o12.item.1=(" ");text.o13.item.1=(" "); text.o14.item.1=(" "); text.o15.item.1=(" "); text.o16.item.1=(" ");}]
/ ontrialend = [ if (trial.mytrial2.response == "LabelB") {text.o2.item.1=(values.outcome);text.o1.item.1=(" "); text.o3.item.1=(" "); text.o4.item.1=(" ");text.o5.item.1=(" ");text.o6.item.1=(" "); text.o7.item.1=(" "); text.o8.item.1=(" ");text.o9.item.1=(" "); text.o10.item.1=(" "); text.o11.item.1=(" ");text.o12.item.1=(" ");text.o13.item.1=(" "); text.o14.item.1=(" "); text.o15.item.1=(" "); text.o16.item.1=(" ");}]
/ ontrialend = [values.tot += values.outcome]
</trial>

<block picking2>
/ trials = [1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69,71,73,75,77,79,81,83,85,87,89,91,93,95,97,99,101,
103,105,107,109,111,113,115,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147,149,151,153,155,157,159,161,163,165,167,169,171,173,175,177,179,181,
183,185,187,189,191,193,195,197,199,201= mytrial2;
2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,
116,118,120,122,124,126,128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,160,162,164,166,168,170,172,174,176,178,180,182,184,186,188,190,192,194,196,
198,200,202= blank2;]
/ onblockbegin = [values.o1a = list.a2optiono1.item(list.a2option.item(1));values.o1b = list.a2optiono2.item(list.a2option.item(1));values.o2a = list.a2optiono1.item(list.a2option.item(2));values.o2b = list.a2optiono2.item(list.a2option.item(2)); values.o1p = list.a2optionp.item(list.a2option.item(1)); values.o2p = list.a2optionp.item(list.a2option.item(2)); ]
</block>






Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 104K
> / onblockbegin = [values.o1a = list.a2optiono1.(x1);values.o1b = list.a2optiono2.(x1);values.o2a = list.a2optiono1.(x2);values.o2b > = list.a2optiono2.(x2); values.o1p = list.a2optionp.(x1); values.o2p = list.a2optionp.(x2); ]
>
> So like above where I need each x1 or x2 or x16 to be a different number drawn from 1-16 without replacement.                               

See the 1st example I posted in my previous reply: https://www.millisecond.com/forums/FindPost15614.aspx

All you need is a single <list> with /selectionrate set to 'always'. nextindex forces a new selection, currentindex does not (same for nextvalue and currentvalue).

Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 104K
That's broken syntax. If you use proper syntax, that works just fine:

<list a>
/ items = ("C", "A", "B")
</list>

<list b>
/ items = (1,2,3)
</list>

<trial mytrial>
/ ontrialbegin = [values.myvalue = list.a.item(list.b.item(1))]
/ stimulusframes = [1=mytext]
/ validresponse = (57)
</trial>

<text mytext>
/ items = ("<%values.myvalue%>")
</text>

<values>
/ myvalue = ""
</values>

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search