Avoid Overlapping Shapes

jsteave

Blocked
Jun 26, 2021
46
0
Albania
Hello,

I am trying to make a program where a random number of randomly sized circles appear on the screen in random positions. However, I do not want the circles to overlap. I know how to avoid having the circles have the same hposition and vposition, but I cannot figure out how to avoid overlap since the sizes are randomized (so even though no two circles can be at (20%, 20%), they could overlap since the second circle could be at (21%, 21%)). Is it possible to do this, and if so, how? Here is the code (I haven't written the code for all circles yet but they will be exactly the same as dots 1 and 2):

<defaults>
/ inputdevice = keyboard
/ fontstyle = ("Verdana", -13, false, false, false, false, 5, 0)
/ screencolor = grey
</defaults>

********STIMULI***********

<item text>
/1 = "+"
</item>

<text fixation>
/items = text
/select = 1
/hposition = 50%
/vposition = 50%
/fontstyle = ("Arial", 40, false, false, false, false, 5, 0)
/ txbgcolor = transparent
</text>

<shape dot1>
/shape = circle
/height = list.dot_size.nextvalue
/color = counter.dot_color1.selectedvalue
/hposition = list.h_position.nextvalue
/vposition = list.v_position.nextvalue
</shape>

<shape dot2>
/shape = circle
/height = list.dot_size.nextvalue
/color = counter.dot_color2.selectedvalue
/hposition = list.h_position.nextvalue
/vposition = list.v_position.nextvalue
</shape>

<list h_position>
/items = (10-90)
/ selectionrate = always
/selectionmode = random
</list>

<list v_position>
/items = (10-90)
/selectionrate = always
/selectionmode = random
</list>

<list dot_size>
/items = (20-40)
/selectionrate = always
/selectionmode = random
</list>

<counter dot_color1>
/items = (blue, yellow)
/select = noreplace
/ selectionrate = trial
</counter>

<counter dot_color2>
/items = (blue, yellow)
/select = noreplace
/not = (counter.dot_color1)
/selectionrate = trial
</counter>

********EXPERIMENT***********

<expt intro>
/blocks = [
1=intro
]
</expt>

<block intro>
/trials = [
1=intro
]
</block>

<trial intro>
/ stimulusframes = [1=dot1, dot2, fixation]
/validresponse = (203, 205)
</trial>
 

jsteave

Blocked
Jun 26, 2021
46
0
Albania
Hello,

I am trying to make a program where a random number of randomly sized circles appear on the screen in random positions. However, I do not want the circles to overlap. I know how to avoid having the circles have the same hposition and vposition, but I cannot figure out how to avoid overlap since the sizes are randomized (so even though no two circles can be at (20%, 20%), they could overlap since the second circle could be at (21%, 21%)). Is it possible to do this, and if so, how? Here is the code (I haven't written the code for all circles yet but they will be exactly the same as dots 1 and 2):

<defaults>
/ inputdevice = keyboard
/ fontstyle = ("Verdana", -13, false, false, false, false, 5, 0)
/ screencolor = grey
</defaults>

********STIMULI***********

<item text>
/1 = "+"
</item>

<text fixation>
/items = text
/select = 1
/hposition = 50%
/vposition = 50%
/fontstyle = ("Arial", 40, false, false, false, false, 5, 0)
/ txbgcolor = transparent
</text>

<shape dot1>
/shape = circle
/height = list.dot_size.nextvalue
/color = counter.dot_color1.selectedvalue
/hposition = list.h_position.nextvalue
/vposition = list.v_position.nextvalue
</shape>

<shape dot2>
/shape = circle
/height = list.dot_size.nextvalue
/color = counter.dot_color2.selectedvalue
/hposition = list.h_position.nextvalue
/vposition = list.v_position.nextvalue
</shape>

<list h_position>
/items = (10-90)
/ selectionrate = always
/selectionmode = random
</list>

<list v_position>
/items = (10-90)
/selectionrate = always
/selectionmode = random
</list>

<list dot_size>
/items = (20-40)
/selectionrate = always
/selectionmode = random
</list>

<counter dot_color1>
/items = (blue, yellow)
/select = noreplace
/ selectionrate = trial
</counter>

<counter dot_color2>
/items = (blue, yellow)
/select = noreplace
/not = (counter.dot_color1)
/selectionrate = trial
</counter>

********EXPERIMENT***********

<expt intro>
/blocks = [
1=intro
]
</expt>

<block intro>
/trials = [
1=intro Mouse click test
]
</block>

<trial intro>
/ stimulusframes = [1=dot1, dot2, fixation]
/validresponse = (203, 205)
</trial>
 
Top