Author: Uri Blass
Date: 10:03:03 01/04/03
Go up one level in this thread
On January 04, 2003 at 12:35:33, Robert Hyatt wrote: >On January 04, 2003 at 11:04:02, Russell Reagan wrote: > >>I believe I got rid of all of the bugs in my move generator. I'm not sure >>exactly what the problem was, but I made a few changes to the castling rights in >>some special cases (capturing a rook on its original square, rook moving from >>its original square, and so on) and it seems to work ok now. So I tried the >>following position. >> >>[D]r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 1 >> >>The above position is from "kiwipete" (Peter McKenzie). It has a little bit of >>everything so it's a good position to use for perft. Anyway, I let it run last >>night, and I thought I had switched my perft function to use 64-bit integer for >>the counter, but these are the results I got. >> >>> setboard r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 1 >>> perft 6 >>48 0 >>2039 0 >>97862 0.254 >>4085603 10.295 >>193690690 525.25 >>3736680389 29450.8 >>total time: 29986.6 >> >>Through the first 5 plies it finds the correct values. At ply 6 the value it >>gives is off by a few billion, but the exact value of the difference isn't just >>any old value. It is 4,294,967,296, which is 2^32, which suggests that my >>counter is getting truncated somewhere. >> >>Is it safe to assume my perft function is working correctly (at least in this >>position), and that the counter just wrapped around? >> >>Russell > > >How are you printing the thing? %d will _not_ work with a 64 bit integer. >Microsoft does it one way. If you are using gcc, use %llu to print a 64 bit >counter (assuming it is unsigned which makes sense). I can post my code of the perft function that is not chess related Maybe it can help Russell(the name mone has only significance in hebrew and not in english and I could also do better in choosing significant varaibles but the function is short and can work for legal move generator in every game and not only for chess. I use a function to translate int64 to string based on suggestion that I got here in the past. My perft(depth) practically calculates perft(depth+1) so I need to calculate perft(depth-1) in order to get what is considered to be perft(depth). static void Uint64ToString (__int64 x, char *s) { unsigned int a = (unsigned int)(x/1000000000),b = (unsigned int)(x%1000000000); if (x>1000000000) sprintf(s,"%u%09u",a,b); else sprintf(s,"%u",b); } __int64 perft(int depth) { int numplies; __int64 mone,p; int a[20]; int diff[20]; int i; mone=0; p=0; pinnumber[0]=pinnumber[ply]; ply=0; generatepinarray(); gen(); memset(a,0,sizeof a); diff[0]=first_move[1]-first_move[0]; if (depth==0) return diff[0]; mone=0; while (a[0]<diff[0]) { for (numplies=ply;numplies<depth;numplies++) { if (a[ply]==0) gen(); diff[ply]=first_move[ply+1]-first_move[ply]; if (diff[ply]>0) makemove(gen_dat[first_move[ply]+a[ply]].m.b); else numplies=100; } if (numplies<100) gen(); diff[ply]=first_move[ply+1]-first_move[ply]; mone=mone+diff[ply]; undomove(); while ((a[ply]==diff[ply]-1)&&(ply>0)) undomove(); a[ply]++; i=ply+1; while (i<depth) { a[i]=0; i++; } } return mone; } For priniting what is considered to be perft(i) I have in another function the following commands char perftnum[128]; Uint64ToString(perft(i-1),perftnum); Uri
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.