Page 1 of 1

ENTROPY_GET

Posted: Sun Feb 25, 2024 3:06 pm
by flimbo72
Hello everybody.

I'm currently using Kernal's ENTROPY_GET routine to shuffle a 5 elements array, but I get some quirks:

- a certain sequence shows up way too often
- occasionally a sequence comes up twice in a row

Upon extensive checking, I can safely claim that my shuffle algorithm is working properly, so I'm now questioning if ENTROPY_GET is a reliable random number generator.
Did any of you have a chance to deal with such routine? What do you think about it?

Thanks,
Giacomo

Re: ENTROPY_GET

Posted: Mon Feb 26, 2024 3:36 pm
by mortarm
JAT, is there a way to initialize the seed before calling the routine, like you can in BASIC?

Re: ENTROPY_GET

Posted: Mon Feb 26, 2024 7:19 pm
by desertfish
I don't think there's a way to "seed" this, actually, I would argue the result of this call is meant to be a seed in its own.
The docs say:
This routine returns 24 somewhat random bits in registers .A, .X, and .Y. In order to get higher-quality random numbers, this data should be fed into a pseudo-random number generator.
So it's probably best to do that, and not continuously call this routine to get random numbers from.
Here's a pretty good prng https://codebase64.org/doku.php?id=base ... r_8_16_bit