mercredi 3 avril 2019

How to generate a new sequence of random numbers every day?

I'm making a daily challenge in a game. Every day should be a new challenge. My procedural generation uses a random number generator. Attempting the daily challenge twice (or two different users attempting it) should have the same results (the same sequence of random numbers).

I want:

  • generate a sequence of random numbers.
  • sequence must be the same every time I start generating in the same day
  • get a different sequence of numbers each day

I think I should create a Random with a DateTime as the seed, but I'm not sure how. DateTime.UtcNow.Ticks is a long and DateTime's seed is an int.

I do not want the hours/minutes/seconds to impact the randomness (aside from the boundary between yesterday and today). The answers I've found are all about passing the current time into Random (or how that's the default no-parameter ctor behaviour).




Aucun commentaire:

Enregistrer un commentaire