Hi all,
Anyone have a preference between the Mersenne twister, KISS, or some other PRNG?
Thanks
Dan H.
MT or KISS ?
Moderators: hgm, Rebel, chrisw
-
- Posts: 5258
- Joined: Mon Feb 27, 2006 4:31 pm
- Location: Atlanta, Georgia
-
- Posts: 1822
- Joined: Thu Mar 09, 2006 11:54 pm
- Location: The Netherlands
Re: MT or KISS ?
Where do you need it for and how many numbers do you want it to generate?Dan Honeycutt wrote:Hi all,
Anyone have a preference between the Mersenne twister, KISS, or some other PRNG?
Thanks
Dan H.
-
- Posts: 20943
- Joined: Mon Feb 27, 2006 7:30 pm
- Location: Birmingham, AL
Re: MT or KISS ?
I think all work well for chess. You don't need that many numbers so cycling is not an issue...Dan Honeycutt wrote:Hi all,
Anyone have a preference between the Mersenne twister, KISS, or some other PRNG?
Thanks
Dan H.
-
- Posts: 5258
- Joined: Mon Feb 27, 2006 4:31 pm
- Location: Atlanta, Georgia
Re: MT or KISS ?
For hashing. only about a thousand values.diep wrote:Where do you need it for and how many numbers do you want it to generate?
Best
Dan H.
-
- Posts: 6401
- Joined: Thu Mar 09, 2006 8:30 pm
- Location: Chicago, Illinois, USA
Re: MT or KISS ?
After trying different things, I settled for hardwiring them with numbers from here http://www.random.org/Dan Honeycutt wrote:For hashing. only about a thousand values.diep wrote:Where do you need it for and how many numbers do you want it to generate?
Best
Dan H.
Miguel
-
- Posts: 5258
- Joined: Mon Feb 27, 2006 4:31 pm
- Location: Atlanta, Georgia
Re: MT or KISS ?
Hi Miguel,michiguel wrote:After trying different things, I settled for hardwiring them with numbers from here http://www.random.org/Dan Honeycutt wrote:For hashing. only about a thousand values.diep wrote:Where do you need it for and how many numbers do you want it to generate?
Best
Dan H.
Miguel
Can you elaborate a bit on "After trying different things"? With my C engines (Simon and Bruja) I do the same thing. I'm presently working on a Java engine which I'd like to keep fairly streamlined. Thus I'm looking to replace several pages of 0xblah, blah blah random numbers with a few lines of code: my_prng()
It is my opinion, based solely on gut feel rather than on any basis in probability and statistics, that hashing with numbers generated with a good prng are going to suffer no more than one in a zillion more collisions than hashing with true random numbers. However, I'm entirely open to contrary opinions, especially from someone with some math to back up what they say.
Best
Dan H.
-
- Posts: 6401
- Joined: Thu Mar 09, 2006 8:30 pm
- Location: Chicago, Illinois, USA
Re: MT or KISS ?
I tried a couple of public domain generators from the net. I don't remember now, but I can dig it from the old source code. Anyway, I do not think they were anything special.Dan Honeycutt wrote:Hi Miguel,michiguel wrote:After trying different things, I settled for hardwiring them with numbers from here http://www.random.org/Dan Honeycutt wrote:For hashing. only about a thousand values.diep wrote:Where do you need it for and how many numbers do you want it to generate?
Best
Dan H.
Miguel
Can you elaborate a bit on "After trying different things"? With my C engines (Simon and Bruja) I do the same thing. I'm presently working on a Java engine which I'd like to keep fairly streamlined. Thus I'm looking to replace several pages of 0xblah, blah blah random numbers with a few lines of code: my_prng()
It is my opinion, based solely on gut feel rather than on any basis in probability and statistics, that hashing with numbers generated with a good prng are going to suffer no more than one in a zillion more collisions than hashing with true random numbers. However, I'm entirely open to contrary opinions, especially from someone with some math to back up what they say.
Best
Dan H.
I agree that there should be any difference in strength. I think this is all a matter of taste.
Miguel
-
- Posts: 5258
- Joined: Mon Feb 27, 2006 4:31 pm
- Location: Atlanta, Georgia
Re: MT or KISS ?
Okay. Thanks for your input.michiguel wrote:I think this is all a matter of taste.
Miguel
Best
Dan H.
-
- Posts: 1822
- Joined: Thu Mar 09, 2006 11:54 pm
- Location: The Netherlands
Re: MT or KISS ?
Really lots will work. Just make sure it generates 64 bits numbers and not 32 bits. The standard tests used for RNG's to see them as being ok are more than sufficient for Zobrist.diep wrote:Where do you need it for and how many numbers do you want it to generate?Dan Honeycutt wrote:Hi all,
Anyone have a preference between the Mersenne twister, KISS, or some other PRNG?
Thanks
Dan H.
If you don't want to research all that,
the cheapest safe idea is always to store it in an array in hex and then modify something by hand at 4 AM using the overwrite and write a 0 here and a 1 there an a 'f' somewhere else and do that for all 16 characters.
-
- Posts: 481
- Joined: Thu Apr 16, 2009 12:00 pm
- Location: Slovakia, EU
Re: MT or KISS ?
This is what Critter uses:
PS. "Key" is a typedef for "uint64_t"
Code: Select all
const unsigned int rnd_seed[55] = {
0x5414d5f4, 0xb3935330, 0xd0773e27, 0xac62a182,
0x5db20c92, 0xc1e618ac, 0xd003926a, 0x171fa3b3,
0x9ad12101, 0x762172c1, 0xbc5d9dc3, 0x07b72a70,
0x6e5ac890, 0xf7be54d1, 0x0d6332fa, 0x56ba8fbe,
0xeba585ec, 0x571421c5, 0x96b3c079, 0x12eb9b92,
0xc07c0978, 0x0700c5bd, 0x31a43513, 0x74eba4aa,
0x4ec55db5, 0x2c91c2e9, 0x208771f6, 0x304ee204,
0x1e004673, 0xf3ac22f9, 0xa8561feb, 0xded13435,
0xd03e7513, 0xdae66bc2, 0x01c20be1, 0x46638997,
0xfb26ce62, 0x01f87fc3, 0xc0016099, 0x44429270,
0xb04f4481, 0xf31b8ad7, 0x86dd7a46, 0x03e72091,
0x96a22589, 0x74dcb7d4, 0x12d0fc03, 0x474a16e8,
0x2ff5717c, 0x54bded92, 0x783a9487, 0xe767978c,
0x3052d5cd, 0x16eca191, 0x8eaf6d15
};
static unsigned int rnd_tab[55];
static int rnd_j, rnd_k;
void init_random() {
for (int i = 0; i < 55; i++)
rnd_tab[i] = rnd_seed[i];
rnd_j = 23;
rnd_k = 54;
}
unsigned int random32() {
unsigned int rnd = (rnd_tab[rnd_k] += rnd_tab[rnd_j]);
if (--rnd_j < 0) rnd_j = 54;
if (--rnd_k < 0) rnd_k = 54;
return rnd;
}
Key random64() {
Key a = random32(), b = random32();
return (a << 32 | b);
}