Help with Randomization of Non-Overlapping Images
Vinson, David
d.vinson at ucl.ac.uk
Fri Aug 1 17:54:23 UTC 2014
I suspect you didn't get any replies before due the impressively complicated set of OR statements in that loop. I suspect the problem is there somewhere but imagine it world be a nightmare to track it down. My guess is the loop never exits, whether due to an error or impossible constraints.
What if instead you enumerated the possible legal combinations of positions in a nested List and then just sampled one of them per trial?
Good luck,
David V
----- Reply message -----
From: "tamiskovich at gmail.com" <tamiskovich at gmail.com>
To: "e-prime at googlegroups.com" <e-prime at googlegroups.com>
Subject: Help with Randomization of Non-Overlapping Images
Date: Fri, Aug 1, 2014 6:30 pm
Does anyone have any suggestions on this? I'm stuck on this and eprime support directed me here.
Tara
On Monday, July 28, 2014 3:43:33 PM UTC-5, Tara Miskovich wrote:
Hello,
I am working on having 4 images randomly places within a rectangular region without overlapping. I wrote the code below, and it appears to be working with up to Image 3 added, but when I add in the forth image the program freezes. I am hoping for some guidance with what to try next or how to get past this. Here is the code I wrote to randomize the x and y location for each image.
Thanks!
Tara
Dim x1 As Integer
Dim x2 As Integer
Dim x3 As Integer
Dim x4 As Integer
Dim y1 As Integer
Dim y2 As Integer
Dim y3 As Integer
Dim y4 As Integer
x1 = random(36, 42)
y1 = random(38, 60)
Do
x2 = random(36, 42)
y2 = random(38, 60)
x3 = random(36, 42)
y3 = random(38, 60)
x4 = random(36, 42)
y4 = random(38, 60)
Loop While (x2 = x1 Or x2 = x1 + 1 Or x2 = x1+2 Or x2 = x1 - 1 Or x2 = x1 - 2 _
And y2 = y1 Or y2 = y1 + 1 Or y2 = y1 + 2 Or y2 = y1 + 3 Or y2 = y1 - 1 Or y2 = y1 - 2 Or y2 = y1 - 3)_
Or (x3 = x1 Or x3 = x1 + 1 Or x3 = x1+2 Or x3 = x1 - 1 Or x3 = x1 - 2 _
And y3 = y1 Or y3 = y1 + 1 Or y3 = y1 + 2 Or y3 = y1 + 3 Or y3 = y1 - 1 Or y3 = y1 - 2 Or y3 = y1 - 3)_
Or (x3 = x2 Or x3 = x2 + 1 Or x3 = x2+2 Or x3 = x2 - 1 Or x3 = x2 - 2 _
And y3 = y2 Or y3 = y2 + 1 Or y3 = y2 + 2 Or y3 = y2 + 3 Or y3 = y2 - 1 Or y3 = y2 - 2 Or y3 = y2 - 3)_
or (x4 = x1 Or x4 = x1 + 1 Or x4 = x1+2 Or x4 = x1 - 1 Or x4 = x1 - 2 _
And y4 = y1 Or y4 = y1 + 1 Or y4 = y1 + 2 Or y4 = y1 + 3 Or y4 = y1 - 1 Or y4 = y1 - 2 Or y4 = y1 - 3)_
Or (x4 = x2 Or x4 = x2 + 1 Or x4 = x2 + 2 Or x4 = x2 - 1 Or x4 = x2 - 2 _
And y4 = y2 Or y4 = y2 + 1 Or y4 = y2 + 2 Or y4 = y2 + 3 Or y4 = y2 - 1 Or y4 = y2 - 2 Or y4 = y2 - 3)_
Or (x4 = x3 Or x4 = x3 + 1 Or x4 = x3 + 2 Or x4 = x3 - 1 Or x4 = x3 - 2 _
And y4 = y3 Or y4 = y3 + 1 Or y4 = y3 + 2 Or y4 = y3 + 3 Or y4 = y3 - 1 Or y4 = y3 - 2 Or y4 = y3 - 3)
c.SetAttrib "x1", x1
c.SetAttrib "x2", x2
c.SetAttrib "x3", x3
c.SetAttrib "x4", x4
c.SetAttrib "y1", y1
c.SetAttrib "y2", y2
c.SetAttrib "y3", y3
c.SetAttrib "y4", y4
--
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To unsubscribe from this group and stop receiving emails from it, send an email to e-prime+unsubscribe at googlegroups.com<mailto:e-prime+unsubscribe at googlegroups.com>.
To post to this group, send email to e-prime at googlegroups.com<mailto:e-prime at googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/e-prime/8d0ddea8-f54e-4a98-a006-cdcbed5cc8ce%40googlegroups.com<https://groups.google.com/d/msgid/e-prime/8d0ddea8-f54e-4a98-a006-cdcbed5cc8ce%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To unsubscribe from this group and stop receiving emails from it, send an email to e-prime+unsubscribe at googlegroups.com.
To post to this group, send email to e-prime at googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/e-prime/B628F720-33AE-48CB-B973-CA5AA81AC8E3%40ucl.ac.uk.
For more options, visit https://groups.google.com/d/optout.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserv.linguistlist.org/pipermail/eprime/attachments/20140801/16d9ad93/attachment.htm>
More information about the Eprime
mailing list