Random numbers in 2d script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2004-04-01 02:12 PM
I'm trying to write a script for an object that will display random/different people in 2d for elevation drawings. Problem is that the random numbers that ArchiCAD generates are generally the same and not very random!
Is there some way I can force ArchiCAD to generate better random numbers?
I remember writing a programme for my Psion that used random numbers and the best way it did it was getting the time in seconds and multiply that with a "random" number and then get the interger of that result. This was due to the Psion generating somewhat limited random numbers.
Below is the script which calls up a Fragment based on the random number.
10:
Randper= INT (RND (15))
fill bft
pen bpn
fragment2 Randper,1
RETURN
Using AC25 5005 UKI FULL
Mac OSX 10.15.7 (19G2021) Mac Pro-2013 32gbRam AMD FirePro D500 3072 MB graphics
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2004-04-01 10:06 PM
Oleg wrote:Interesting trick. I have always wondered what the internal ID might be useful for.
I think, this is some of GDL engine optimization effect.
Try this trick to avoid it.
Instead RND(12) type RND(12 + GLOB_INTID*0 )
Oleg

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2004-04-01 10:41 PM
fuzzytnth3 wrote:Try this
10:
Randper= INT (RND (15))
fill bft
pen bpn
fragment2 Randper,1
RETURN
10: Randper= RND(GLOB_INTID) ! pass one random ! +1 : fragments index start from 1 ! -1e-6 : to avoid exactly 16 Randper= INT(RND(16)-1e-6) + 1 fill bft pen bpn fragment2 Randper,1 RETURN

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2004-04-01 10:41 PM

Using AC25 5005 UKI FULL
Mac OSX 10.15.7 (19G2021) Mac Pro-2013 32gbRam AMD FirePro D500 3072 MB graphics

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2004-04-02 02:12 AM

I've made a part that forms planks of varying widths, though I've got a few issues:
When I copy my object, the projection on plan is the same as the original, even though when I go to 3D view the objects apear different.
Any ideas how to get around this?
And while I'm at it, how do I get the 3D and 2D script to use the same random number sequence? So I get hotspots on each end of the plank.
Thanks.
Graphisoft Senior Product Manager
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2004-04-02 02:28 AM
James wrote:Try generating your random values in the master script.
I've found this useful as well. Thanks
I've made a part that forms planks of varying widths, though I've got a few issues:
When I copy my object, the projection on plan is the same as the original, even though when I go to 3D view the objects apear different.
Any ideas how to get around this?
And while I'm at it, how do I get the 3D and 2D script to use the same random number sequence? So I get hotspots on each end of the plank.
Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2004-04-02 02:38 AM
Graphisoft Senior Product Manager
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2004-04-02 02:55 AM
James wrote:In the master script you could get it to create an array and fill it with random numbers, then use these same numbers sequentially in both scripts as part of a FOR NEXT loop.
I tried that. But because each plank needs to be random widths, the random number is generated with in a FOR NEXT 3D script - therefore generating a new random number for each plank.
regards

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2004-04-02 03:20 AM
Just got home from ACUWest trip last night and am slowly catching up here. A number of comments to throw into the soup.
First, we are talking about
Matthew (good meeting you!) is right to a point about the coins and so forth. A mathematical coin when flipped a large number of times (not necessarily approaching infinity!) will be heads 50% of the time and tails 50% of the time. A sequence of 12 numbers is not sufficient to verify the mathematical properties of a random number generator. 100's to 1,000's have to be generated if one really cares (AC's RND is 'good enough') ... and then various tests are run ... a so-called 'bucket' test - throwing the numbers into buckets to make sure that the generator is uniform - that is, it does not favor certain values over others. (For a generator producing numbers from 1 to 10, we might have 10 'buckets' ... and generate 1,000 numbers... and would expect to see close to 100 - perhaps 95 to 105 - numbers in each bucket.) A 'runs' test, makes sure that the generator isn't generating numbers in sequence too often ... 1,2,3,4,5,6,7,8,9,10 over and over would pass the bucket test, but wouldn't be too random. And so forth. A very well-studied area of computer science and statistics for over 50 years dating back to when computer simulations were called 'Monte Carlo' simulatinos.
Anyway, just some more background there.
Attached is a GDL object that displays either a list of numbers or a bar chart (parameter) in 2D. No statistical tests. But, it lets you see some of the numbers produced by the AC RND function. Rebuild and they stay the same. If you select the 'Karl' function (which isn't statistically perfect, but is OK), then when you rebuild, you'll see a different set of numbers each time. This function was created in order to product an animation that DOES change with each rebuild ... so each new frame of a movie has a new effect. Was going to write something up about it for David's Cookbook, but until today, hadn't seen that anybody else was interested in random numbers.
I used my goofy function for the ArchiContest a few years ago where I built a Finnish Tulikivi soapstone fireplace that was a light source for the scene - and the firelight flickered randomly in intensity, direction and color (within limits of course to make it look real). It used 3 AC lamps inside the woodstove to get the desired effect, which was pretty cool. I think I still have a little MOV that I could post if anyone is interested.
See you in Las Vegas (not).
Karl

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2004-04-02 03:21 AM
Karl

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2004-04-02 10:37 AM
Karl wrote:That sounds very cool. Do you still have the animation on the web somewhere? I would love to see it.
I used my goofy function for the ArchiContest a few years ago where I built a Finnish Tulikivi soapstone fireplace that was a light source for the scene - and the firelight flickered randomly in intensity, direction and color (within limits of course to make it look real). It used 3 AC lamps inside the woodstove to get the desired effect, which was pretty cool. I think I still have a little MOV that I could post if anyone is interested.
Cheers
Graeme
Using AC25 5005 UKI FULL
Mac OSX 10.15.7 (19G2021) Mac Pro-2013 32gbRam AMD FirePro D500 3072 MB graphics