home *** CD-ROM | disk | FTP | other *** search
/ Dream 44 / Amiga_Dream_44.iso / RiscPc / jeux / ArcBoard004.arc / !GNUChessX / src / h / ttable < prev    next >
Text File  |  1995-12-07  |  4KB  |  164 lines

  1. /************************* Tuning parameters ****************************/
  2.  
  3. /*
  4.  * ttblsz can be a any size. #undef ttblsz to remove the transposition
  5.  * tables.
  6.  */
  7. #ifndef ttblsz
  8. #if defined(MSDOS) || defined(__arm__) 
  9. #define ttblsz 8001
  10. #else
  11. #define ttblsz 150001
  12. #endif /* MSDOS */
  13. #endif /* ttblsz*/
  14.  
  15. #define MINTTABLE (8000)    /* min ttable size -1 */
  16. #define MAXrehash (7)
  17.  
  18. #if defined MORESTATS
  19. #if !defined HASHSTATS
  20. #define HASHSTATS            /* Enable hash statistics */  
  21. #endif
  22. #endif
  23. #if defined AGING
  24. #define NEWAGE (8)
  25. #endif
  26.  
  27. #ifdef BAREBONES /* Remove all stats for RAW speed */
  28. #undef   HASHSTATS
  29. #endif /* BAREBONES */
  30.  
  31. /************************* Hash table stuf ****************************/
  32. extern /*unsigned*/ SHORT rehash;  /* main.c */ /* -1 is used as a flag --tpm */
  33. extern unsigned long ttblsize; /* main.c */
  34. extern UTSHORT  newage;
  35.  
  36. #ifdef ttblsz
  37. extern void Initialize_ttable (void);
  38. extern void ZeroTTable (int iop); /* iop: 0= clear any, 1= clear agged */
  39. extern int
  40.       ProbeTTable (SHORT side,
  41.     SHORT depth,
  42.     SHORT ply,
  43.     SHORT *alpha,
  44.     SHORT *beta,
  45.     SHORT *scor);
  46. extern int
  47.       PutInTTable (SHORT side,
  48.         SHORT score,
  49.         SHORT depth,
  50.         SHORT ply,
  51.         SHORT alpha,
  52.         SHORT beta,
  53.         UTSHORT mv);
  54. #else
  55. #define Initialize_ttable(void)
  56. #define ZeroTTable(iop)
  57. #define ProbeTTable(side,depth,ply,alpha,beta,score) (false)
  58. #define PutInTTable(side,score,depth,ply,alpha,beta,mv) (false)
  59. #endif /* ttblsz */
  60.  
  61. /************************* Hash File Stuf ****************************/
  62.  
  63. #ifdef HASHFILE
  64. extern FILE *hashfile;  /* search.c: test if hashfile is opened */
  65.  
  66. extern int
  67.       ProbeFTable (SHORT side,
  68.             SHORT depth,
  69.             SHORT ply,
  70.             SHORT *alpha,
  71.             SHORT *beta,
  72.             SHORT *score);
  73. extern void
  74.       PutInFTable (SHORT side,
  75.             SHORT score,
  76.             SHORT depth,
  77.             SHORT ply,
  78.             SHORT alpha,
  79.             SHORT beta,
  80.             UTSHORT f,
  81.             UTSHORT t);
  82.  
  83.  
  84. extern void TestHashFile(void);
  85. extern void CreateHashFile(long sz);
  86. extern void OpenHashFile(void);
  87. extern void CloseHashFile(void);
  88. #else /* Define null ops so we dont need ifdefs */
  89. #define hashfile (NULL)
  90. #define OpenHashFile()
  91. #define CloseHashFile()
  92. #define ProbeFTable(side,depth,ply,alpha,beta,score) (0)
  93. #define PutInFTable(side,score,depth,ply,alpha,beta,f,t)
  94. #endif /* HASHFILE */
  95.  
  96.  
  97. /************************hash code stuff **************************/
  98. struct hashval
  99.   {
  100.      unsigned long key, bd;
  101.   };
  102.  
  103. extern struct hashval hashcode[2][7][64];
  104. extern void InitHashCode(unsigned int seed);
  105.  
  106. /*
  107.  * hashbd contains a 32 bit "signature" of the board position. hashkey
  108.  * contains a 16 bit code used to address the hash table. When a move is
  109.  * made, XOR'ing the hashcode of moved piece on the from and to squares with
  110.  * the hashbd and hashkey values keeps things current.
  111.  */
  112. extern unsigned long hashkey, hashbd;
  113.  
  114. #define UpdateHashbd(side, piece, f, t) \
  115. {\
  116.   if ((f) >= 0)\
  117.     {\
  118.       hashbd ^= hashcode[side][piece][f].bd;\
  119.       hashkey ^= hashcode[side][piece][f].key;\
  120.     }\
  121.   if ((t) >= 0)\
  122.     {\
  123.       hashbd ^= hashcode[side][piece][t].bd;\
  124.       hashkey ^= hashcode[side][piece][t].key;\
  125.     }\
  126. }
  127.  
  128. extern void gsrand (unsigned int);
  129. extern unsigned int urand (void);
  130.  
  131. /************************* Repitition hash table ****************************/
  132.  
  133. extern SHORT rpthash[2][256];
  134. extern void ZeroRPT (void);
  135. #define ProbeRPThash(side,hashkey) (rpthash[side][hashkey & 0xFF] > 0)
  136. #define IncrementRPThash(side,hashkey) {rpthash[side][hashkey & 0xFF]++;}
  137. #define DecrementRPThash(side,hashkey) {rpthash[side][hashkey & 0xFF]--;}
  138.  
  139. /************************* Evaluation cache ********************************/
  140.  
  141. #ifdef CACHE
  142.     struct etable
  143.     { unsigned long ehashbd;
  144.         tshort escore[2];
  145.         tshort sscore[64];
  146.         tshort score;
  147.         tshort hung[2];
  148.     } ;
  149. extern struct etable *etab[2];
  150. extern UTSHORT ETABLE;
  151. #endif
  152.  
  153. /************************* Hash table statistice ****************************/
  154.  
  155. #ifdef HASHSTATS
  156. void ClearHashStats();    /* initialize the stats */
  157. void ShowHashStats();    /* print the stats */
  158. extern long EADD, EGET; /* Evaluation cache stats counters */
  159. extern unsigned long HashCnt, HashAdd, FHashCnt, FHashAdd, HashCol, THashCol;
  160. #else
  161. #define ClearHashStats()        /* stats calls ignored */
  162. #define ShowHashStats()
  163. #endif
  164.