我正在尝试使用 WELL PRNG 的特定实现,据说比原来的更好。 link to the code
但是我遇到了一些麻烦。无论我如何播种,它都只会输出相同的数字。我想我可能只是用错了,但一直没能弄清楚我的错误。不幸的是,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;
}
最佳答案
根据评论 squeamish-ossifrage 我修改了代码。以下代码似乎有效:
...
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;
...
关于c++ - WELL PRNG 不工作?(也许),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26538416/