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