How to generate a random number from system clock as seed
Eric P626
ericp at lariennalibrary.com
Sun Jun 9 14:02:54 UTC 2024
On Sunday, 9 June 2024 at 13:20:09 UTC, Joseph Rushton Wakeling
wrote:
> On Saturday, 8 June 2024 at 16:09:04 UTC, monkyyy wrote:
>> rng is an optional parameter, `uniform(0,100).writeln;` alone
>> works; the docs not telling you that is really bad
>
> The docs do tell you that `rng` is an optional parameter of
I don't need anything fancy. Most of the time, it's for video
games, so I want to make sure the numbers are always shuffled.
Here it's for maze generation, so I wan each maze to be unique.
Eventually, I would like to use a fixed seed generator, so that I
can generate the same maze over and over again if necessary. I
guess, in that case, I could create a generator.
I found the the simplest way to implement this is not to define
any seed or generator and simply call:
~~~
uniform(0,2)
~~~
with the range you want. It was a bit counter intuitive because
most languages have a ```rand()``` function. But I prefer
specifying a range.
Thanks again.
More information about the Digitalmars-d-learn
mailing list