Millisecond Forums

Randomising item location dependent on other item location

https://forums.millisecond.com/Topic22289.aspx

By Beth - 8/16/2017

I am trying to randomise the location of 4 items on the screen (randomising both vposition and hposition), but have one item's location always dependent on the location of the other (e.g. I always want feature5 to appear in the same "column" as SharedA, but feature8 to always appear in the same "column" as RareA", but have all 4 positions change randomly, except for the latter contingency, so that the vposition and hposition of each pair swap between each "column" and hposition).

I can't quite get the code to work so any help would be much appreciated. Right now the pictures seem to be appearing on top of each other and I think it's because I'm re-using the values twice, but can't seem to get it to work any other way.


<block exampleblock>
/ trials = [1-10 = Atrials]
</block>

<values>
/ a_pos_h = 0%
/ wrong_pos_h = 0%
/ a_pos_v = 0%
/ wrong_pos_v = 0%
</values>

<counter colorcounter_h>
/ items = (1,2)
/ select = noreplace
/ selectionrate = always
</counter>

<counter positioncounter_h>
/ items = (40%,60%)
/ select = noreplace
/ selectionrate = always
</counter>

<counter colorcounter_v>
/ items = (1,2)
/ select = noreplace
/ selectionrate = always
</counter>

<counter positioncounter_v>
/ items = (30%,70%)
/ select = noreplace
/ selectionrate = always
</counter>


<trial Atrials>

/ ontrialbegin = [values.a_pos_h = counter.positioncounter_h.selectedvalue;
  values.wrong_pos_h = counter.positioncounter_h.selectedvalue; values.a_pos_v = counter.positioncounter_v.selectedvalue;
  values.wrong_pos_v = counter.positioncounter_v.selectedvalue;]
/ stimulusframes = [1=ListA,listA_partner,wronglistA,wronglistA_partner,keybindings1,keybindings2]
/ validresponse = (30, 38)
/ iscorrectresponse = [(values.a_pos_h==40% && trial.Atrials.response==30)
  || (values.a_pos_h==60% && trial.Atrials.response==38)]
</trial>



<picture ListA>
/ items = ListA
/ select = colorcounter_h
/ select = colorcounter_v
/ hposition = values.a_pos_h
/ vposition = values.a_pos_v
</picture>


<picture ListA_partner>
/ items = ListA_partner
/ select = current(ListA)
/ select = colorcounter_h
/ select = colorcounter_v
/ hposition = values.a_pos_h
/ vposition = values.a_pos_v
</picture>

<picture wronglistA>
/ items = wronglistA
/ select = colorcounter_h
/ select = colorcounter_v
/ hposition = values.wrong_pos_h
/ vposition = values.a_pos_v
</picture>

<picture wronglistA_partner>
/ items = wronglistA_partner
/ select = current(wrongListA_partner)
/ select = colorcounter_h
/ select = colorcounter_v
/ hposition = values.wrong_pos_h
/ vposition = values.a_pos_v
</picture>

<item ListA>
/ 1 = "SharedA.jpg"
/ 2 = "SharedA.jpg"
/ 3 = "SharedA.jpg"
/ 4 = "SharedA.jpg"

</item>

<item ListA_partner>
/ 1 = "feature5.png"
/ 2 = "feature5.png"
/ 3 = "feature5.png"
/ 4 = "feature5.png"

</item>


<item wronglistA>
/ 1 = "RareA.jpg"
/ 2 = "RareA.jpg"
/ 3 = "RareA.jpg"
/ 4 = "RareA.jpg"

</item>


<item wronglistA_partner>
/ 1 = "feature8.png"
/ 2 = "feature8.png"
/ 3 = "feature8.png"
/ 4 = "feature8.png"

</item>


By Dave - 8/16/2017

Beth - Wednesday, August 16, 2017
I am trying to randomise the location of 4 items on the screen (randomising both vposition and hposition), but have one item's location always dependent on the location of the other (e.g. I always want feature5 to appear in the same "column" as SharedA, but feature8 to always appear in the same "column" as RareA", but have all 4 positions change randomly, except for the latter contingency, so that the vposition and hposition of each pair swap between each "column" and hposition).

I can't quite get the code to work so any help would be much appreciated. Right now the pictures seem to be appearing on top of each other and I think it's because I'm re-using the values twice, but can't seem to get it to work any other way.


<block exampleblock>
/ trials = [1-10 = Atrials]
</block>

<values>
/ a_pos_h = 0%
/ wrong_pos_h = 0%
/ a_pos_v = 0%
/ wrong_pos_v = 0%
</values>

<counter colorcounter_h>
/ items = (1,2)
/ select = noreplace
/ selectionrate = always
</counter>

<counter positioncounter_h>
/ items = (40%,60%)
/ select = noreplace
/ selectionrate = always
</counter>

<counter colorcounter_v>
/ items = (1,2)
/ select = noreplace
/ selectionrate = always
</counter>

<counter positioncounter_v>
/ items = (30%,70%)
/ select = noreplace
/ selectionrate = always
</counter>


<trial Atrials>

/ ontrialbegin = [values.a_pos_h = counter.positioncounter_h.selectedvalue;
  values.wrong_pos_h = counter.positioncounter_h.selectedvalue; values.a_pos_v = counter.positioncounter_v.selectedvalue;
  values.wrong_pos_v = counter.positioncounter_v.selectedvalue;]
/ stimulusframes = [1=ListA,listA_partner,wronglistA,wronglistA_partner,keybindings1,keybindings2]
/ validresponse = (30, 38)
/ iscorrectresponse = [(values.a_pos_h==40% && trial.Atrials.response==30)
  || (values.a_pos_h==60% && trial.Atrials.response==38)]
</trial>



<picture ListA>
/ items = ListA
/ select = colorcounter_h
/ select = colorcounter_v
/ hposition = values.a_pos_h
/ vposition = values.a_pos_v
</picture>


<picture ListA_partner>
/ items = ListA_partner
/ select = current(ListA)
/ select = colorcounter_h
/ select = colorcounter_v
/ hposition = values.a_pos_h
/ vposition = values.a_pos_v
</picture>

<picture wronglistA>
/ items = wronglistA
/ select = colorcounter_h
/ select = colorcounter_v
/ hposition = values.wrong_pos_h
/ vposition = values.a_pos_v
</picture>

<picture wronglistA_partner>
/ items = wronglistA_partner
/ select = current(wrongListA_partner)
/ select = colorcounter_h
/ select = colorcounter_v
/ hposition = values.wrong_pos_h
/ vposition = values.a_pos_v
</picture>

<item ListA>
/ 1 = "SharedA.jpg"
/ 2 = "SharedA.jpg"
/ 3 = "SharedA.jpg"
/ 4 = "SharedA.jpg"

</item>

<item ListA_partner>
/ 1 = "feature5.png"
/ 2 = "feature5.png"
/ 3 = "feature5.png"
/ 4 = "feature5.png"

</item>


<item wronglistA>
/ 1 = "RareA.jpg"
/ 2 = "RareA.jpg"
/ 3 = "RareA.jpg"
/ 4 = "RareA.jpg"

</item>


<item wronglistA_partner>
/ 1 = "feature8.png"
/ 2 = "feature8.png"
/ 3 = "feature8.png"
/ 4 = "feature8.png"

</item>



If I'm understanding your description correctly, then the following process should work:

<values>
/ shared_column = 0
/ rare_column = 0

/ shared_a_row = 0
/ feature_5_row =0

/ rare_a_row = 0
/ feature_8_row =0
</values>

// columns are defined by horizontal position
<list columns>
/ items = (40%, 60%)
/ selectionrate = always
</list>

// rows are defined by vertical position
<list rows>
/ items = (30%, 70%)
/ selectionrate = always
</list>

//#1 pick random columns for "shared" and "rare"
//#2 pick random rows for "shared a" and "feature 5"
//#3 pick random rows for "rare a" and "feature 8"
<trial example>
/ ontrialbegin = [values.shared_column = list.columns.nextvalue;
    values.rare_column = list.columns.nextvalue;]
/ ontrialbegin = [values.shared_a_row = list.rows.nextvalue;
    values.feature_5_row = list.rows.nextvalue; ]
/ ontrialbegin = [values.rare_a_row = list.rows.nextvalue;
    values.feature_8_row = list.rows.nextvalue; ]
/ stimulusframes = [1=shared_a, feature_5, rare_a, feature_8]
/ validresponse = (57)
</trial>


<text shared_a>
/ items = ("Shared A")
/ hposition = values.shared_column
/ vposition = values.shared_a_row
</text>

<text feature_5>
/ items = ("Feature 5")
/ hposition = values.shared_column
/ vposition = values.feature_5_row
</text>

<text rare_a>
/ items = ("Rare A")
/ hposition = values.rare_column
/ vposition = values.rare_a_row
</text>

<text feature_8>
/ items = ("Feature 8")
/ hposition = values.rare_column
/ vposition = values.feature_8_row
</text>

<block myblock>
/ trials = [1-10 = example]
</block>