Gamestudio Links
Zorro Links
Newest Posts
Why Zorro supports up to 72 cores?
by 11honza11. 04/26/24 08:55
M1 Oversampling
by 11honza11. 04/26/24 08:32
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (VoroneTZ, Quad, EternallyCurious, 1 invisible), 844 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
how to randomize properly #443536
07/19/14 11:33
07/19/14 11:33
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline OP
Senior Expert
HeelX  Offline OP
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
random_seed((sys_seconds % sys_month) * sys_hours - 42);

Re: how to randomize properly [Re: HeelX] #443537
07/19/14 11:50
07/19/14 11:50
Joined: May 2008
Posts: 2,113
NRW/Germany
alibaba Offline
Expert
alibaba  Offline
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
Thanks!


Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
Re: how to randomize properly [Re: alibaba] #443538
07/19/14 12:14
07/19/14 12:14
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Thank you! I wish this could be add in the manual!


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: how to randomize properly [Re: 3run] #443540
07/19/14 13:00
07/19/14 13:00
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline
Serious User
DLively  Offline
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
I dont understand, how is this different or better than just random_seed(0);?


A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: how to randomize properly [Re: DLively] #443544
07/19/14 14:36
07/19/14 14:36
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline OP
Senior Expert
HeelX  Offline OP
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
It is derived from the Z12 and Z5 strategies. Therefore you should trust it.

Re: how to randomize properly [Re: HeelX] #443546
07/19/14 15:51
07/19/14 15:51
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline
Serious User
DLively  Offline
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
Alright, I shall trust it - But how its different than random_seed(0);


A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Re: how to randomize properly [Re: DLively] #443579
07/20/14 17:53
07/20/14 17:53
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
It's not implementation defined.
Anyhow, this is not the right way to initialize a PRNG, sorry lads. Time doesn't have enough entropy and even worse, because this code only takes seconds, you have a full second (or 2.something billion CPU clock cycles) where re-seeding the PRNG will result in it generating the very same values over and over again.

The generally agreed upon way of seeding a PRNG is to tap into the kernels entropy pool and get some bits out of there. The kernel has a pool of high quality entropy available for access, and it's ideal to get some bits from there to initialize a PRNG.

Edit: to be fair, going down this road leads you to all kinds of interesting topics. It also highly depends on what quality of randomness you require. A game might get away with very low quality randomness out of a shitty LCG, although it really doesn't hurt to use Mersenne Twister which has a much larger period and returns uniformly distributed results. But maybe you don't want uniformly distributed results but add a weight in, for example RPGs might choose to have a "luck" skill that biases the results of the randomness.

Last edited by JustSid; 07/20/14 18:00.

Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: how to randomize properly [Re: WretchedSid] #443584
07/20/14 18:06
07/20/14 18:06
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline
Serious User
DLively  Offline
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
Thanks for clearing this up, JustSid laugh


A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1