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