井PRNG不工作?(也许)

WELL PRNG not working?(maybe)

本文关键字:也许 工作 PRNG      更新时间:2023-10-16

我正在尝试使用WELL PRNG的特定实现,据说比原来的更好。链接到代码

然而,我有一些宝藏。无论我如何播种,它都会输出相同的数字。我想我可能只是用错了,但还没能找出我的错误。不幸的是,PRNG的来源对我来说完全不透明

我的代码:

#include <iostream>
#include <WELL44497a_new.h>
void pause()
{
    std::string dummy;
    std::cout << "Press enter to continue...";
    std::getline(std::cin, dummy);
}
int main(int argc, char** argv) {
    using std::cout;
    using std::cin;
    using std::endl;
    cout<<"Hello"<<endl;
    pause();
    unsigned int rngseed;
    cout<<"Input RNG seed:";
    cin>>rngseed;
    cout<<"The RNG seed is:";
    cout<<rngseed<<endl;
    pause();
    InitWELLRNG44497(&rngseed);
    int i=1;
    for (i;i<100;i++){
        unsigned long rngtest=WELLRNG44497();
        cout<<rngtest<<endl;
    }
    pause();
    return 0;
}

根据评论我修改了代码。以下代码似乎有效:

...
cin>>rngseed;
cout<<"The RNG seed is:";
cout<<rngseed<<endl;
pause();
unsigned int rngseed_arr[1391];
int i=0;
for (i;i<1391;i++){
    rngseed_arr[i]=rngseed+i;
}
InitWELLRNG44497(rngseed_arr);
i=1;
...