home *** CD-ROM | disk | FTP | other *** search
/ PC-Online 1996 May / PCOnline_05_1996.bin / linux / source / xap / gchess / patch74.01 < prev    next >
Text File  |  1995-10-10  |  10KB  |  374 lines

  1. *** ../src/eval.c    Sat Feb 11 05:54:43 1995
  2. --- eval.c    Mon Mar  6 13:50:07 1995
  3. ***************
  4. *** 1574,1580 ****
  5.                   pp = false;
  6.                   break;
  7.                   }
  8. !               z = (pp ? i - ((row (i) == 6) ? 8 : 16) : i);
  9.                 Pd += ((pp) ? 5 * taxicab (sq, z) : taxicab (sq, z));
  10.             }
  11.           }
  12. --- 1574,1580 ----
  13.                   pp = false;
  14.                   break;
  15.                   }
  16. !               z = (pp ? i - ((row (i) == 1) ? 8 : 16) : i);
  17.                 Pd += ((pp) ? 5 * taxicab (sq, z) : taxicab (sq, z));
  18.             }
  19.           }
  20. *** ../src/search.c    Wed Feb 22 08:46:50 1995
  21. --- search.c    Sat Mar  4 09:41:41 1995
  22. ***************
  23. *** 269,275 ****
  24.             /* calculate avg time per move remaining */
  25.   
  26.             ResponseTime = TimeControl.clock[side] / TimeControl.moves[side];
  27. !           ResponseTime += TCadd * 3 / 4;
  28.             TCleft = (int) ResponseTime / 5;
  29.             if (TimeControl.moves[side] < 5)
  30.           TCcount = MAXTCCOUNTX - 10;
  31. --- 269,276 ----
  32.             /* calculate avg time per move remaining */
  33.   
  34.             ResponseTime = TimeControl.clock[side] / TimeControl.moves[side];
  35. !           ResponseTime = ResponseTime * 2 / 3;
  36. !           ResponseTime += TCadd / 2;
  37.             TCleft = (int) ResponseTime / 5;
  38.             if (TimeControl.moves[side] < 5)
  39.           TCcount = MAXTCCOUNTX - 10;
  40. ***************
  41. *** 1245,1251 ****
  42.   #endif
  43.             ElapsedTime (2);
  44.             TCcount++;
  45. -           if (et > ResponseTime) flag.timeout = true;
  46.             if (!background && Sdepth > 2)
  47.           {
  48.             if (best < alpha)
  49. --- 1246,1251 ----
  50. *** ../src/ttable.c    Sun Feb  5 14:47:31 1995
  51. --- ttable.c    Sat Mar 25 13:55:05 1995
  52. ***************
  53. *** 21,27 ****
  54.   struct hashentry *ttable[2];
  55.   
  56.   unsigned long ttblsize;
  57. ! /* unsigned */ SHORT rehash;  /* -1 is used as a flag --tpm */
  58.   #ifdef NEWAGE
  59.           utshort TTage;        /* Current ttable age */
  60.           UTSHORT TTageClock,    /* Count till next age tick */
  61. --- 21,27 ----
  62.   struct hashentry *ttable[2];
  63.   
  64.   unsigned long ttblsize;
  65. ! SHORT rehash;  /* -1 is used as a flag --tpm */
  66.   #ifdef NEWAGE
  67.           utshort TTage;        /* Current ttable age */
  68.           UTSHORT TTageClock,    /* Count till next age tick */
  69. ***************
  70. *** 98,177 ****
  71.    */
  72.   
  73.   {
  74. !   register struct hashentry *ptbl;
  75. !   register /*unsigned*/ SHORT i = 0;    /*to match new type of rehash --tpm*/
  76.   
  77.   #ifdef DEBUG
  78. !     if(flag.nott)return false;
  79.   #endif
  80.   #ifdef HASHSTATS
  81. !     ttprobe[depth]++;
  82.   #endif
  83. !  ptbl = &ttable[side][hashkey % ttblsize];
  84. !   while (true)
  85. !     {
  86. !       if (ptbl->depth == 0) return false;
  87. !       if (ptbl->hashbd == hashbd) break;
  88. !       if (++i > rehash) return false;
  89. !       ptbl++;
  90. !     }
  91.   
  92.       PV = SwagHt = ptbl->mv;
  93. !   if ((ptbl->depth >= (SHORT) depth) || abs(ptbl->score)>9000)
  94. !     {
  95.   #ifdef HASHTEST
  96. !       for (i = 0; i < 32; i++)
  97. !     {
  98. !       if (ptbl->bd[i] != CB (i))
  99.           {
  100.   #ifdef HASHSTATS
  101. !           HashCol++;
  102. !           ShowMessage (CP[199]);    /*ttable collision detected*/
  103.   #endif
  104. !           break;
  105.           }
  106. -     }
  107.   #endif /* HASHTEST */
  108.   
  109.   #ifdef HASHSTATS
  110. !     ttdepthout[ptbl->depth]++;
  111. !     HashCnt++;
  112.   #endif
  113.   
  114. ! #ifdef NEWAGE
  115. !         /* Find entry within rehash window or return failure */
  116. !          for (i=rehash, ptbl = &ttable[side][hashkey % ttblsize];
  117. !                   ptbl->hashbd != hashbd; ptbl++)
  118. !           if (--i == 0) return false;
  119. !         /* Update age of rediscovered node */
  120. !           ptbl->age = TTage - TTdepthage[ptbl->depth];
  121. ! #endif
  122. !       if (ptbl->flags & truescore)
  123. !     {
  124. !       *score = ptbl->score;
  125. !       /* adjust *score so moves to mate is from root */
  126. !       if (*score > 9000) *score -= ply;
  127. !       else if (*score < -9000) *score += ply;
  128. !       *beta = -20000;
  129. !     }
  130. !       else if (ptbl->flags & lowerbound)
  131. !     {
  132. !       if (ptbl->score > *alpha)
  133.   #ifdef notdef
  134. !         *alpha = ptbl->score - 1;
  135.   #endif
  136. !         *alpha = ptbl->score;
  137. !     }
  138.   #ifdef DEBUG
  139. !     if (debuglevel & 32)
  140. !       {
  141.           algbr (PV >> 8, PV & 0xff, 0);
  142.           printf ("-get-> h=%lx d=%d s=%d p=%d a=%d b=%d %s\n", hashbd, depth, *score, ply, *alpha, *beta, mvstr);
  143. !       }
  144.   #endif
  145. !       return (true);
  146. !     }
  147. !   return (false);
  148.   }
  149.   
  150.   inline
  151. --- 98,178 ----
  152.    */
  153.   
  154.   {
  155. !     register struct hashentry *ptbl;
  156. !     register SHORT i = 0;
  157.   
  158.   #ifdef DEBUG
  159. !     if(flag.nott)return false;
  160.   #endif
  161.   #ifdef HASHSTATS
  162. !     ttprobe[depth]++;
  163.   #endif
  164. ! #ifdef NEWAGE
  165. !       /* Find entry within rehash window or return failure */
  166. !       for (i=rehash, ptbl = &ttable[side][hashkey % ttblsize];
  167. !            ptbl->hashbd != hashbd; ptbl++)
  168. !         if (--i == 0) return false;
  169. !       /* Update age of rediscovered node */
  170. !           ptbl->age = TTage - TTdepthage[ptbl->depth];
  171. ! #else
  172. !     ptbl = &ttable[side][hashkey % ttblsize];
  173. !     while (true)
  174. !       {
  175. !       if (ptbl->depth == 0) return false;
  176. !       if (ptbl->hashbd == hashbd) break;
  177. !       if (++i > rehash) return false;
  178. !       ptbl++;
  179. !       }
  180. ! #endif
  181.   
  182.       PV = SwagHt = ptbl->mv;
  183. !     if ((ptbl->depth >= (SHORT) depth) || abs(ptbl->score)>9000)
  184. !       {
  185.   #ifdef HASHTEST
  186. !       for (i = 0; i < 32; i++)
  187.           {
  188. +         if (ptbl->bd[i] != CB (i))
  189. +           {
  190.   #ifdef HASHSTATS
  191. !               HashCol++;
  192. !               ShowMessage (CP[199]); /*ttable collision detected*/
  193.   #endif
  194. !               break;
  195. !           }
  196.           }
  197.   #endif /* HASHTEST */
  198.   
  199.   #ifdef HASHSTATS
  200. !       ttdepthout[ptbl->depth]++;
  201. !       HashCnt++;
  202.   #endif
  203.   
  204. !       if (ptbl->flags & truescore)
  205. !         {
  206. !         *score = ptbl->score;
  207. !         /* adjust *score so moves to mate is from root */
  208. !         if (*score > 9000) *score -= ply;
  209. !         else if (*score < -9000) *score += ply;
  210. !         *beta = -20000;
  211. !         }
  212. !       else if (ptbl->flags & lowerbound)
  213. !         {
  214. !         if (ptbl->score > *alpha)
  215.   #ifdef notdef
  216. !           *alpha = ptbl->score - 1;
  217.   #endif
  218. !         *alpha = ptbl->score;
  219. !         }
  220.   #ifdef DEBUG
  221. !       if (debuglevel & 32)
  222. !         {
  223.           algbr (PV >> 8, PV & 0xff, 0);
  224.           printf ("-get-> h=%lx d=%d s=%d p=%d a=%d b=%d %s\n", hashbd, depth, *score, ply, *alpha, *beta, mvstr);
  225. !         }
  226.   #endif
  227. !       return (true);
  228. !       }
  229. !     return (false);
  230.   }
  231.   
  232.   inline
  233. ***************
  234. *** 191,207 ****
  235.   
  236.     {
  237.       register struct hashentry *ptbl;
  238. !     register /*unsigned*/ SHORT i = 0;    /*to match new type of rehash --tpm*/
  239.   
  240.       ptbl = &ttable[side][hashkey % ttblsize];
  241.       while (true)
  242.         {
  243. !         if (ptbl->depth == 0 
  244. ! #ifdef NEWAGE
  245. !             || TTage - ptbl->age > newage
  246. ! #endif
  247. !             ) break;
  248. !         if((ptbl->hashbd) == hashbd)if(ptbl->depth > (UCHAR)depth)return false; else break;
  249.           if (++i > rehash)
  250.             {
  251.   #ifdef HASHSTATS
  252. --- 192,207 ----
  253.   
  254.     {
  255.       register struct hashentry *ptbl;
  256. !     register SHORT i = 0;
  257. ! #ifndef NEWAGE
  258.   
  259.       ptbl = &ttable[side][hashkey % ttblsize];
  260.       while (true)
  261.         {
  262. !         if (ptbl->depth == 0) break;
  263. !         if ((ptbl->hashbd) == hashbd) {
  264. !             if (ptbl->depth > (UCHAR)depth) return false; else break;
  265. !         }
  266.           if (++i > rehash)
  267.             {
  268.   #ifdef HASHSTATS
  269. ***************
  270. *** 213,249 ****
  271.             }
  272.           ptbl++;
  273.         }
  274. ! #ifdef NEWAGE
  275. !     {
  276.           /* Look for match or oldest entry to reuse */
  277. !         int i;
  278. !         SHORT old = 0;
  279. !         struct hashentry * oldest = (struct hashentry *)NULL;
  280. !         for (i=rehash, ptbl = &ttable[side][hashkey % ttblsize];
  281. !                 i > 0 && ptbl->hashbd != hashbd; i--, ptbl++)
  282. !             if ((TTage - ptbl->age) > old)
  283. !               {  
  284. !                 old = TTage - ptbl->age;
  285. !                 oldest = ptbl;
  286. !               }  
  287. !         if (i == 0)
  288. !           {
  289.               ptbl = oldest; /* reuse oldest entry */
  290. !             if (--TTageClock == 0)
  291. !               {
  292.                   TTageClock = TTageRate;
  293.                   TTage++;        /* Everyone is now just a little older */
  294. !               }
  295. !           }
  296. !         ptbl->age = TTage - TTdepthage[ptbl->depth]; /* Set age of this node */
  297.       }
  298. ! #else
  299. !     TTadd++;
  300. ! #endif
  301.   #ifdef HASHSTATS
  302.       HashAdd++;
  303.   #endif
  304. -     if(ptbl->depth > (UCHAR)depth) return false;
  305.       ptbl->hashbd = hashbd;
  306.       ptbl->depth = (UCHAR) depth;
  307.       ptbl->score = score;
  308. --- 213,257 ----
  309.             }
  310.           ptbl++;
  311.         }
  312. !     TTadd++;
  313. !     if (ptbl->depth > (UCHAR)depth) return false;
  314. ! #else /* NEWAGE */
  315. !     utshort old;
  316. !         struct hashentry *oldest;
  317.           /* Look for match or oldest entry to reuse */
  318. !     /* Note that arithmetic on ages is intentionally modulo 65536 */
  319. !         i = rehash;
  320. !     oldest = ptbl = &ttable[side][hashkey % ttblsize];
  321. !         old = TTage - ptbl->age;
  322. !     while (ptbl->hashbd != hashbd) {
  323. !         if (--i == 0) break;
  324. !         ptbl++;
  325. !         if ((TTage - ptbl->age) > old) {
  326. !         old = TTage - ptbl->age;
  327. !         oldest = ptbl;
  328. !         }
  329. !     }
  330. !         if (i == 0) {
  331.               ptbl = oldest; /* reuse oldest entry */
  332. ! #ifdef HASHSTATS
  333. !         THashCol++;
  334. ! #endif
  335. !             if (--TTageClock == 0) {
  336.                   TTageClock = TTageRate;
  337.                   TTage++;        /* Everyone is now just a little older */
  338. !         }
  339. !     } else {
  340. ! /*!!!        if (ptbl->depth > (UCHAR)depth) return false;*/
  341.       }
  342. ! /*!!!*/        if (ptbl->depth > (UCHAR)depth) return false;
  343. !         ptbl->age = TTage - TTdepthage[depth]; /* Set age of this node */
  344. ! #endif /* NEWAGE */
  345.   #ifdef HASHSTATS
  346.       HashAdd++;
  347.   #endif
  348.       ptbl->hashbd = hashbd;
  349.       ptbl->depth = (UCHAR) depth;
  350.       ptbl->score = score;
  351. ***************
  352. *** 290,296 ****
  353.         {
  354.           TTageClock = TTageRate;
  355.           TTage = newage+1; /* Zero entries are pre-expired. */
  356. -         TTageRate = ttblsize/(newage/2); /* Average 1/2 of table will be expired */
  357.           /* zero the age of all ttable entries */
  358.           memset(ttable[white],0,sizeof(struct hashentry)*(unsigned)(ttblsize+rehash));
  359.           memset(ttable[black],0,sizeof(struct hashentry)*(unsigned)(ttblsize+rehash));
  360. --- 298,303 ----
  361. ***************
  362. *** 824,827 ****
  363. --- 831,837 ----
  364.   #endif
  365.             }
  366.     }
  367.   
  368.