\r
#ifdef WIN32 \r
# include <windows.h>\r
+# define CPUtime 1000.*clock\r
#else\r
# include <sys/time.h>\r
+# include <sys/times.h>\r
+# include <unistd.h>\r
int GetTickCount() // with thanks to Tord\r
{ struct timeval t;\r
gettimeofday(&t, NULL);\r
return t.tv_sec*1000 + t.tv_usec/1000;\r
}\r
+ double CPUtime()\r
+ { // get CPU time used by process, converted to 'MILLICLOCKS'\r
+ struct tms cpuTimes;\r
+ static int cps = 0;\r
+ if(!cps) cps = sysconf(_SC_CLK_TCK);\r
+ times(&cpuTimes);\r
+ return ((double)(cpuTimes.tms_utime + cpuTimes.tms_stime) * CLOCKS_PER_SEC * 1000)/cps;\r
+ }\r
#endif\r
\r
int StartKey;\r
#endif\r
\r
/* make unique integer from engine move representation */\r
-#define PACK_MOVE 256*K + L + (PromPiece << 16);\r
+#define PACK_MOVE 256*K + L + (PromPiece << 16) + (GT<<24);\r
\r
/* convert intger argument back to engine move representation */\r
-#define UNPACK_MOVE(A) K = (A)>>8 & 255; L = (A) & 255; PromPiece = (A)>>16 & 255;\r
+#define UNPACK_MOVE(A) K = (A)>>8 & 255; L = (A) & 255; PromPiece = (A)>>16 & 255; GT = (A)>>24 & 255;\r
\r
/* Global variables visible to engine. Normally they */\r
/* would be replaced by the names under which these */\r
{ /* e=score, z=prev.dest; J,Z=hashkeys; return score*/\r
int j,r,m,v,d,h,i,F,G,P,V,f=J,g=Z,C,s,flag,FF,*ps=sp,kk=S;\r
signed char t,p,u,x,y,X,Y,H,B,gt;\r
- struct _*a=A+(J+(k+S)*E&U-1); /* lookup pos. in hash table*/\r
+ struct _*a=A+(J+(k+S)*E&U); /* lookup pos. in hash table*/\r
*sp++=0;\r
q-=q<e;l-=l<=e; /* adj. window: delay bonus */\r
d=a->D;m=a->V;X=a->F;Y=a->Y; /* resume at stored depth */\r
{\r
int Computer, MaxTime, MaxMoves, TimeInc, sec, i, j;\r
char line[256], command[256], c, cc;\r
- int m, nr;\r
+ int m, nr, hh;\r
+ double cpuT;\r
FILE *f;\r
\r
if(argc>1 && sscanf(argv[1], "%d", &m)==1)\r
/* the game have to be done in this time. */\r
/* If MaxMoves=1 any leftover time is lost*/\r
Ticks = GetTickCount();\r
+ cpuT = CPUtime(); printf("# times @ %u\n", Ticks);\r
m = MovesLeft<=0 ? 40 : MovesLeft;\r
tlim = (0.6-0.06*(BW-8))*(TimeLeft+(m-1)*TimeInc)/(m+7);\r
if(tlim>TimeLeft/15) tlim = TimeLeft/15;\r
Computer = EMPTY;\r
continue;\r
} else UnderProm = -1;\r
+ m = GetTickCount() - Ticks;\r
+ printf("# times @ %u: real=%d cpu=%1.0f\n", m + Ticks, m,\r
+ (CPUtime() - cpuT)/CLOCKS_PER_SEC);\r
printf("move ");\r
printf("%c%c%c%c",'a'+(K&15),'0'+BH-(K>>4),\r
'a'+(L&15),'0'+BH-(L>>4));\r
if(prom)printf("%c",piecename[prom&15]+'a'-1);\r
printf("\n");\r
- m = GetTickCount() - Ticks;\r
\r
/* time-control accounting */\r
TimeLeft -= m;\r
if(sscanf(line+7, "Ini File=%s", filename) == 1) {\r
inifile = filename; continue;\r
}\r
- if(sscanf(line+7, "Clear Hash") == 1) for(i=0; i<U; i++) A->K = 0;\r
+ if(sscanf(line+7, "Clear Hash%c", &c) == 1) for(i=0; i<=U; i++) A->K = 0;\r
if(sscanf(line+7, "MultiVariation Margin=%d", &margin) == 1) continue;\r
if(sscanf(line+7, "Variant fairy selects=%s", selectedFairy+6) == 1) continue;\r
if(sscanf(line+7, "Cambodian Makruk rules=%d", &Cambodian) == 1) continue;\r
GT = (Side == WHITE ? piecetype : blacktype)[line[4]&31];\r
if(GT) PromPiece = (Side == WHITE ? 7 : 7+pm) - GT, GT |= 32 + Side;\r
{char *c=line; K=c[0]-16*c[1]+799;L=c[2]-16*c[3]+799; }\r
- if (m)\r
+ if (m & line[1] != '@')\r
/* doesn't have move syntax */\r
printf("Error (unknown command): %s\n", command);\r
else { int i=-1;\r
if(b[L] && (b[L]&16) == Side && w[b[L]&15] < 0) // capture own King: castling\r
{ i=K; K = L; L = i>L ? i-1 : i+2; }\r
if(w[GT&15] < -1) pl[GT&31]++, J+=89729; // promotion to royal piece\r
- if(b[K]&32) GT = 0; // non-virgin mover => true promotion rather than gating\r
+ if((b[K]&15) < 3) GT = 0; // Pawn => true promotion rather than gating\r
if(D(Side,-I,I,Q,O,LL|S,3)!=I) {\r
/* did have move syntax, but illegal move */\r
printf("Illegal move:%s\n", line);\r