>
>
> >Hello openbsd users and developers. I read this exchange between these
> two gentlemen on ports@, and I have been building a tile game where each
> tile is one byte, and I want to use this function to generate a random page
> for the map:
> >
> >#include <stdlib.h>
> >
> >int main(void) {
> > unsigned char page[4096];
> > arc4random_buf(page, sizeof(page));
> > return 0;
> >}
>
> As others have well-described the concerns Theo raised about the use of
> rand(3) I wanted to mention that in the context of your use-case (game
> programming) you may absolutely *require* a deterministic pseudo-random
> number generator. This is, for example the sort of behavior relied upon
> by most games that use a seed to generate a random world. If you
> wish to be able to have yor random map be re-created (whether for play
> or testing) then you need a deterministic algorithm.
>
But I think rand() is so loosely specified that you are not guaranteed that
it gives the same results on different OSes (or versions of it), different
endianess, different CPUs or just different libc's so whatever you wish
from a deterministic RNG, you are not going to be able to rely on rand()
giving you most of those wished-for properties.
--
May the most significant bit of your life be positive.