When try to use random number generator it is not enough random. Especially after server restart you get same numbers (integers). For me it looks like it depend on server uptime.
Also another problem, when more mods try to change seed for random numbers by Math.Randomizer, it will break random number generator totally.
Description
Details
- Severity
- Tweak
- Resolution
- Open
- Reproducibility
- Always
- Operating System
- Windows 7
- Category
- General
Event Timeline
Math.Randomize(-1); int index = Math.RandomInt(0, 100) % 2;
Or reference external methods over HTTP
Math.Randomize is working as expected, the randomizer is relying on progressed game time, you can re-feed that value and make a more complex formula to get better sudo random values.
int val = TickCount(0); val = val + (val << 37); val = Math.AbsInt(val); val = val % 50;
This solution is also viable and good for loading screen randomizers
Problem is also GetRandomElement() from array...
I prefer fix internal methods instead creating some workarounds.
What's wrong with using GetHourMinuteSecondUTC and GetYearMonthDay?
It just seems like your specific use case requires the randomizer to give you an actually random number.
when more mods try to change seed, it will break random number generator totally.
Example?
@GlutenFreeVapes The issue is that when the server just inits, the random values will always be the same because the game seems to use the in game time internally to generate the pseudorandom values. Even using what you said as seed will be of little use because we usually do scheduled server restarts so the time could end up being the same.
At least TickCount relies on the fact your PC is running different processes in the background. I'm sure the randomness would be different enough for smaller numbers even on a fresh PC with identical specs, even if its on something very early on like a loading screen