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-04 01:28 AM
fuzzytnth3 wrote:Just uploaded the small QuickTime movie (182 kb) to: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.
Low quality res and scene was just to demo the firelight.
Thanks,
Karl
One of the forum moderators

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2004-04-06 10:41 AM
Just uploaded the small QuickTime movie (182 kb) to:Very effective Karl.
http://www.archispectives.com/tips/Flickering-Firelight-Karl.mov
Low quality res and scene was just to demo the firelight.
Thanks,
Karl
I finished my random people object yesterday. I've attached a wee snapshot. Quite chuffed with it as it works on slopes as well as horizontal

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-06 09:00 PM
fuzzytnth3 wrote:Very nice. It illustrates nicely one of my broader wishes for GDL: that objects can be aware of their surroundings. There are cases where you have two identical people adjacent to one another in your image. A simple result of randomness. It would be nice if an object were "contextually aware" ... and could make queries such as "if there is an object of type X within Y meters of me, what is the value of parameter Z for that object" (well, actually, it would return a set - or array - of such things). Then, one of the identical people could turn itself into a different image in your case.
I finished my random people object yesterday. I've attached a wee snapshot. Quite chuffed with it as it works on slopes as well as horizontal
More broadly, objects could 'react' to other elements - preventing interferences (if desired), or maintaining specified distances from other elements. A toilet would enforce spacing from walls and cabinets that conforms to building codes, for example. For the dream list, if not the wish list.
Karl
One of the forum moderators

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2004-04-06 09:43 PM
One thought I had was to use an array where you create a random number put it in the array and then generate another random number but then have the script check what the first number was but add an allowance for the width of the first object, in this case a person. If the second random fell within the range of the first then the script would generate a new random number until it creates a random number that doesn't clash with the first. Repeat the process for more iterations.
Having said all that, I thought to myself arrrgh! I have never used arrays in GDL or the PSION language that I used to write programmes for. I have just never quite got my head round how you pull out the specific number from an array that you want to use.
Maybe I should see this as a challenge to conquer arrays

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-07 03:16 AM
You wrote on April 2:
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
What is the variable "1e" ?
Where is it declared ?
Thanks,
Peter Devlin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2004-04-07 06:55 AM
Peter wrote:It is not variable.
What is the variable "1e" ?
Where is it declared ?
Thanks,
Peter Devlin
1e-6 is just a number (small one).
This format available in most programming languages.
It mean power of 10, like 1*10^(-6)
= 0.000001
Oleg.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2004-04-07 11:00 PM
I did not know that.
I wrote this in a 3D script
!It is not variable.
!1e-6 is just a number (small one).
!This format available in most programming languages.
!It mean power of 10, like 1*10^(-6)
!= 0.000001
w=0.000001
x=1*10^(-6)
y=1e-6
z=10**(-6)
print w,",",x,",",y,",",z
it printed this: 1e-06,1e-06,1e-06,1e-06
Thank you for this information.
Peter Devlin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2006-04-05 10:55 AM
Wish I had read your trick many wasted hours ago!
Cheers
Paul
ArchiCAD 8-28 | Twinmotion 2024
Windoze 11 PC | Intel Core i9 10900K | Nvidia Gforce RTX 3080 | 32 Gb DDR3 | 2x4K monitor extended desktop
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2006-04-05 07:37 PM
That random people object looks very cool.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2018-12-11 04:12 AM
Ling.
AC22-28 AUS 3110 | Help Those Help You - Add a Signature |
Self-taught, bend it till it breaks | Creating a Thread |
Win11 | i9 10850K | 64GB | RX6600 | Win11 | R5 2600 | 16GB | GTX1660 |