1D Noise using Mersenne twister giving different results on different devices

强颜欢笑 提交于 2019-12-13 19:16:34

问题


I'm generating 2D terrain with 1D perlin noise using Mersenne Twister to for random numbers. My first thought was using Mersenne Twister will give me always the same results with same seed on any given hardware. But when I compare the values/terrain on different devices it gives me different results. (It worked for IOS, OSX and MAC, but not for WP8).

Code:

class 1DNoiseTest
{
    typedef std::mt19937 MyRNG;
    MyRNG rng;
1DNoiseTest( unsigned seed )
    {
        rng.seed(seed);
        std::uniform_real_distribution<double> distribution(0.0,1.0);
        for ( unsigned i = 0; i < kMaxVertices; ++i )
        {
            r[ i ] = ( distribution(rng)); error
        }
    }

...

Am I misunderstanding Mersenne Twister or am I doing something wrong? How could I get the same terrain/values on every device/hardware?

Thanks for your time!


回答1:


See this question:

C++11 cross compiler/standard library random distribution reproducibility

std::uniform_real_distribution is not guaranteed to give same results across different compilers.



来源:https://stackoverflow.com/questions/30176669/1d-noise-using-mersenne-twister-giving-different-results-on-different-devices

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!