GLB Random Number Algorithm?

Previous topic - Next topic

Widget101

Hi there,

Having spent far too long in Elite Dangerous and No Man's Sky I've been playing round with the SEEDRND and RND functions in GLBasic to create a super simple procedural galaxy (well, basically a matrix with repeatable numbers in it to represent stars) and am wondering what algorithm and 'period' GLB uses (if its not a secret!) as its basis??

:)



dreamerman

Hi, generally as You can download GLBasic source (it's >2GB with all stuff) so there are no secrets in any function :-)
GLB is using ISSAC method and 'rand.c' implementation (or whatever it should be called properly) by Bob Jenkins. You can found original code here: https://burtleburtle.net/bob/c/rand.c
It was little modified to work as GLB part, but core is same.


Check my source code editor for GLBasic - link Update: 20.04.2020

Widget101

Quote from: dreamerman on 2020-Jun-07
Hi, generally as You can download GLBasic source (it's >2GB with all stuff) so there are no secrets in any function :-)
GLB is using ISSAC method and 'rand.c' implementation (or whatever it should be called properly) by Bob Jenkins. You can found original code here: https://burtleburtle.net/bob/c/rand.c
It was little modified to work as GLB part, but core is same.

Thanks for that Dreamerman, that's awesome. Wiki reckons of the ISAAC PRNG that 'Only a few other generators of such high quality and speed exist in usage'.

I was looking into methods for procedural generation and quite a few examples of other systems that I found on the 'tinternet using 'inbuilt' rand functions start developing patterns when graphically representing very large numbers of results, and as such coders were manually implementing the Lehmer or other algorithm. I was wondering whether I'd be getting a similar issue with GLB but it looks really solid, no problems, and I guess that's why! :good:

QuoteDesigned for speed and security, ISAAC (Indirection, Shift, Accumulate, Add, and Count) generates 32-bit random numbers. On average, cycles are 2^8295 values long, and are guaranteed to be at least 2^40 values long. The results are uniformly distributed, unbiased, and unpredictable unless you know the seed.

[Note: reading this back before posting makes me sound like I know what I'm talking about!!  :P Just to be clear - I really don't, but do find it fascinating!]

Hemlos

You can use rnd() as the seed input too.
Bing ChatGpt is pretty smart :O