CHESS PRACTICE            
Updated: April 2008  

- ANTOINE BRUNEAU'S BLOG -

Chess and Programming


HOW CHESS
COMPUTERS WORK, II



3o) The Evaluation Function

The minimax algorithm requires an evaluation of the positions at each leaf. This evaluation is done by a function which associates an evaluation of the position according to certain rules. This value is signed by a convention: positive if White has the advantage and negative if Black has it. It computes the White and Black scores according to the same rules and gives the difference.
In chess, the evaluation function is approximate, it only translates heuristic principles - there is no canonical method to compute the evaluation. A single numerical value is used to summarize many rules. It is a way of explaining strategy principles to the machine. In searching to optimize the value of the position the computer acts as if he could understand the rules of strategy. Of course those principles do not enable combination recognition: it is the minimax algorithm that enables machines to find combinations.

«Dossi, Ugo - "Trajectories of
a chess game" Image copyright ©
Ugo Dossi - Artists Rights Society
(ARS), New York / ADAGP, Paris

          Dossi, Ugo - 'Trajectories of  
        a chess game' Image copyright ©   
        Ugo Dossi - Artists Rights Society
        (ARS), New York / ADAGP, Paris


Basically, the evaluation function counts the material (on each side) by summing the pieces weighted by the values for each kind of piece: for example, the Queen equals 9 pawns. Sometimes the function gives the King a very high value signifying that checkmate is the most important factor. We can refine this evaluation by adding to the assessment other values that translate certain positional considerations. It is important to distinguish positions with equal material, and sometimes positional aspects can prevail over material aspects. Refining the evaluation function is one of the fundamental ways to improve the performance of chess computers.
One aspect easy to compute is mobility: it suffices to count the number of legal moves generated by the move generator. This is not exactly what we call mobility in chess because it counts all possible moves, even those that are useless or even bad! - but it gives a rough approximation. We can quantify other positional aspects such as the protection of the King, domination of the centre and pawn structure etc.
We can refine the evaluation by adding or subtracting points depending on whether certain rules are satisfied or not by using conditional propositions such as: "if the King is in check then subtract x points". It is advisable to have 3 different evaluation functions - for the opening, the middle game and the endgame - because strategic rules are different in each phase. For example, in the opening the function subtracts points if the Queen has moved, or if the pawn f2/f7 has moved before kingside castling. In the middle game the function subtracts points if the King hasn't castled, or if Knights or Bishops haven't yet moved. In the endgame the function subtracts points for backward, isolated and doubled pawns.


4o) The Horizon Effect

The algorithm min-max works with a tree truncated at a certain depth. The horizon effect is a perverse effect due to the fact that this depth is the same for all branches. The limits of machines require limiting the depth of the analysis of game tree but this depth does not need not to be the same everywhere. Because of the horizon effect, the legendary strength of computers in tactics is true only up to a certain limit, because computers work as if the moves beyond this horizon don’t exist. They see only near dangers - after 7 moves they are completely lost. Computers are not fit for positional sacrifice recognition. In the earliest chess programs, the horizon effect led to aberrant sacrifices and even today computers are not really able to avoid this effect, because we don't have a technique which remedies it, but only recipes based on principles that are difficult to implement.
To remedy the horizon effect we must make depth vary as a function of the type of position. We have only a certain amount of analysis time available and we have to share it out in the most useful manner between all positions to be analysed. We can noticeably improve the research with a given depth ‘d’ if we make an algorithm with a variable depth that is only an average ‘d’. If a move seems bad (for example in the case of loss of material) then it is probable that this move is in fact bad and it is useless to privilege it in the analysis, whereas, if the move seems interesting it is useful to continue to decide if it actually is so, so as not to unwisely play it. To recognise a bad move we can use the ‘nil move’ heuristic: if immediately after having moved we move a second time as if it was again our turn to play, and if this second move is not advantageous then the first move can be considered as bad. For defining an average depth equal to ‘d’, the algorithm Search Extension associates to each branch the value 10 times ‘d’ and decreases it at each dropping of a level in the tree by a small quantity if the move is interesting. So interesting moves benefit from a greater depth of analysis. The research in depth stops in each branch when this value is nil (or negative).
As well as looking at bad or ‘good’ or interesting moves, the horizon effect concerns unstable positions, i.e. those where there is capture, check or promotion. For example, let us consider the case where we run the algorithm min-max with a depth = 1. The program will choose a move that captures an opposite piece, for example the Queen takes a protected Knight, because the response of the adversary is beyond his horizon. If we run it with a greater depth this problem will still occur at the frontier of the horizon: it will see in this place a capture whereas it can be balanced or even largely balanced. It will see an illusory threat in what is a commonplace exchange because it will see only one half of this exchange and this will impact on the calculation even if it occurs in the depths of the calculations of the variations. For example, if at the end of a variation it sees that it can take the opposite Queen with its own Queen but doesn't see that its Queen will be recaptured on the following move it will believe to have found a combination and this variant will be overestimated erroneously. This problem is specific to captures: if the depth is odd the algorithm doesn't take into account the riposte of the adversary and overvalues some moves, whereas if the depth is even it doesn't see its own riposte to moves of the adversary and therefore overvalues some moves by the opponent. The problem is that we *must* stop at a determined depth (even or odd).

«Wikipedia The Free Encyclopediia
Spiral Sphere and Julia, Detail,
~ A computer-generated image
programmed by visual artist Robert
W. McGregor - Image copyright ©
visual artist Robert W. McGregor
Artists Rights Society (ARS),
New York / ADAGP, Paris
          Wikipedia The Free Encyclopediia  
        Spiral Sphere and Julia, Detail,
        ~ A computer-generated image
        programmed by visual artist Robert
        W. McGregor - Image copyright ©
        visual artist Robert W. McGregor
        Artists Rights Society (ARS),
         New York / ADAGP, Paris


A rather more subtle obstacle occurs when the computer is in the midst of a forced threat (such as the loss of his Queen). The horizon effect will give him the illusion of an answer: all sacrificial moves that enable delaying the danger will give him the illusion of avoiding it because it will push it back and locate it beyond his horizon, although those sacrifices are not valid replies and only serve to worsen uselessly the material balance. Although if at such a situation the alpha-beta algorithm is extended, the program computes the global balance and doesn't play those delay-action moves. Hence the solution is to recognise this kind of position in order to invest more analysis time on it.
The solution then is to continue the basic search by a search for stability. For this we create a second evaluation function like the one which evaluates the position, but this one evaluates the kind of position. This second evaluation provides the degree of confidence the program may have in the evaluation of the position. So the computer continues the analysis in the cases where the position hasn’t a reliable evaluation to reach positions where the evaluation is reliable, and which enable modification of the evaluation of the position concerned. Stable positions have a reliable evaluation, and we don't need to continue the analysis on them further, whereas unstable positions must be analysed in depth until reaching stable positions that enable changing the evaluation of our position in a reliable manner.

************

© Antoine Bruneau - April 2008

[This page was conceived by
Antoine Bruneau - John E Hawkes
has contributed to the English
presentation of this article -
All data is copyrighted by: ©
Antoine Bruneau & Chess-Theory]


************

If you like music, you may choose now a fine background Music:

    Choose now a fine background Music!...



  • For each music a pop-up opens behind your page.
  • Each pop-up owns a fine image related to the artist!
  • You may come back to your previous page or access all other page on the Site (the pop-up will stay open).
  • This music may accompany you, if you wish, through all the Site.
  • You may change, when you want, a music for another.


  • ************

       «CRYSTAL PHOENIX GALLERY-
    ArtPrint - "Checkmate" - - Image
    copyright © CRYSTAL PHOENIX GALLERY
    Artists Rights Society (ARS), New York / ADAGP, Paris»


    ***


    FOR PLEASANT SURFING AROUND THIS SITE:

  • We suggest these best paths:

  •   «LASTEST UPDATES»
      «GENERAL SITE PLAN»
      «GENERAL SITE MENU»
      «LINK COLLECTION HOME PAGE»
      «ECO CODES BASE»
      «CHESS THEORY FORUMS»
      «SEARCH ENGINE»
      «VIRTUAL ART MUSEUM»


    ***


    FOR DISCOVERING WHO WE ARE:

  • ... and also expressing freely your opinion:

  •   «CHESS-THEORY: GUEST BOOK»
      «CHESS-THEORY: ABOUT US»    
      «CHESS-THEORY: COPYRIGHT»





               * DON'T NEGLECT TO CONTACT US HERE! *           
    This page, created by Michel Bruneau, is
    Copyright: © Michel Bruneau «Chess-Theory»
    Webmaster - All rights reserved 2004-2008


    Thank to  you  visitors  and friends!...
    Please notice  that  you  help us a  lot
    by giving your opinion and comments
    about  this  page as well as all  other
    pages that you have recently visited
    in  the   «Chess-Theory»   Website:


      Express yourself
on our Guest Book  

    My Dear  Friends!...  Without  at   least
    your  moral  support, formulated  here
    or   on  our  forums, this  site can close
    definitively without advance warning!
    ... Humour? Maybe, but it is also true
    that   a   Webmaster,  most of  the time
    alone facing his computers, experien-
    ces  sometimes,   in  his  projects  and
    realizations, discouragement and doubt
    ... HELP ME BY WRITING YOUR FEELINGS!


    The «Chess-Theory» Website receives
    more than
    90, 000 different visitors
    per month, coming  from  about
    145
    different   countries   in   the   world
    (daily statistics generated by awstats)






    * «CHESS-THEORY FOUNDATION» WEB SITES *
    The  «Chess-Theory  Foundation»,  currently
    still  unofficial,   under  the  responsibility   of
    Michel Bruneau, the «Chess-Theory»  Web-
    master,   puts   to  your  disposal  the   three
    following   complementary  Web   Addresses:


    * CHESS-THEORY.COM *

    ~ CHESS-THEORY.COM ~
    This is our main site, fully dedicated
    to Chess Theory, Chess Training, Chess
    Analysis and Chess Practice; but presenting
    also the first version of our Virtual Art
    Museum. This bilingual Site owns about 2 000
    English pages, 2 000 French pages, more than
    10 000 linked images, many hundreds of chess
    diagrams and more than 110 analyzed games
    presented with the "Chess-Theory" Viewer!...

                   ~ 'CHESS-THEORY.COM' ~
      This is our main site, fully dedicated 
      to Chess Theory, Chess Training, Chess 
      Analysis and Chess Practice; but presenting
      also the first version of our Virtual Art 
      Museum. This bilingual Site owns about 2 000 
      English pages, 2 000 French pages, more than  
      10 000 linked images, many hundreds of chess 
      diagrams and more than 110 analyzed games    
      presented with the 'Chess-Theory' Viewer!...


    * VIRTUAL-ART-MUSEUM.COM *

    ~ VIRTUAL-ART-MUSEUM.COM ~
    You will recover here, in a surprising
    new look design, all galleries and
    linked images of the "Chess-Theory"
    Virtual Art Museum ... but, rather soon,
    you will discover also many new beautiful
    galleries presenting a rich collection
    of unexpected Hight Definition Images,
    Royalty Free Photos and so more ....

             ~ 'VIRTUAL-ART-MUSEUM.COM' ~
      You will recover here, in a surprising
      new look design, all galleries and
      linked images of the 'Chess-Theory'
      Virtual Art Museum ... but, rather soon,
      you will discover also many new beautiful 
      galleries presenting a rich collection 
      of unexpected  Hight Definition Images, 
      Royalty Free Photos and so more ....


    * FROM-THE-WHOLE-WORLD.COM *

    ~ FROM-THE-WHOLE-WORLD.COM ~
    This Web Site, currently under
    construction, will deal with all
    cultural, intellectual or moral
    subject untreated by other ones

     ~ 'FROM-THE-WHOLE-WORLD.COM' ~
      This Web Site, currently under
      construction, will deal with all
      cultural, intellectual or moral
      subjects not treated by other ones




    «Michel  Bruneau  the  "Chess-Theory" Webmaster
    ...  presumably   when  he  was  a   little  younger
    and    still    full    of    Illusions   and     Dreams! »
    Photograph and Montage by Jean-Pierre Bruneau
    Copyright © 2008 Jean-Pierre Bruneau & "Chess-Theory"
    Nevertheless this image is available for Link Exchange!

         Michel Bruneau the 'Chess-Theory' Webmaster 
         ...presumably when he was a little younger   
                and still full of Illusions and Dreams!


    ******** ©-«Chess-Theory.com»-2004-2008 ********


                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
    Listen Music Now