I have two separate functions that each generate a random number from the same range (1-5). Unfortunately, ~90% of the time they generate the same number. I know that within a single function you solve that problem by re-using the same Random
object because it's happening so quickly that the system clock has yet to really change and seed a different "random" value, but when it's spread across more than one function what is the best approach to resolving this? The whole process takes about a full second to complete and these functions are not called back-to-back, so surely (I would think) the clock has ticked in between them, but is that not true?
I have some ideas for how to generate the numbers using an algorithm instead of just Random
but they would be more taxing and I feel there's a simpler solution.
Edit: Can the people who downvoted please explain? I'd be happy to improve the question based on your suggestions.