Re: [hatari-devel] Hatari_srand() / Hatari_rand()?

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Two nitpicky comments (sorry), that are however not meant to argue against the change:
 
You do not call the OS's rand() and srand() function, but the standard library's. The pseudo-random generator state is not shared with other processes/programs. So, for a given Hatari build on a Hatari machine, you will get reproducible random numbers from rand() if you call srand() with a fixed seed. This is guaranteed by the C standard.
 
Of course on a different machine or with a Hatari executable built with a different compiler/standard library, you might get a different sequence of reproducible random numbers, if they implement a different PRNG.
 
Regards
Christian
 
 
Gesendet: Donnerstag, 18. Januar 2024 um 09:39 Uhr
Von: "Nicolas Pomarède" <npomarede@xxxxxxxxxxxx>
An: hatari-devel@xxxxxxxxxxxxxxxxxxx
Betreff: Re: [hatari-devel] Hatari_srand() / Hatari_rand()?
Le 18/01/2024 à 00:26, Eero Tamminen a écrit :
> Hi Nicolas,
>
> Is the intention of the new Hatari_srand() / Hatari_rand() wrappers to
> be able to set used random seed value (after CLI option is added for
> that) for reproducible Hatari runs?
>

Hi

not really, it's more about isolating the underlying random method for
now. We use the OS's rand() but some other emulators are sometimes using
a different/faster method (see uaerand() in cpu/ or also core_rand() in
Hatari for libretro).

If we ever want to have our own internal random function (that don't get
called by other programs) to have reproducible series of random numbers
then it will be possible this way

Nicolas


 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/