<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: random 1 or -1 ? in GDL</title>
    <link>https://community.graphisoft.com/t5/GDL/random-1-or-1/m-p/650363#M7412</link>
    <description>&lt;P&gt;Another possibility&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;xx = 0.50&lt;BR /&gt;my_value = -xx + RND(xx*2)&lt;/P&gt;</description>
    <pubDate>Tue, 04 Feb 2025 14:04:59 GMT</pubDate>
    <dc:creator>Yves</dc:creator>
    <dc:date>2025-02-04T14:04:59Z</dc:date>
    <item>
      <title>random 1 or -1 ?</title>
      <link>https://community.graphisoft.com/t5/GDL/random-1-or-1/m-p/650096#M7398</link>
      <description>&lt;P&gt;&lt;SPAN class="HwtZe"&gt;&lt;SPAN class="jCAhz ChMk0b"&gt;&lt;SPAN class="ryNqvb"&gt;some simple randomization algorithm in GDL to get the value 1 or -1 ? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2025 08:34:49 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/random-1-or-1/m-p/650096#M7398</guid>
      <dc:creator>gaba</dc:creator>
      <dc:date>2025-02-03T08:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: random 1 or -1 ?</title>
      <link>https://community.graphisoft.com/t5/GDL/random-1-or-1/m-p/650103#M7399</link>
      <description>&lt;P&gt;There is a random function in GDL (RND), but it returns a positive number.&lt;/P&gt;
&lt;P&gt;You would have to do something like this I would think...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if RND(1) &amp;lt;= 0.5 then&lt;/P&gt;
&lt;P&gt;my_value = -1&lt;/P&gt;
&lt;P&gt;else&lt;/P&gt;
&lt;P&gt;my_value = 1&lt;/P&gt;
&lt;P&gt;endif&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Barry.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2025 09:15:43 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/random-1-or-1/m-p/650103#M7399</guid>
      <dc:creator>Barry Kelly</dc:creator>
      <dc:date>2025-02-03T09:15:43Z</dc:date>
    </item>
    <item>
      <title>Re: random 1 or -1 ?</title>
      <link>https://community.graphisoft.com/t5/GDL/random-1-or-1/m-p/650105#M7400</link>
      <description>&lt;P&gt;And from memory it is not truly random.&lt;/P&gt;
&lt;P&gt;You will get the same result every time you run it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Barry.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2025 09:19:16 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/random-1-or-1/m-p/650105#M7400</guid>
      <dc:creator>Barry Kelly</dc:creator>
      <dc:date>2025-02-03T09:19:16Z</dc:date>
    </item>
    <item>
      <title>Re: random 1 or -1 ?</title>
      <link>https://community.graphisoft.com/t5/GDL/random-1-or-1/m-p/650132#M7401</link>
      <description>&lt;P&gt;&lt;SPAN class="HwtZe"&gt;&lt;SPAN class="jCAhz ChMk0b"&gt;&lt;SPAN class="ryNqvb"&gt;Barry thanks, I know rnd() but it's a weird function.&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="HwtZe"&gt;&lt;SPAN class="jCAhz ChMk0b"&gt;&lt;SPAN class="ryNqvb"&gt;I thought to use REQUEST('DateTime'... but it's not possible to read at least milliseconds etc.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2025 10:36:46 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/random-1-or-1/m-p/650132#M7401</guid>
      <dc:creator>gaba</dc:creator>
      <dc:date>2025-02-03T10:36:46Z</dc:date>
    </item>
    <item>
      <title>Re: random 1 or -1 ?</title>
      <link>https://community.graphisoft.com/t5/GDL/random-1-or-1/m-p/650293#M7403</link>
      <description>&lt;P&gt;I have used the RND function in conjunction with a position variable of the relevant entity before. Use the % operand to "limit" the output to your desired range.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;mat_array[int(rnd(abs(mat_seed*iDis)) % mat_count) + 1]&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I want a different generation, I can just change the seed if I do not want to change the position.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ps. What are you trying to do that needs to be randomised every milisecond? There's not Unix time stamp in AC...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2025 07:54:22 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/random-1-or-1/m-p/650293#M7403</guid>
      <dc:creator>Lingwisyer</dc:creator>
      <dc:date>2025-02-04T07:54:22Z</dc:date>
    </item>
    <item>
      <title>Re: random 1 or -1 ?</title>
      <link>https://community.graphisoft.com/t5/GDL/random-1-or-1/m-p/650342#M7411</link>
      <description>&lt;P&gt;&lt;SPAN class="HwtZe"&gt;&lt;SPAN class="jCAhz ChMk0b"&gt;&lt;SPAN class="ryNqvb"&gt;Thank you &lt;a href="https://community.graphisoft.com/t5/user/viewprofilepage/user-id/11140"&gt;@Lingwisyer&lt;/a&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;1. I have several hedges with the SAME dimensions A,B,ZZYZX e.g. 100x60x150&lt;BR /&gt;2. In gdl (without changing A,B,ZZYZX) I would like each hedge to add to A,B,ZZYZX (or subtract) a random value from the range e.g. 0-10cm.&lt;BR /&gt;3. This way each hedge will look slightly different (a little longer or shorter, a little wider or narrower, a little higher or lower etc.).&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;aa=A
bb=B
hh=ZZYZX
if rnd_size then
  if rnd_a&amp;gt;EPS then aa=aa+rnd(10)*rnd_a*0.01 !!! if random A, rnd_a=&amp;lt;0,1,2...&amp;gt;
  if rnd_b&amp;gt;EPS then bb=bb+rnd(10)*rnd_b*0.01 !!! if random B, rnd_b=&amp;lt;0,1,2...&amp;gt;
  if rnd_h&amp;gt;EPS then hh=hh+rnd(10)*rnd_h*0.01 !!! if random ZZYZX, rnd_h=&amp;lt;0,1,2...&amp;gt;
endif
...model hedge aa x bb x hh&lt;/LI-CODE&gt;
&lt;P&gt;For now I can randomly increase A,B,ZZYZX, that's why I asked about random +/-1&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="rnd_size.png" style="width: 400px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/82753iC6A1E68C7747A5BD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="rnd_size.png" alt="rnd_size.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2025 12:08:44 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/random-1-or-1/m-p/650342#M7411</guid>
      <dc:creator>gaba</dc:creator>
      <dc:date>2025-02-04T12:08:44Z</dc:date>
    </item>
    <item>
      <title>Re: random 1 or -1 ?</title>
      <link>https://community.graphisoft.com/t5/GDL/random-1-or-1/m-p/650363#M7412</link>
      <description>&lt;P&gt;Another possibility&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;xx = 0.50&lt;BR /&gt;my_value = -xx + RND(xx*2)&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2025 14:04:59 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/random-1-or-1/m-p/650363#M7412</guid>
      <dc:creator>Yves</dc:creator>
      <dc:date>2025-02-04T14:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: random 1 or -1 ?</title>
      <link>https://community.graphisoft.com/t5/GDL/random-1-or-1/m-p/650453#M7415</link>
      <description>&lt;P&gt;Need to work on your pruning skills!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you just wanting the&amp;nbsp;±1 to mirror your output values into the negatives? Just double the size of your RND range and offset everything. As Barry has mentioned, every instance of RND in your script will return the same base value, so in your case your range would end up split in half. It is why the code that I showed before uses a position value as it is something that would change enough with each loop to faux the randomisation. The seed value then just makes this faux even more obscure. Without it I would have gotten a very visible set pattern.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ling.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 01:27:43 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/random-1-or-1/m-p/650453#M7415</guid>
      <dc:creator>Lingwisyer</dc:creator>
      <dc:date>2025-02-05T01:27:43Z</dc:date>
    </item>
    <item>
      <title>Re: random 1 or -1 ?</title>
      <link>https://community.graphisoft.com/t5/GDL/random-1-or-1/m-p/650462#M7416</link>
      <description>&lt;P&gt;I found this post that may help to generate non-repeating random numbers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.graphisoft.com/t5/Libraries-objects/Random-numbers-in-2d-script/m-p/22771/highlight/true#M40872" target="_blank"&gt;https://community.graphisoft.com/t5/Libraries-objects/Random-numbers-in-2d-script/m-p/22771/highlight/true#M40872&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can read the whole thread but from the post I link to I think is most relevant.&lt;/P&gt;
&lt;P&gt;It is all about generating a unique seed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Barry.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 01:54:38 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/random-1-or-1/m-p/650462#M7416</guid>
      <dc:creator>Barry Kelly</dc:creator>
      <dc:date>2025-02-05T01:54:38Z</dc:date>
    </item>
    <item>
      <title>Re: random 1 or -1 ?</title>
      <link>https://community.graphisoft.com/t5/GDL/random-1-or-1/m-p/650652#M7426</link>
      <description>&lt;P&gt;thanks Barry, this is a very old post but the idea is right,&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.graphisoft.com/t5/Libraries-objects/Random-numbers-in-2d-script/m-p/22771/highlight/true#M40872" target="_blank" rel="noopener"&gt;https://community.graphisoft.com/t5/Libraries-objects/Random-numbers-in-2d-script/m-p/22771/highlight/true#M40872&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;except that GLOB_INTID is now probably GLOB_INTGUID.&lt;BR /&gt;And GLOB_INTGUID is a string and I think you should randomly choose a number (or letter) from it. And I used this fact (letter or number) as a trick for the -/+1 situation (i.e. the direction of decreasing or increasing the constant size of the base object).&lt;BR /&gt;Finally, something like this came out:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;... myscript

q=strsub(GLOB_INTGUID,int(RND(10)),1) !!! STR random number [0-9] or letter from object GLOB_INTGUID

id2int=0 : n = SPLIT (q, "%n", id2int) !!! convert STR 2 INT

xdir= ( (id2int&amp;lt;EPS)*(-1) + (id2int&amp;gt;EPS)*(1) ) !!! if letter= -1, if number= +1

	!!! default size
	aa=A
	bb=B
	hh=ZZYZX

if rnd_size then	!!! if random object sizes ON

	if rnd_a&amp;gt;EPS then \	!!! if random object size A
			aa = A + RND ((rnd_a - id2int) *0.01 ) * xdir !!! if random A, rnd_a=myrange [0,....]

	if rnd_b&amp;gt;EPS then \ !!! if random object size B
			bb = B + RND ((rnd_b - id2int) *0.01 ) * xdir !!! if random B, rnd_b=myrange [0,....]

	if rnd_h&amp;gt;EPS then \ !!! if random object size ZZYZX
			hh = ZZYZX + RND ((rnd_h - id2int) *0.01 ) * xdir !!! if random ZZYZX, rnd_h=myrange [0,....]
		
endif

...model hedge aa x bb x hh&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="HwtZe"&gt;&lt;SPAN class="jCAhz ChMk0b"&gt;&lt;SPAN class="ryNqvb"&gt;Control of the range of increasing/decreasing dimensions AxBxZZYZX is done with separate parameters rnd_a, rnd_b, rnd_h.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="jCAhz ChMk0b"&gt;&lt;SPAN class="ryNqvb"&gt; Setting e.g. rnd_a=0 means using the base dimension A. &lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;And generally speaking, in my specific application it is not a "bug" that random numbers are "constant", because I do not want objects to randomly change their dimensions with each window regeneration. It would be bad if a given hedge in one camera shot had for example a different height, and in another camera shot (or section/elevation...) a different one. That would be ridiculous! The random dimensions will actually change only after changing the base AxBxZZYZX (OR AFTER CLONING the object!).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="rnd_size2.png" style="width: 999px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/82813i7CC9C891C3092608/image-size/large?v=v2&amp;amp;px=999" role="button" title="rnd_size2.png" alt="rnd_size2.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 12:01:48 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/GDL/random-1-or-1/m-p/650652#M7426</guid>
      <dc:creator>gaba</dc:creator>
      <dc:date>2025-02-05T12:01:48Z</dc:date>
    </item>
  </channel>
</rss>

