home *** CD-ROM | disk | FTP | other *** search
/ Más de 2,500 Juegos / CD1.iso / ZIPDAT / 0153 / 0153.ZIP / SRC / TTABLE.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-23  |  4.2 KB  |  156 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) 
  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 *score);
  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();
  85. extern void CreateHashFile(long sz);
  86. extern void OpenHashFile();
  87. extern void CloseHashFile();
  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, sq) \
  115. {\
  116.       hashbd ^= hashcode[side][piece][sq].bd;\
  117.       hashkey ^= hashcode[side][piece][sq].key;\
  118. }
  119.  
  120. extern void gsrand (unsigned int);
  121. extern unsigned int urand (void);
  122.  
  123. /************************* Repitition hash table ****************************/
  124.  
  125. extern SHORT rpthash[2][256];
  126. extern void ZeroRPT (void);
  127. #define ProbeRPThash(side,hashkey) (rpthash[side][hashkey & 0xFF] > 0)
  128. #define IncrementRPThash(side,hashkey) {rpthash[side][hashkey & 0xFF]++;}
  129. #define DecrementRPThash(side,hashkey) {rpthash[side][hashkey & 0xFF]--;}
  130.  
  131. /************************* Evaluation cache ********************************/
  132.  
  133. #ifdef CACHE
  134.    struct etable
  135.    { unsigned long ehashbd;
  136.       tshort escore[2];
  137.       tshort sscore[64];
  138.       tshort score;
  139.       tshort hung[2];
  140.    } ;
  141. extern struct etable *etab[2];
  142. extern UTSHORT ETABLE;
  143. #endif
  144.  
  145. /************************* Hash table statistice ****************************/
  146.  
  147. #ifdef HASHSTATS
  148. void ClearHashStats();  /* initialize the stats */
  149. void ShowHashStats();   /* print the stats */
  150. extern long EADD, EGET; /* Evaluation cache stats counters */
  151. extern unsigned long HashCnt, HashAdd, FHashCnt, FHashAdd, HashCol, THashCol;
  152. #else
  153. #define ClearHashStats()      /* stats calls ignored */
  154. #define ShowHashStats()
  155. #endif
  156.