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

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include "chess.h"
  4. #include "data.h"
  5.  
  6. /* last modified 06/05/98 */
  7. /*
  8. ********************************************************************************
  9. *                                                                              *
  10. *   Drawn() is used to answer the question "is this position a hopeless draw?" *
  11. *   several considerations are included in making this decision, but the most  *
  12. *   basic one is simple the remaining material for each side.  if either side  *
  13. *   has pawns, it's not a draw.  with no pawns, equal material is a draw.      *
  14. *   otherwise, the superior side must have enough material to be able to force *
  15. *   a mate.                                                                    *
  16. *                                                                              *
  17. ********************************************************************************
  18. */
  19. int Drawn(TREE *tree, int value)
  20. {
  21. /*
  22.  ----------------------------------------------------------
  23. |                                                          |
  24. |   if either side has pawns, the game is not a draw for   |
  25. |   lack of material.                                      |
  26. |                                                          |
  27.  ----------------------------------------------------------
  28. */
  29.   if (TotalWhitePawns || TotalBlackPawns) return(0);
  30. /*
  31.  ----------------------------------------------------------
  32. |                                                          |
  33. |   the search result must indicate a draw also, otherwise |
  34. |   it could be a tactical win or loss.                    |
  35. |                                                          |
  36.  ----------------------------------------------------------
  37. */
  38.   if (value != DrawScore(crafty_is_white)) return(0);
  39. /*
  40.  ----------------------------------------------------------
  41. |                                                          |
  42. |   if neither side has pawns, and one side has some sort  |
  43. |   of material superiority, then determine if the winning |
  44. |   side has enough material to win.                       |
  45. |                                                          |
  46.  ----------------------------------------------------------
  47. */
  48.   if (TotalWhitePieces<5 && TotalBlackPieces<5) return(2);
  49. /*
  50.  ----------------------------------------------------------
  51. |                                                          |
  52. |   if neither side has pawns, then one side must have     |
  53. |   some sort of material superiority, otherwise it is a   |
  54. |   draw.                                                  |
  55. |                                                          |
  56.  ----------------------------------------------------------
  57. */
  58.   if (TotalWhitePieces == TotalBlackPieces) return(1);
  59.   return(0);
  60. }
  61.