If you want a repeatable random number generator (I know it sounds like an oxymoron, but there are many uses), then you can see what I’ve done in Bullshit Bingo, (a very incomplete project.)
$:/_/bb/core/modules/filters/random adds the random
filter operator. It encapsulates a seed
value, and the random sequence is consistently derived from this seed. By default, the seed value is taken from the current timestamp, but you can reset when you choose.
Each numbered line: <$list filter="[range[1],[5]] :map[random[]]" join=" - " />
1: 0.19520605020832604 - 0.7753033857357936 - 0.8539897062427786 - 0.15315850285354154 - 0.5485494205384965
2: 0.06974825811421169 - 0.9001869682434088 - 0.37714365743496375 - 0.991742586043906 - 0.38895416827141904
[random:seed[42]]
3: 0.4522544728826022 - 0.6456426595707433 - 0.763655334196982 - 0.1435706032701936 - 0.2765127271454081
[random:seed[42]]
4: 0.4522544728826022 - 0.6456426595707433 - 0.763655334196982 - 0.1435706032701936 - 0.2765127271454081
// Note the repeat between lines 3 and 4
I use the randomization in that page in two ways. First, on startup, I store the result of a random call as the name of the default card to show. Second, when I go to render any card, I seed the randomizer with the card number, and then get a consistent Bingo Card. Every visit to Card 837 will have the same terms in the same squares.
This is not appropriate for all randomization needs, but there are many use cases for a random-seeming, but repeatable, sequence. The implementation is nothing special, using a simple Linear congruential generator. Please done try to use it for cryptographical work!