Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ public static class RandomSeedGenerator

#endregion

/// <summary>
/// The seed that should be used for random number generation
/// </summary>
private static int? Seed = null;

#region Public Methods and Operators

public static int GetRandomSeed()
Expand All @@ -44,10 +49,15 @@ public static int GetRandomSeed()
{
}

// Keep the randomness per hour instead of per day.
DateTime now = DateTime.UtcNow;
int seed = (now.Year * 10000) + (now.Month * 100) + now.Day + now.Hour;
return seed;
if (Seed == null)
{
// Keep the randomness per hour instead of per day.
DateTime now = DateTime.UtcNow;
Seed = (now.Year * 10000) + (now.Month * 100) + now.Day + now.Hour;
Console.WriteLine($"Generated seed for random number generator: {Seed}");
}

return Seed.Value;
}

#endregion
Expand Down