What is the best known speed of move generation?

Discussion of chess software programming and technical issues.

Moderator: Ras

Alessandro Scotti

Re: What is the best known speed of move generation?

Post by Alessandro Scotti »

You don't really need lltoa, you can replace this:

Code: Select all

        lltoa(count, buf, 10);
        printf("perft(%d)=%s (%6.3f sec)\n\n",
              i, buf, t*(1./CLOCKS_PER_SEC));
with this:

Code: Select all

        printf("perft(%d)=%I64d (%6.3f sec)\n\n",
              i, count, t*(1./CLOCKS_PER_SEC));
In C++ "new" is a reserved work but it can be the name of a variable in C (seems to be unused anyway).
Uri Blass
Posts: 10793
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: What is the best known speed of move generation?

Post by Uri Blass »

Alessandro Scotti wrote:You don't really need lltoa, you can replace this:

Code: Select all

        lltoa(count, buf, 10);
        printf("perft(%d)=%s (%6.3f sec)\n\n",
              i, buf, t*(1./CLOCKS_PER_SEC));
with this:

Code: Select all

        printf("perft(%d)=%I64d (%6.3f sec)\n\n",
              i, count, t*(1./CLOCKS_PER_SEC));
In C++ "new" is a reserved work but it can be the name of a variable in C (seems to be unused anyway).
Thanks
Now it compiles for me but I do not know how to use it because if I run it in console mode it simply get no input and exit.

I never use in programming
int main(int argc, char **argv) and I simply always use
int main(void) and if I want to test perft I can type the information in console mode.

I guess that there is some way to give it information in the parameters of main but I do not know how to do it.

I get the following screen when I run it

Usage is: perft <depth> [H<hash size>] [-<split depth>] [<FEN string>]
<hash size> = 20 gives you 2^20 = 1M entries (16MB)
Press any key to continue . . .

Edit:I could use it simply by modifying the code
I still do not know how to use the parameters of main

Uri
Uri Blass
Posts: 10793
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: What is the best known speed of move generation?

Post by Uri Blass »

looking at the code I find no makemove function and it seems that making the move is simply not done as a seperate function but done as part of the perft function.

I think that this is a bad design because it make it harder to change this code to calculate some of perft number on pgn file because in order to do it you need to write additional make move function.

I wonder what was the reason not to have special make move function and if the reason was to make the code faster or a different reason.

Uri
nczempin

Re: What is the best known speed of move generation?

Post by nczempin »

Uri Blass wrote:
Alessandro Scotti wrote:You don't really need lltoa, you can replace this:

Code: Select all

        lltoa(count, buf, 10);
        printf("perft(%d)=%s (%6.3f sec)\n\n",
              i, buf, t*(1./CLOCKS_PER_SEC));
with this:

Code: Select all

        printf("perft(%d)=%I64d (%6.3f sec)\n\n",
              i, count, t*(1./CLOCKS_PER_SEC));
In C++ "new" is a reserved work but it can be the name of a variable in C (seems to be unused anyway).
Thanks
Now it compiles for me but I do not know how to use it because if I run it in console mode it simply get no input and exit.

I never use in programming
int main(int argc, char **argv) and I simply always use
int main(void) and if I want to test perft I can type the information in console mode.

I guess that there is some way to give it information in the parameters of main but I do not know how to do it.

I get the following screen when I run it

Usage is: perft <depth> [H<hash size>] [-<split depth>] [<FEN string>]
<hash size> = 20 gives you 2^20 = 1M entries (16MB)
Press any key to continue . . .

Edit:I could use it simply by modifying the code
I still do not know how to use the parameters of main

Uri
try e. g.:

perft 6

perft 6 "rnb1kbnr/ppppqppp/8/8/8/8/PPPPQPPP/RNB1KBNR w KQkq -"


Make sure you open a "cmd" shell first and then give those commands.
Uri Blass
Posts: 10793
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: What is the best known speed of move generation?

Post by Uri Blass »

nczempin wrote:
Uri Blass wrote:
Alessandro Scotti wrote:You don't really need lltoa, you can replace this:

Code: Select all

        lltoa(count, buf, 10);
        printf("perft(%d)=%s (%6.3f sec)\n\n",
              i, buf, t*(1./CLOCKS_PER_SEC));
with this:

Code: Select all

        printf("perft(%d)=%I64d (%6.3f sec)\n\n",
              i, count, t*(1./CLOCKS_PER_SEC));
In C++ "new" is a reserved work but it can be the name of a variable in C (seems to be unused anyway).
Thanks
Now it compiles for me but I do not know how to use it because if I run it in console mode it simply get no input and exit.

I never use in programming
int main(int argc, char **argv) and I simply always use
int main(void) and if I want to test perft I can type the information in console mode.

I guess that there is some way to give it information in the parameters of main but I do not know how to do it.

I get the following screen when I run it

Usage is: perft <depth> [H<hash size>] [-<split depth>] [<FEN string>]
<hash size> = 20 gives you 2^20 = 1M entries (16MB)
Press any key to continue . . .

Edit:I could use it simply by modifying the code
I still do not know how to use the parameters of main

Uri
try e. g.:

perft 6

perft 6 "rnb1kbnr/ppppqppp/8/8/8/8/PPPPQPPP/RNB1KBNR w KQkq -"


Make sure you open a "cmd" shell first and then give those commands.
I am not sure about the meaning of opening a "cmd" shell.
It is possible that I used it a long time ago but it is certainly not something that I use often and I do not remember what I did except the fact that I had some problem when program that I ran exited immediatly and I got some advice that helped me to see what is the problem by running it in a different way.

Uri
Jacob

Re: What is the best known speed of move generation?

Post by Jacob »

I am not sure about the meaning of opening a "cmd" shell.
It is possible that I used it a long time ago but it is certainly not something that I use often and I do not remember what I did except the fact that I had some problem when program that I ran exited immediatly and I got some advice that helped me to see what is the problem by running it in a different way.

Uri
In Windows, go to: Start Menu -> All Program -> Accessories -> Command Prompt

This will open a console window. Navigate to the executable folder: (i.e., cd c:\)

Then type in the executable name, followed by the arguments: perft 6 "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"

Or you can make a batch file, which makes it easier to change the arguments/etc..

Open notepad and write:

Code: Select all

c:\perft 6 "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
PAUSE
Save it as perft.bat anywhere you'd like, and double-click it to run. (make sure to set the "save as type" to "all files"). Right click and choose "edit" to make changes.
nczempin

Re: What is the best known speed of move generation?

Post by nczempin »

Uri Blass wrote:
nczempin wrote:
try e. g.:

perft 6

perft 6 "rnb1kbnr/ppppqppp/8/8/8/8/PPPPQPPP/RNB1KBNR w KQkq -"


Make sure you open a "cmd" shell first and then give those commands.
I am not sure about the meaning of opening a "cmd" shell.
It is possible that I used it a long time ago but it is certainly not something that I use often and I do not remember what I did except the fact that I had some problem when program that I ran exited immediatly and I got some advice that helped me to see what is the problem by running it in a different way.

Uri
Assuming you have XP: "Start->Run..." then type in "cmd" in that text box.

then you have a windows command shell, and from that you have to navigate to the place where the perft.exe is found. then you can run the perft command with the given parameters

Since you have the source code, you could also hard-code a parameter within the code rather than take it from the command-line parameters. Set depth to some fixed value.

For Run.., see this: http://commandwindows.com/runline.htm
nczempin

Re: What is the best known speed of move generation?

Post by nczempin »

Oh, and for lltoa, you can google for it and find the code on the web, and link that to the perft code.
Uri Blass
Posts: 10793
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: What is the best known speed of move generation?

Post by Uri Blass »

I can add that I will probably not try to use
"cmd" shell.

My idea was to improve the code in order to calculate sum of perft on pgn file and in order to use it I do not need the existing main function and I may use a different main function but after understanding that I cannot use the code as it is for that target I decided not to make an effort to change the code.

If H.G.Muller is interested in writing a better code to help to find bugs in his move generator(I do not know if he has bugs) then I think that he should write a code to calculate sum of perft numbers on pgn file(movei has a special code for that target and it is possible to compare with movei's numbers).

Movei can calculate the sum of perft(3) on pgn file by
writing at console mode perftpgn xxx.pgn 3 when xxx.pgn is a pgn file that is at the same folder as the exe file of movei.

Uri
Gerd Isenberg
Posts: 2251
Joined: Wed Mar 08, 2006 8:47 pm
Location: Hattingen, Germany

Re: What is the best known speed of move generation?

Post by Gerd Isenberg »

hgm wrote:Yes, this is what I meant when I said that the normal rookAttacks would not do, and you would need a 14-bit variety (with 2D magic). You would need a variant that does pay attention to the edge occupancies, and if the entire ray is empty upto and including the edge, does not include it in the attacks set.

Code: Select all

R.B.K..R ->  r = 11110111 (as the B is not in RooksOrQueen)
.RB.K... ->  r = 01110000 (as the edge square is empty)
..B.K... ->  r = 00000000
Ok, i got the idea. Indeed, it seems a very fast approach to determine what is going on on the rays of the king. Since there are up to two opposite directions on each ray, you need to combine the cases which may occur on both directions, eg. a pin from positive direction and a discoverd checker from the negative one and so on. It somehow reminds me on the 64-bit switch of a masked ray, proposed by Dann Corbit some time ago.