Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Staged evaluation

Author: Harald Lüßen

Date: 16:54:48 10/20/04

Go up one level in this thread


On October 20, 2004 Alessandro Scotti wrote:

>I'm going to rewrite the evaluation function of my engine and I would like to
>know what do you think about dividing the game in stages such as for example
>middlegame#1, middlegame#2, ..., endgame#1 and so on.
>I've often read that it's better for an engine to avoid "discontinuity" in the
>evaluation, which sounds reasonable but on the other hand dividing the game in
>stages looks like a big mess and I'm not sure there won't be other side effects
>as well...
>Therefore I'm considering to implement only the three "classic" stages of
>opening, middlegame and endgame, and to provide "ad-hoc" code fragments if
>necessary. Would that be enough for decent play?

I have a function at the beginning of each evaluation:
/**
Get the two game stages for white and black.
This depends on the development of pieces and on the material without pawns.
 0: opening position
 1:                                     (develop .NB..BN. and castle)
 2:
 3:
 4:
 5:                                     (middlegame)
 6: full developed
 7: wmaterial_without_pawns < 1 Queen + 2 rooks + 2 bishops + 2 knights
 8: wmaterial_without_pawns <           2 rooks + 2 bishops + 2 knights
 9: wmaterial_without_pawns <           2 rooks + 2 bishops
10: wmaterial_without_pawns <           2 rooks + 1 bishop (beginning endgame)
11: wmaterial_without_pawns <           2 rooks
12: wmaterial_without_pawns <           1 rook
13: material                < 5 pawns   (late endgame)
*/
I just look at the material values, not at the pieces listet above.
The function could certainly be improved or scaled differently
or the whole thing could be done in make_move().
In the evaluation I do things like this:
  if ( bgame_stage >= 10 )
  {
      ...
      bking_safety_value += king_corner_value * (7-dist) * (bgame_stage-9);
      ...
  }
You can even use tables with the stage as one index.
  eval += pcsq[stage][pc][sq];
  eval += trick17_scaled_to_make_sense[stage];

What I don't like are the many special cases and ifs in my
evaluation. Tord's idea may be smoother and easier to maintain
and it avoids steps and holes in the evaluation. Tord, does
the doubled evaluation in
eval = p * middlegame_eval + (1-p) * endgame_eval
cost much time?

Harald



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.