home *** CD-ROM | disk | FTP | other *** search
/ Dream 57 / Amiga_Dream_57.iso / Amiga / Jeux / Reflexion / Crafty-15.19.lha / crafty-15.19 / src / history.c < prev    next >
C/C++ Source or Header  |  1998-09-13  |  3KB  |  57 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include "chess.h"
  4. #include "data.h"
  5.  
  6. /* last modified 06/24/98 */
  7. /*
  8. ********************************************************************************
  9. *                                                                              *
  10. *   History() is used to maintain the history database.  this is a set of      *
  11. *   counts, indexed by the 12-bit value [to,from], that contains the relative  *
  12. *   effectiveness of this move as a refutation.  this effectiveness is simply  *
  13. *   an arbitrary value that varies significantly and inversely to the depth of *
  14. *   the sub-tree refuted by each move.                                         *
  15. *                                                                              *
  16. *   these routines also maintain the killer move lists as well, since they are *
  17. *   similar in nature.                                                         *
  18. *                                                                              *
  19. ********************************************************************************
  20. */
  21. void History(TREE *tree, int ply, int depth, int wtm, int move) {
  22.   register int index;
  23. /*
  24.  ----------------------------------------------------------
  25. |                                                          |
  26. |   if the best move so far is a capture or a promotion,   |
  27. |   return, since we try good captures and promotions      |
  28. |   before searching history heuristic moves anyway.       |
  29. |                                                          |
  30.  ----------------------------------------------------------
  31. */
  32.   if (CaptureOrPromote(move)) return;
  33. /*
  34.  ----------------------------------------------------------
  35. |                                                          |
  36. |   otherwise, use the [to,from] as an index and increment |
  37. |   the appropriate history table/entry.                   |
  38. |                                                          |
  39.  ----------------------------------------------------------
  40. */
  41.   index=move & 4095;
  42.   if (wtm) history_w[index]+=depth*depth;
  43.   else history_b[index]+=depth*depth;
  44. /*
  45.  ----------------------------------------------------------
  46. |                                                          |
  47. |   now, add the same move to the current killer moves if  |
  48. |   it is not already there.                               |
  49. |                                                          |
  50.  ----------------------------------------------------------
  51. */
  52.   if (tree->killer_move1[ply] != move) {
  53.     tree->killer_move2[ply]=tree->killer_move1[ply];
  54.     tree->killer_move1[ply]=move;
  55.   }
  56. }
  57.