Definition of "endgame"?

Discussion of chess software programming and technical issues.

Moderator: Ras

bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Definition of "endgame"?

Post by bob »

Tony wrote:
adams161 wrote:hi,

I have a cheap way of doing this. An endgame occurs when material reaches a point that you have few pieces on the board. Maybe as suggested the value of 12 pawns. I'm actually using two stages of endgame i think, endgame1 and endgame2.

Since i dont want to allow a single capture mid search to radically change teh score, i.e. the capture and bring me into endgame, I dont allow the phase change to endgame to occur in a search.

At the beginning of a search before calling search, i check if we are in endgame. If we are then i set one of or both of the endgame flags. I dump the hash also at that point since it contains scores that were not evalutated with endgame eval parameters.

the cost is a less precise knowledge of when you enter endgame. but i set my count of pieces in such a way that its a little higher, so that if some pieces get captured in search it doesnt push me to to low a piece count beyond what i feel would be endgame.

Mike
That doesn't sound like a solution, more like ignoring (or worsening) the problem. A lot of times (fe a rook bishop ending) the reason for not exchanging the bishop is because the "shift" of the values of the connected passed pawns.

Not allowing the score transitions would be very bad. With nowadays hardware, the normal search makes this transition pretty often and quiescence search very often.

Tony
I agree. Scoring changes have to occur over a continuous range with no discontinuities, with some exceptions. For example, removing the last opponent piece might let your passed pawn run and promote. That eval term should just kick in when the piece is removed. No scaling necessary. But for opening to middlegame or middlegame to endgame, which happens in most every game, if it is done in a discontinuous way, it invites a very bizarre form of the horizon effect into your game. And the results are ugly at times...
Tony

Re: Definition of "endgame"?

Post by Tony »

adams161 wrote:hi,

My endgame control only effects king saftey and null moves so its not such a big issue however its been on the back of my mind how to implent pawn evaluates specific to endgames which i dont do now.

The other week i had pulsar play a game with tinker on icc, it was doing fine the whole game tell it got to endgame then it let tinker get a passed pawn, pulsar had one two, but pulsars pawn was going to lose the race but pulsar didnt see it. So the idea of adding endgame specific pawn code has been on my mind.

Any suggestions for some basic start points on how to evaluate pawns differently in endgame, throughout the game i'm evaluating passed, doubled, isolated and backwared i think, and cheap ways in terms of code and proccesing to implement them?

MIke
I can give you XiniX' secret implementation. It's not really secret but few people use it. It's based on interior recognizers.

Just write a couple of dozens evaluation functions !

In XiniX I keep track of the materialsignature, but I don't know the exact number.

So fe KRKN looks like ( the one with the rook is considered winner since I don't know the counts yet)

Code: Select all


bool evaluateKRKN(TBoard *board,int stm,int winner,int &score)
{
   if (rookCount(winner)==1)
   {
      if (knightCount(looser)==1)
      {
          score=SetWinnerScore(50,winner);
          return(true);
      }
      else if (knightCount(looser)==2)
      {
           score=SetWinnerScore(-25,winner);
          return(true);
     }
      else return(false);
   }
   else if (rookCount(winner)==2)
   {
        score+=DriveKingToCorner(board,winner);
         return(true);
   }
   else return(false);

}

You can reuse a lot of code, so it isn't too bad.

fe my KQPKQP, KRPKRP,KBPKBP and KNPKNP all adjust the score for 4-3, 3-2 and 2-1 advantages with all pawns on one wing except that 4-3 for KNPKNP is still winning and 3-2 for KRPKRP is checked for e-f and g pawn against f-h pawn.

You basicly take a bunch of endgame books and start adding.

Compared to other engines, XiniX is very strong in the endgame. (Not counting the usual bugs that such a big amount of knowledge can contain)

Last few tournement I played, I had inferior hardware, but when I went into an equal endgame, I normally never lost.

The problem was always how to reach an equal endgame.

Tony
Uri Blass
Posts: 11126
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: Definition of "endgame"?

Post by Uri Blass »

hgm wrote:This has always seemed a very fishy method to me. Why would the game stage not simply be an instantaneous function of what is on the board? We don't smooth heavy material losses, do we? Like if you are a Rook ahead, and a certain line loses your Queen, not take the -950 centiPawn immediately, but slowly ramp down the evaluation from +500 to -450 over the next 10 moves after the capture...
Note that capturing a queen changes the game stage clearly more than capturing a knight and every capture of piece that is no pawn change the stage of the game.

I do not see the relevance of your example because
slowly ramp down the stage from stage X to stage Y over the next 10 moves does not happen unless there are some piece captures that cause the stage to change from stage X to stage Y because with no piece capture(and no promotion because to do things simple I assume no promotion in the next 10 moves) the game stage is not changed.

Uri
Tony

Re: Definition of "endgame"?

Post by Tony »

Uri Blass wrote:
hgm wrote:This has always seemed a very fishy method to me. Why would the game stage not simply be an instantaneous function of what is on the board? We don't smooth heavy material losses, do we? Like if you are a Rook ahead, and a certain line loses your Queen, not take the -950 centiPawn immediately, but slowly ramp down the evaluation from +500 to -450 over the next 10 moves after the capture...
Note that capturing a queen changes the game stage clearly more than capturing a knight and every capture of piece that is no pawn change the stage of the game.

I do not see the relevance of your example because
slowly ramp down the stage from stage X to stage Y over the next 10 moves does not happen unless there are some piece captures that cause the stage to change from stage X to stage Y because with no piece capture(and no promotion because to do things simple I assume no promotion in the next 10 moves) the game stage is not changed.

Uri
You miss the point.

Since most people do this in a linear way ( since this is how it's done in Fruit) you assume that exchanging from a 4 rook endgame to a 2 rook, has the same effect as going from 2 to 0 rooks.

Tony
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Definition of "endgame"?

Post by bob »

Tony wrote:
Uri Blass wrote:
hgm wrote:This has always seemed a very fishy method to me. Why would the game stage not simply be an instantaneous function of what is on the board? We don't smooth heavy material losses, do we? Like if you are a Rook ahead, and a certain line loses your Queen, not take the -950 centiPawn immediately, but slowly ramp down the evaluation from +500 to -450 over the next 10 moves after the capture...
Note that capturing a queen changes the game stage clearly more than capturing a knight and every capture of piece that is no pawn change the stage of the game.

I do not see the relevance of your example because
slowly ramp down the stage from stage X to stage Y over the next 10 moves does not happen unless there are some piece captures that cause the stage to change from stage X to stage Y because with no piece capture(and no promotion because to do things simple I assume no promotion in the next 10 moves) the game stage is not changed.

Uri
You miss the point.

Since most people do this in a linear way ( since this is how it's done in Fruit) you assume that exchanging from a 4 rook endgame to a 2 rook, has the same effect as going from 2 to 0 rooks.

Tony
I don't quite go that far. In Crafty the effect is far more pronounced when going from 2 to zero than from 4 to 2. 2 to 0 can cause a huge jump for many reasons. Outside passers become almost winning advantages. For just one.

I've not tried the "fruit" approach. I simply compute three score components, the standard stuff that never changes, some endgame specific stuff, and some king-safety specific stuff. King safety stuff gets scaled down as material comes off, endgame stuff gets scaled up inversely to the king safety stuff. The basic scoring doesn't change, although some of it probably should.
Uri Blass
Posts: 11126
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: Definition of "endgame"?

Post by Uri Blass »

Tony wrote:
Uri Blass wrote:
hgm wrote:This has always seemed a very fishy method to me. Why would the game stage not simply be an instantaneous function of what is on the board? We don't smooth heavy material losses, do we? Like if you are a Rook ahead, and a certain line loses your Queen, not take the -950 centiPawn immediately, but slowly ramp down the evaluation from +500 to -450 over the next 10 moves after the capture...
Note that capturing a queen changes the game stage clearly more than capturing a knight and every capture of piece that is no pawn change the stage of the game.

I do not see the relevance of your example because
slowly ramp down the stage from stage X to stage Y over the next 10 moves does not happen unless there are some piece captures that cause the stage to change from stage X to stage Y because with no piece capture(and no promotion because to do things simple I assume no promotion in the next 10 moves) the game stage is not changed.

Uri
You miss the point.

Since most people do this in a linear way ( since this is how it's done in Fruit) you assume that exchanging from a 4 rook endgame to a 2 rook, has the same effect as going from 2 to 0 rooks.

Tony
I did not say that linear way is the best.
I already thought that non-linear can be better than linear but it needs to be proved by games.

In public movei the default personality is linear but the code was changed to allow non linear functions and in one case it was even changed to allow the user to get non linear personality for one component by having 25 different scores based on stage of the game.

The relevant compnent that is not used by the default persoanlity(except similiar term that I am going to mention later in this post) is bonus for extreme pawn.

extreme_pawn_array 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.

The first numbers are for the opening and the last numbers are for the endgame and 0 mean not used.


practically the score is divided by a constant(24 if I remember correctly) so you may need value of 240 to have 0.1 centi-pawn bonus for extreme passed pawn.

Note that there is also special bonus for extreme passed pawn of 0.1 pawns in the endgame stage(when endgame stage is defined in a different way) because I did not remove special endgame stage from movei so I have special_bonus_endgame 10 in the default personality.

I believe that correct non linear bonus for endgame together with removing special_bonus_endgame 10 is better than linear bonus for endgame and this is the reason that I added the extreme_pawn_array but I am unsure about the right values and unfortunately I do not like to spend computer time on testing it when I plan to rewrite movei in any case.

I also did not replace special_bonus_endgame 10 by linear bonus because I am unsure if it is better and I did not like to do changes that I am unsure if they make the program better.

If people are interested in trying to improve movei by having better extreme_pawn_array then I will be happy but my guess is that you cannot earn more than 10 elo by doing it and you may need thousands of games so I do not expect people to do it.

Uri
User avatar
hgm
Posts: 28428
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Definition of "endgame"?

Post by hgm »

I think the fact that you have to artifitially smoothen something over a number of moves is a sign that someting is done in a fundamentally wrong way. Like in uMax, where (for simplicity's sake) I only determine a game-stage indicator in the root, from the (weighted) non-Pawn material on the board (both sides added), B,N=2, R=3, Q=6, and use it to determine Pawn-push and King-safety scores.Then you get funny effects if large material is traded down in the root, so that many positions in the tree suddenly get a completely different evaluation. So the n-2 iteration stored in the hash on the next move then can give a completely wrong impression of how the new tree should look, and iteration n-1 takes a lot longer than usual. This effect could be softened by temporal averaging. But it is something that is easy to live with in the first place.
Uri Blass
Posts: 11126
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: Definition of "endgame"?

Post by Uri Blass »

<snipped>
hgm wrote:I think the fact that you have to artifitially smoothen something over a number of moves
I do not understand why do you think that it is a fact.

The game stage is changed only after captures of non pawns or promotions there is no change over a number of moves if
after a capture you have quiet moves.

If you have a line like 1...BxQ 2.a4 h5 3.Rd1 Re8 4.Be3 Be6 then the stage is not changed during moves 2-4 in this line.

Uri
Harald Johnsen

Re: Definition of "endgame"?

Post by Harald Johnsen »

Tony wrote:
You miss the point.

Since most people do this in a linear way you assume that exchanging from a 4 rook endgame to a 2 rook, has the same effect as going from 2 to 0 rooks.

Tony
I don't know why you say that. You don't know what terms are in the evaluation.
1) you have recognizer for special position or set of position => smoothing is not even used here
2) you have end game terms that handle special positions so they will have more effect the less material you have on the board
3) your rook example : 4 rooks, 2 rook, 0 rooks are different phase number, so obviously the evaluation will be different.

HJ.
User avatar
hgm
Posts: 28428
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Definition of "endgame"?

Post by hgm »

Well, perhaps I understood it wrong then, but I thought that was exactly what people mean by smoothening: That they distribute the change that in fact occurs in a single (capture) move over several moves.