Page 1 of 1

Random numbers for magics

Posted: Sun Sep 27, 2015 11:32 pm
by daz12
I'm having problems with random numbers with respect to magics. My code in C# starts well but after a while a I just keep getting duplicate 'magic candidate' numbers generated by my instance of random. Anybody had similar experience and if so how did you overcome it? How difficult is it to actually find magics for rooks?

The largest no of unique indexes I've obtained is about 400 (target 2048 for rook on C1 square) before a duplicate appears.

Thanks

Daz

Re: Random numbers for magics

Posted: Mon Sep 28, 2015 1:41 am
by hyatt
Are you describing a problem in the sequence your PRNG is producing? If so, I'd immediately try another PRNG...

Re: Random numbers for magics

Posted: Mon Sep 28, 2015 8:04 pm
by daz12
I tried a large array of random instances, which produces candidate magics for a while but even that approach starts producing duplicate random numbers every time after a while. Does this happen in Java, C etc?

Daz

Re: Random numbers for magics

Posted: Mon Sep 28, 2015 8:21 pm
by hyatt
Not with a good PRNG. You obviously want a 64 bit PRNG and they rarely run into this kind of short-cycle stuff, which is what it sounds like you are describing (i.e. the PRNG keeps producing the same number, or the same fairly short sequence of numbers, over and over. Some C's have a 16 bit PRNG that is hopeless since there are only 65536 possible random values...

Re: Random numbers for magics

Posted: Tue Sep 29, 2015 6:50 pm
by daz12
How long can it take to find a magic? I reckon I've tried a few hundred thousand randoms so far and still no luck! Someone told me they went through millions until they found magic numbers.

Daz

Re: Random numbers for magics

Posted: Wed Sep 30, 2015 2:50 pm
by hyatt
Some have gone through tens of billions. Out of 2^64 that is a small fraction. :) You'd have to try 'em all to find the best possible case.

Re: Random numbers for magics

Posted: Fri Oct 02, 2015 6:40 pm
by thevinenator
how good are the random numbers used for the Polyglot opening book hash?

i've been using those numbers in my program mainly so i don't have to duplicate effort. any position hash can immediately be used to access a polyglot opening book.

Re: Random numbers for magics

Posted: Sat Oct 03, 2015 5:32 am
by hyatt
Question is, how many of those are there? Does polyglot have a static array of random values or does it generate them on the fly???

If it has a static array, that won't be enough...

Re: Random numbers for magics

Posted: Sun Oct 04, 2015 5:20 am
by thevinenator
what do you mean by "that won't be enough".

oh, i think i slightly changed the topic. i'm not using bitmaps, my move generator is based on a board of 64 using pre-calculated arrays for move generation., so i'm only using the hash for TT.