Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: To Bob

Author: Robert Hyatt

Date: 07:36:27 11/28/00

Go up one level in this thread


On November 28, 2000 at 00:12:23, Jeremiah Penery wrote:

>On November 27, 2000 at 19:21:06, Robert Hyatt wrote:
>
>>Note that this code has been significantly rewritten, so older versions probably
>>will behave a bit differently here.  It was time to clean up the detection of
>>"one side can't win" and do it right, rather than in a kludge.  It now knows
>>that KR vs KNP is not a win for the KR, ditto for KRB vs KRP and so forth...
>>the extra piece isn't enough.
>
>I have been adding similar knowledge to Crafty recently (in the
>EvaluateMaterial() function).  I have completely rewritten the module, in a way
>that hopefully catches all the possible situations.  It's also (IMO) much easier
>to read and understand than the original module, and I haven't noticed much, if
>any, reduction in speed when using it.  Using this, it's probably possible to
>eliminate some of the stuff in EvaluateDraws() or some of the stuff regarding
>material balance elsewhere, but I haven't tried it yet.  It's also possible that
>there are some errors in this, but I think I've found them all.

EvaluateMaterial() isn't where I fixed the problem.  I wanted to also handle
the case KRN vs KRPP (and similar cases) correctly.  KRPP can often win.  The
eval now recognizes two cases:  white can't win and black can't win.  And the
last step in the evaluation process is to make sure that if white can't win
is set, the score can't go above DrawScore(), and if black can't win is set,
the score can't go below DrawScore().

The new version of everything is significantly smaller than it was before, so
that speed didn't suffer at all.  And it is also far more accurate although I
am still feeding it test positions to be sure that all the special cases are
recognized.




>
>I would email it to you (or the Crafty list), but I've recently discovered that
>my outgoing email server on campus won't let me use it, since I'm not directly
>on the campus network.  So, for the time being, I have only hotmail or something
>to send outgoing email, which I _really_ hate using. (Also, in the past your
>email server automatically trashed anything from hotmail, so it might not get to
>you anyway.  I'm not sure if it's still this way, but I don't even like trying
>to use that thing. :)  I post the code here instead:
>
>int EvaluateMaterial(TREE *tree) {
>   register int score;
>   register int diffmajors, diffminors, diffpawns, diffqueens;
>   int w_queens, b_queens;
>/*
>**********************************************************************
>*                                                                    *
>*   we start with the raw Material balance for the current position. *
>*                                                                    *
>**********************************************************************
>*/
>   score=Material;
>   do {
>      diffmajors=WhiteMajors-BlackMajors;
>      diffminors=WhiteMinors-BlackMinors;
>      diffpawns=TotalWhitePawns-TotalBlackPawns;
>      w_queens=PopCnt(WhiteQueens);
>      b_queens=PopCnt(BlackQueens);
>      diffqueens=w_queens-b_queens;
>      if (diffmajors > 0 && diffminors > 0) break;
>      else if (diffmajors < 0 && diffminors < 0) break;
>      else if (diffminors==0 && diffpawns==0) break;
>      if (!tree->endgame) {
>         if (diffmajors==0 && diffpawns==0) break;
>         if (diffmajors==0 && diffminors==0) break;
>      }
>      if (!TotalWhitePawns || !TotalBlackPawns) {
>         if (diffmajors==0 && diffqueens==0 && abs(diffminors)==1) {
>            if (TotalWhitePawns > 1) score=TotalWhitePawns*PAWN_VALUE>>1;
>            else if (TotalBlackPawns > 1) score=-TotalBlackPawns*PAWN_VALUE>>1;
>            else score=0;
>            break;
>         }
>         else if (diffmajors+diffminors==0 && diffqueens==0) {
>            if (TotalWhitePawns && diffmajors > 0)
>               score=TotalWhitePawns*PAWN_VALUE;
>            else if (TotalBlackPawns && diffmajors < 0)
>               score=-TotalBlackPawns*PAWN_VALUE;
>            else score=0;
>            break;
>         }
>         else if (diffmajors==0 && diffminors==0) {
>            if (diffqueens==0 && abs(diffpawns)==1) score/=2;
>         }
>      }
>      else {
>         if (diffmajors+diffminors==0 && abs(diffminors)==1) {
>            if (diffqueens==0 && diffpawns==0) {
>               score=(diffmajors > 0) ? EXCHANGE : -EXCHANGE;
>               break;
>            }
>         }
>         if (diffminors > 2) {
>            if (diffmajors==-1) {
>               score+=BAD_TRADE;
>            }
>         }
>         else if (diffminors > 1) {
>            if (diffqueens==0 && diffmajors==-1) {
>               if (diffpawns > -2) score+=BAD_TRADE;
>            }
>         }
>         else if (diffminors==1) {
>            if (diffmajors==0 && diffqueens==0) {
>               if (diffpawns >= -2) score+=BAD_TRADE;
>               if (diffpawns == -3) score+=BAD_TRADE>>1;
>            }
>         }
>         else if (diffminors < -2) {
>            if (diffmajors==1) {
>               score-=BAD_TRADE;
>            }
>         }
>         else if (diffminors < -1) {
>            if (diffqueens==0 && diffmajors==1) {
>               if (diffpawns < 2) score-=BAD_TRADE;
>            }
>         }
>         else if (diffminors==-1) {
>            if (diffmajors==0 && diffqueens==0) {
>               if (diffpawns <= 2) score-=BAD_TRADE;
>               if (diffpawns == 3) score-=BAD_TRADE>>1;
>            }
>         }
>      }
>   } while(0);
>   return (score);
>}



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.