0

I am trying to use a specific implementation of the WELL PRNG, supposedly better than the original. link to the code

However I am having some trobles with it. No matter how I seed it, it just outputs the same numbers. I think that I am probably just using it wrong, but have not been able to figure out my mistake. Unfortunately the source of the PRNG is completely opaque to me.

My code:

#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;
}
uLoop
  • 225
  • 1
  • 8
  • 4
    Well if [this](http://www3.ocn.ne.jp/~harase/WELL44497a_new.c) is the code you're using, then `InitWELLRNG44497()` looks like it requires an array of 1391 `int` values, not just one `int*` pointer. Maybe that has something to do with it. – r3mainer Oct 23 '14 at 22:27
  • @squeamish-ossifrage You were bang on! I changed my code to create an array from the input and now it seems to be working. Thanks. If you had posted this as an answer, rather than a comment I would flag it as the answer. – uLoop Oct 23 '14 at 22:43

1 Answers1

1

Based on the comment squeamish-ossifrage I have revised the code. The following code appears to work:

...
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;
...
uLoop
  • 225
  • 1
  • 8