문제

I need to send an identical sequence of random numbers to a distributed network of applications.

Since such sequence might be quite long, I was thinking about sending just a (randomly generated) centralized seed initialization number and the length of the desired sequence.

Given that every component on the receiving hand will use the same .NET version, would that be a viable solution to have identical random data generated on all of my nodes?

도움이 되었습니까?

해결책

You should be able to distribute a seed for Random(int seed) and recreate the same sequence assuming that you are using the same version of .NET in all environments.

Remarks on System.Random @ MSDN

Notes to Callers The implementation of the random number generator in the Random class is not guaranteed to remain the same across major versions of the .NET Framework. As a result, your application code should not assume that the same seed will result in the same pseudo-random sequence in different versions of the .NET Framework.

If you can see a case where the framework version will change, or if you may need to recreate an old sequence after you've started using a new version, you'll want to create your own random implementation.

See the answers of this question for pointers: Crossplatform random number generator

다른 팁

You can use the Random class with a seed or use a service oriented architecture.

Random when initialized with a seed will produce an identical sequence.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top