Selecting from different lists in a semi-random fashion


Author
Message
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
***JayD*** - Thursday, October 12, 2017
Hi,

I'm building a Stroop script in which blocks present 40 trials (20 food-related, 20 neutral) containing 4 colours (red, blue, orange, green) in a semi-random fashion. Specifically, no more than 2 words from the same category (food/neutral) and no more than 2 words of the same colour can appear consecutively. Each item (20 food, 20 neutral) is presented once and colours are evenly distributed. 

I wanted to ask about how to accomplish the semi-randomisation efficiently and ensure the colours are evenly distributed. Parts of my script are below:


********** Food *********

<item Food>
/ 1 = "Cake"
/ 2 = "Cheese"
/ 3 = "Potato chips"
/ 4 = "Pasta"
/ 5 = "Bonbon"
/ 6 = "Salad"
/ 7 = "Meatball"
/ 8 = "Cookie"
/ 9 = "Ice cream"
/ 10 = "Kebab"
/ 11 = "Bun"
/ 12 = "Yoghurt"
/ 13 = "Whipped cream"
/ 14 = "Chocolate"
/ 15 = "Hamburger"
/ 16 = "Meat"
/ 17 = "Peanut butter"
/ 18 = "Croissant"
/ 19 = "Vanilla custard"
/ 20 = "Treacle waffle"
</item>


<list Food_Items>
/ poolsize = 20
</list>


<text Food_Red>
/ items = Food
/ color = (red)
/ fontstyle = ("Arial", 80pt, true)
/ select = list.Food_Items.nextindex
</text>

<text Food_Blue>
/ items = Food
/ color = (blue)
/ fontstyle = ("Arial", 80pt, true)
/ select = list.Food_Items.nextindex
</text>

<text Food_Orange>
/ items = Food
/ color = (orange)
/ fontstyle = ("Arial", 80pt, true)
/ select = list.Food_Items.nextindex
</text>

<text Food_Green>
/ items = Food
/ color = (green)
/ fontstyle = ("Arial", 80pt, true)
/ select = list.Food_Items.nextindex
</text>



**** Neutral ****

<item Neutral>
/ 1 = "Tape"
/ 2 = "Paperclip"
/ 3 = "Cupboard"
/ 4 = "Felt-tip"
/ 5 = "Mobile phone"
/ 6 = "Ball pen"
/ 7 = "Scissors"
/ 8 = "Diary"
/ 9 = "File"
/ 10 = "Pushpin"
/ 11 = "Printer"
/ 12 = "Monitor"
/ 13 = "Cable"
/ 14 = "Notice board"
/ 15 = "Bookshelf"
/ 16 = "Envelope"
/ 17 = "Stamp"
/ 18 = "Wastepaper bin"
/ 19 = "Punch"
/ 20 = "Stapler"
</item>


<list Neutral_Items>
/ poolsize = 20
</list>


<text Neutral_Red>
/ items = Neutral
/ color = (red)
/ fontstyle = ("Arial", 80pt, true)
/ select = list.Neutral_Items.nextindex
</text>

<text Neutral_Blue>
/ items = Neutral
/ color = (blue)
/ fontstyle = ("Arial", 80pt, true)
/ select = list.Neutral_Items.nextindex
</text>

<text Neutral_Orange>
/ items = Neutral
/ color = (orange)
/ fontstyle = ("Arial", 80pt, true)
/ select = list.Neutral_Items.nextindex
</text>

<text Neutral_Green>
/ items = Neutral
/ color = (green)
/ fontstyle = ("Arial", 80pt, true)
/ select = list.Neutral_Items.nextindex
</text>

**************************** TRIALS *****************************

****** Food Trials *******

<trial Food_RED>
/ stimulustimes = [0 = Food_Red]
/ responsetime = 0
/ correctresponse = ("A")
/ validresponse = ("S", "K", "L")
/ trialduration = 2000
/ posttrialpause = 1000
/ responseinterrupt = immediate
</trial>

<trial Food_BLUE>
/ stimulustimes = [0 = Food_Blue]
/ responsetime = 0
/ correctresponse = ("S")
/ validresponse = ("A", "K", "L")
/ trialduration = 2000
/ posttrialpause = 1000
/ responseinterrupt = immediate
</trial>

<trial Food_ORANGE>
/ stimulustimes = [0 = Food_Orange]
/ responsetime = 0
/ correctresponse = ("K")
/ validresponse = ("A", "S", "L")
/ trialduration = 2000
/ posttrialpause = 1000
/ responseinterrupt = immediate
</trial>

<trial Food_GREEN>
/ stimulustimes = [0 = Food_Green]
/ responsetime = 0
/ correctresponse = ("L")
/ validresponse = ("A", "S", "K")
/ trialduration = 2000
/ posttrialpause = 1000
/ responseinterrupt = immediate
</trial>



****** Neutral Trials *******

<trial Neutral_RED>
/ stimulustimes = [0 = Neutral_Red]
/ responsetime = 0
/ correctresponse = ("A")
/ validresponse = ("S", "K", "L")
/ trialduration = 2000
/ posttrialpause = 1000
/ responseinterrupt = immediate
</trial>

<trial Neutral_BLUE>
/ stimulustimes = [0 = Neutral_Blue]
/ responsetime = 0
/ correctresponse = ("S")
/ validresponse = ("A", "K", "L")
/ trialduration = 2000
/ posttrialpause = 1000
/ responseinterrupt = immediate
</trial>

<trial Neutral_ORANGE>
/ stimulustimes = [0 = Neutral_Orange]
/ responsetime = 0
/ correctresponse = ("K")
/ validresponse = ("A", "S", "L")
/ trialduration = 2000
/ posttrialpause = 1000
/ responseinterrupt = immediate
</trial>

<trial Neutral_GREEN>
/ stimulustimes = [0 = Neutral_Green]
/ responsetime = 0
/ correctresponse = ("L")
/ validresponse = ("A", "S", "K")
/ trialduration = 2000
/ posttrialpause = 1000
/ responseinterrupt = immediate
</trial>


<block 1>
/ preinstructions = (Instructions)
/ trials = [1-40 = noreplacenorepeat(Food_RED, Food_BLUE, Food_ORANGE, Food_GREEN, Neutral_RED, Neutral_BLUE, Neutral_ORANGE, Neutral_GREEN)]
/ postinstructions = (Block1_End)
</block>


*************

Thanks!

Jay


You will need to use <list> elements for both category and color selection, and probably use /not constraints to block colors as well at runtime to keep them from repeating. See e.g. examples like this https://www.millisecond.com/forums/Topic20470.aspx or https://www.millisecond.com/forums/FindPost20201.aspx



Edited 7 Years Ago by Dave
***JayD***
***JayD***
Distinguished Member (4.1K reputation)Distinguished Member (4.1K reputation)Distinguished Member (4.1K reputation)Distinguished Member (4.1K reputation)Distinguished Member (4.1K reputation)Distinguished Member (4.1K reputation)Distinguished Member (4.1K reputation)Distinguished Member (4.1K reputation)Distinguished Member (4.1K reputation)
Group: Forum Members
Posts: 17, Visits: 67
Hi,

I'm building a Stroop script in which blocks present 40 trials (20 food-related, 20 neutral) containing 4 colours (red, blue, orange, green) in a semi-random fashion. Specifically, no more than 2 words from the same category (food/neutral) and no more than 2 words of the same colour can appear consecutively. Each item (20 food, 20 neutral) is presented once and colours are evenly distributed. 

I wanted to ask about how to accomplish the semi-randomisation efficiently and ensure the colours are evenly distributed. Parts of my script are below:


********** Food *********

<item Food>
/ 1 = "Cake"
/ 2 = "Cheese"
/ 3 = "Potato chips"
/ 4 = "Pasta"
/ 5 = "Bonbon"
/ 6 = "Salad"
/ 7 = "Meatball"
/ 8 = "Cookie"
/ 9 = "Ice cream"
/ 10 = "Kebab"
/ 11 = "Bun"
/ 12 = "Yoghurt"
/ 13 = "Whipped cream"
/ 14 = "Chocolate"
/ 15 = "Hamburger"
/ 16 = "Meat"
/ 17 = "Peanut butter"
/ 18 = "Croissant"
/ 19 = "Vanilla custard"
/ 20 = "Treacle waffle"
</item>


<list Food_Items>
/ poolsize = 20
</list>


<text Food_Red>
/ items = Food
/ color = (red)
/ fontstyle = ("Arial", 80pt, true)
/ select = list.Food_Items.nextindex
</text>

<text Food_Blue>
/ items = Food
/ color = (blue)
/ fontstyle = ("Arial", 80pt, true)
/ select = list.Food_Items.nextindex
</text>

<text Food_Orange>
/ items = Food
/ color = (orange)
/ fontstyle = ("Arial", 80pt, true)
/ select = list.Food_Items.nextindex
</text>

<text Food_Green>
/ items = Food
/ color = (green)
/ fontstyle = ("Arial", 80pt, true)
/ select = list.Food_Items.nextindex
</text>



**** Neutral ****

<item Neutral>
/ 1 = "Tape"
/ 2 = "Paperclip"
/ 3 = "Cupboard"
/ 4 = "Felt-tip"
/ 5 = "Mobile phone"
/ 6 = "Ball pen"
/ 7 = "Scissors"
/ 8 = "Diary"
/ 9 = "File"
/ 10 = "Pushpin"
/ 11 = "Printer"
/ 12 = "Monitor"
/ 13 = "Cable"
/ 14 = "Notice board"
/ 15 = "Bookshelf"
/ 16 = "Envelope"
/ 17 = "Stamp"
/ 18 = "Wastepaper bin"
/ 19 = "Punch"
/ 20 = "Stapler"
</item>


<list Neutral_Items>
/ poolsize = 20
</list>


<text Neutral_Red>
/ items = Neutral
/ color = (red)
/ fontstyle = ("Arial", 80pt, true)
/ select = list.Neutral_Items.nextindex
</text>

<text Neutral_Blue>
/ items = Neutral
/ color = (blue)
/ fontstyle = ("Arial", 80pt, true)
/ select = list.Neutral_Items.nextindex
</text>

<text Neutral_Orange>
/ items = Neutral
/ color = (orange)
/ fontstyle = ("Arial", 80pt, true)
/ select = list.Neutral_Items.nextindex
</text>

<text Neutral_Green>
/ items = Neutral
/ color = (green)
/ fontstyle = ("Arial", 80pt, true)
/ select = list.Neutral_Items.nextindex
</text>

**************************** TRIALS *****************************

****** Food Trials *******

<trial Food_RED>
/ stimulustimes = [0 = Food_Red]
/ responsetime = 0
/ correctresponse = ("A")
/ validresponse = ("S", "K", "L")
/ trialduration = 2000
/ posttrialpause = 1000
/ responseinterrupt = immediate
</trial>

<trial Food_BLUE>
/ stimulustimes = [0 = Food_Blue]
/ responsetime = 0
/ correctresponse = ("S")
/ validresponse = ("A", "K", "L")
/ trialduration = 2000
/ posttrialpause = 1000
/ responseinterrupt = immediate
</trial>

<trial Food_ORANGE>
/ stimulustimes = [0 = Food_Orange]
/ responsetime = 0
/ correctresponse = ("K")
/ validresponse = ("A", "S", "L")
/ trialduration = 2000
/ posttrialpause = 1000
/ responseinterrupt = immediate
</trial>

<trial Food_GREEN>
/ stimulustimes = [0 = Food_Green]
/ responsetime = 0
/ correctresponse = ("L")
/ validresponse = ("A", "S", "K")
/ trialduration = 2000
/ posttrialpause = 1000
/ responseinterrupt = immediate
</trial>



****** Neutral Trials *******

<trial Neutral_RED>
/ stimulustimes = [0 = Neutral_Red]
/ responsetime = 0
/ correctresponse = ("A")
/ validresponse = ("S", "K", "L")
/ trialduration = 2000
/ posttrialpause = 1000
/ responseinterrupt = immediate
</trial>

<trial Neutral_BLUE>
/ stimulustimes = [0 = Neutral_Blue]
/ responsetime = 0
/ correctresponse = ("S")
/ validresponse = ("A", "K", "L")
/ trialduration = 2000
/ posttrialpause = 1000
/ responseinterrupt = immediate
</trial>

<trial Neutral_ORANGE>
/ stimulustimes = [0 = Neutral_Orange]
/ responsetime = 0
/ correctresponse = ("K")
/ validresponse = ("A", "S", "L")
/ trialduration = 2000
/ posttrialpause = 1000
/ responseinterrupt = immediate
</trial>

<trial Neutral_GREEN>
/ stimulustimes = [0 = Neutral_Green]
/ responsetime = 0
/ correctresponse = ("L")
/ validresponse = ("A", "S", "K")
/ trialduration = 2000
/ posttrialpause = 1000
/ responseinterrupt = immediate
</trial>


<block 1>
/ preinstructions = (Instructions)
/ trials = [1-40 = noreplacenorepeat(Food_RED, Food_BLUE, Food_ORANGE, Food_GREEN, Neutral_RED, Neutral_BLUE, Neutral_ORANGE, Neutral_GREEN)]
/ postinstructions = (Block1_End)
</block>


*************

Thanks!

Jay


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search