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

  1. #include <stdio.h>
  2. #include "chess.h"
  3. #include "data.h"
  4.  
  5. /* last modified 06/05/98 */
  6. /*
  7. ********************************************************************************
  8. *                                                                              *
  9. *   DrawScore() is used to determine how good or bad a draw is in the current  *
  10. *   game situation.  It depends on several factors, including the stage of the *
  11. *   game (opening [draw=bad], middlegame [draw=somewhat bad] and endgames      *
  12. *   [draw=default_draw_score.])  Additionally, it looks at the opponent's time *
  13. *   remaining in the game, and if it's low, it will eschew the draw and press  *
  14. *   the opponent to win before his flag falls.                                 *
  15. *                                                                              *
  16. ********************************************************************************
  17. */
  18. int DrawScore(int crafty_is_white)
  19. {
  20.   register int draw_score;
  21. /*
  22.  ----------------------------------------------------------
  23. |                                                          |
  24. |   first, set the draw score based on the phase of the    |
  25. |   game, as would be done normally, anyway.               |
  26. |                                                          |
  27.  ----------------------------------------------------------
  28. */
  29.   if (!draw_score_normal) {
  30.     if (move_number <= 30) 
  31.       draw_score=default_draw_score-66;
  32.     else if (middle_game)
  33.       draw_score=default_draw_score-33;
  34.     else
  35.       draw_score=default_draw_score;
  36. /*
  37.  ----------------------------------------------------------
  38. |                                                          |
  39. |   now that the base draw score has been set, look at the |
  40. |   opponent's remaining time and set the draw score to a  |
  41. |   lower value if his time is low.                        |
  42. |                                                          |
  43.  ----------------------------------------------------------
  44. */
  45.     if (tc_increment == 0) {
  46.       if (tc_time_remaining_opponent < 3000)
  47.         draw_score=default_draw_score-50;
  48.       if (tc_time_remaining_opponent < 1500)
  49.         draw_score=default_draw_score-100;
  50.     }
  51.   }
  52. /*
  53.  ----------------------------------------------------------
  54. |                                                          |
  55. |   if playing a computer, return the default draw score   |
  56. |   regardless of the phase of the game or time left.      |
  57. |                                                          |
  58.  ----------------------------------------------------------
  59. */
  60.   else draw_score=default_draw_score;
  61.   if (crafty_is_white) return(draw_score);
  62.   else return(-draw_score);
  63. }
  64.