Random numbers for magics

Code, algorithms, languages, construction...
Post Reply
daz12
Posts: 16
Joined: Wed Feb 25, 2015 7:19 am

Random numbers for magics

Post by daz12 » Sun Sep 27, 2015 11:32 pm

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

hyatt
Posts: 1242
Joined: Thu Jun 10, 2010 2:13 am
Real Name: Bob Hyatt (Robert M. Hyatt)
Location: University of Alabama at Birmingham
Contact:

Re: Random numbers for magics

Post by hyatt » Mon Sep 28, 2015 1:41 am

Are you describing a problem in the sequence your PRNG is producing? If so, I'd immediately try another PRNG...

daz12
Posts: 16
Joined: Wed Feb 25, 2015 7:19 am

Re: Random numbers for magics

Post by daz12 » Mon Sep 28, 2015 8:04 pm

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

hyatt
Posts: 1242
Joined: Thu Jun 10, 2010 2:13 am
Real Name: Bob Hyatt (Robert M. Hyatt)
Location: University of Alabama at Birmingham
Contact:

Re: Random numbers for magics

Post by hyatt » Mon Sep 28, 2015 8:21 pm

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...

daz12
Posts: 16
Joined: Wed Feb 25, 2015 7:19 am

Re: Random numbers for magics

Post by daz12 » Tue Sep 29, 2015 6:50 pm

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

hyatt
Posts: 1242
Joined: Thu Jun 10, 2010 2:13 am
Real Name: Bob Hyatt (Robert M. Hyatt)
Location: University of Alabama at Birmingham
Contact:

Re: Random numbers for magics

Post by hyatt » Wed Sep 30, 2015 2:50 pm

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.

thevinenator
Posts: 68
Joined: Tue Jun 02, 2015 11:02 pm
Real Name: Vince

Re: Random numbers for magics

Post by thevinenator » Fri Oct 02, 2015 6:40 pm

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.
"An Engine's strength flows from the Search. But beware, pruning, extensions, reductions; the dark side of the Search are they. Once you start down the dark path, it will dominate and consume you, as it has to so many developers before.” -- Yoda

hyatt
Posts: 1242
Joined: Thu Jun 10, 2010 2:13 am
Real Name: Bob Hyatt (Robert M. Hyatt)
Location: University of Alabama at Birmingham
Contact:

Re: Random numbers for magics

Post by hyatt » Sat Oct 03, 2015 5:32 am

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...

thevinenator
Posts: 68
Joined: Tue Jun 02, 2015 11:02 pm
Real Name: Vince

Re: Random numbers for magics

Post by thevinenator » Sun Oct 04, 2015 5:20 am

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.
"An Engine's strength flows from the Search. But beware, pruning, extensions, reductions; the dark side of the Search are they. Once you start down the dark path, it will dominate and consume you, as it has to so many developers before.” -- Yoda

Post Reply