home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 5 / ctrom5b.zip / ctrom5b / OS2 / SPEL / UCHESS / UCHESSRC / TTABLE.H < prev    next >
C/C++ Source or Header  |  1994-09-22  |  5KB  |  164 lines

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