Definition of "endgame"?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

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

Re: Definition of "endgame"?

Post by Uri Blass »

hgm wrote: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.
I guess that you understood wrong.

Their point was that change from opening to endgame does not happen in a single capture(using this assumption is still the case for many old programs and if you look at the code of programs like tscp you may find that it has a special piece square table for endgame that it is using only when the material is low enough and it does not do average between opening score and endgame score when the weights are based on the material in the board).

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

Re: Definition of "endgame"?

Post by hgm »

Well, it depends how the game-stage is used in your eavaluation. IIRC, for King safety TSCP has a term that is proportional to the opponent material. So that would gradually decrease in importance, rather than all at once. I wonder if this has actually been measured. I would expect that the moment your King has to leave its shelter and join the fight is very sharply defined in most games. Do it too early, and you are toast. Do it too late, and the end-game is hopelessly lost. Trading of a single piece can make the difference if the opponent has quick mating potential against an exposed King, or if he can never do more than pointless chasing with checks. I could well imagine that an abrupt transition approximates reality better than a gradual change.

I am not sure that having different PSTs if middle-game and end-game is useful at all. It seems to me that if PSTs should depend on anything, it would be on Pawn structure. And I guess they could be a very 'discontinuous' function of that: a single Pawn move, permanently opening or closing a line (e.g. trade or push) could have a dramatic effect on if your current piece placement is excellent or disastrous. I think this is a real effect, and should never be smoothened.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Definition of "endgame"?

Post by bob »

hgm wrote: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.
No. You simply have to smooth the transition somehow, rather than just letting a single capture turn on/off a bistable value. That is what Berliner referred to as a "evaluation discontinuity" and which he clearly explained why it must be avoided or you get instability around those discontinuities in your search.

I scale as material is removed, not as moves are made.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Definition of "endgame"?

Post by bob »

Harald Johnsen wrote:
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.
His point was that the difference between positions with 4 rooks as opposed to just two is probably less significant than the difference between positions with 2 rooks vs none. Linearly scaling based on material is not so good there.
User avatar
hgm
Posts: 27796
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Definition of "endgame"?

Post by hgm »

bob wrote:I scale as material is removed, not as moves are made.
OK, I see. But let's look at a specific example, Say KQBB+Pawns vs KQBN+Pawns. As black I would not want to come out with my King from behind the Pawn shelter if the opponent still has QBB, as I would be mated very quickly. If the opponent has only KBB, this danger is reduced to about zero, as it is almost impossible to mate with two Bishops (even with King support they can only do it if you are at the board edge).

So wouldn't it be logical to drop King safety completely when Queens are traded? It seems to me this has the character of an all-or-none thing: either the opponent has enough material to mate you in the center of the board, in which case you have to value some protection, or he hasn't.
Uri Blass
Posts: 10282
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: Definition of "endgame"?

Post by Uri Blass »

hgm wrote:
bob wrote:I scale as material is removed, not as moves are made.
OK, I see. But let's look at a specific example, Say KQBB+Pawns vs KQBN+Pawns. As black I would not want to come out with my King from behind the Pawn shelter if the opponent still has QBB, as I would be mated very quickly. If the opponent has only KBB, this danger is reduced to about zero, as it is almost impossible to mate with two Bishops (even with King support they can only do it if you are at the board edge).

So wouldn't it be logical to drop King safety completely when Queens are traded? It seems to me this has the character of an all-or-none thing: either the opponent has enough material to mate you in the center of the board, in which case you have to value some protection, or he hasn't.
I think that you are not right.

Based on my experience there is a mate danger even in pawn endgame
and I remember that I lost a blitz game in a pawn endgame because my king was checkmated some years ago.

I do not remember the position that it happened but it is easy to compose a position when it can happen

[D]8/8/8/3ppp2/4k3/4P3/3PK3/8 w - - 0 1

It is dangerous to develop the king in
QBB vs QBB and pawns but it is even more dangerous to do it in QRBB vs QRBB and you may want to sacrifice a pawn to force the opponent to develop his king in the second case and not do it in the first case.

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

Re: Definition of "endgame"?

Post by hgm »

The point is not if there are mate positions possible. The search will see and avoid those. The point is if there exist ways to force such mates in a long series of moves, so that the actual mate will be beyond the search horizon, while your fate is already inescapably sealed. The evaluation is for handling such long-term strategic problems.

I am not sure about the way you equate mating chances to the amount of material one should be willing to sacrifice. If the mating chance is large enough, it does not matter what you sacrifice. You just go for that chance, and if it doesn't work out, you are lost.
Last edited by hgm on Thu Jan 31, 2008 7:32 pm, edited 1 time in total.
Harald Johnsen

Re: Definition of "endgame"?

Post by Harald Johnsen »

bob wrote: His point was that the difference between positions with 4 rooks as opposed to just two is probably less significant than the difference between positions with 2 rooks vs none. Linearly scaling based on material is not so good there.
Yes that's right :)
I use a table for the non linear scaling :

Code: Select all

// ------------------------------? K+1+2+3+4+5+6+7 --- space for more pieces...
static int MidGameValueCoef[] = {0,0,0,2,4,5,7,8,8,8,8,8,8,8,8,8,8,8,8};
static int EndGameValueCoef[] = {8,8,8,6,4,2,0,0,0,0,0,0,0,0,0,0,0,0,0};
#define MidGameValue(n,pop)     (((n)*MidGameValueCoef[pop])/8)
#define EndGameValue(n,pop)     (((n)*EndGameValueCoef[pop])/8)
I count 1 for the king and each piece, 2 for the queen, then you can use whatever non linear function to fill the table.

HJ.
Uri Blass
Posts: 10282
Joined: Thu Mar 09, 2006 12:37 am
Location: Tel-Aviv Israel

Re: Definition of "endgame"?

Post by Uri Blass »

hgm wrote:The point is not if there are mate positions possible. The search will see and avoid those. The point is if there exist ways to force such mates in a long series of moves, so that the actual mate will be beyond the search horizon, while your fate is already inescapably sealed. The evaluation is for handling such long-term strategic problems.

I am not sure about the way you equate mating chances to the amount of material one should be willing to sacrifice. If the mating chance is large enough, it does not matter what you sacrifice. You just go for that chance, and if it doesn't work out, you are lost.
1)I think that you cannot trust search because there are leafs nodes that you evaluate.

I practically do not evaluate king safety in pawn endgames because cases when there is mate are rare there but evaluating that the king has no square to go in leaf position may help you to detect mate danger.

Here is another example that I composed
black cannot prevent mate in 2 in the first diagram.
Of course black does not play Rxh4 in the second diagram but it is possible that black get the second diagram instead of getting some winning position because of not evaluating king safety in the endgame
and evaluating that after Rxh4 Kxh4 black has unstoppable passed pawn.

[D]8/p4p1p/5P1k/7P/7K/8/6P1/8 b - - 0 1

[D]8/p4p1p/5P1k/7P/7R/6K1/6P1/7r b - - 0 1



2)Things are not so simple.
It is possible that the opponent is forced to sacrifice material to prevent mate.

If you sacrifice a rook for mate attack and the opponent can prevent the mate and lead the king to safe square by sacrificing a knight then sacrificing a rook was too much.
You are not in binary situation that you have mate or not mate when you save the material advantage.

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

Re: Definition of "endgame"?

Post by bob »

hgm wrote:
bob wrote:I scale as material is removed, not as moves are made.
OK, I see. But let's look at a specific example, Say KQBB+Pawns vs KQBN+Pawns. As black I would not want to come out with my King from behind the Pawn shelter if the opponent still has QBB, as I would be mated very quickly. If the opponent has only KBB, this danger is reduced to about zero, as it is almost impossible to mate with two Bishops (even with King support they can only do it if you are at the board edge).

So wouldn't it be logical to drop King safety completely when Queens are traded? It seems to me this has the character of an all-or-none thing: either the opponent has enough material to mate you in the center of the board, in which case you have to value some protection, or he hasn't.
No. A pair of rooks and a pair of bishops is murderous. In fact, the "trojan horse attack" works with a pair of rooks or a rook and queen on the h-file equally well...

That's why there is not a lot of agreement where to turn it off. Which makes scaling it back slowly more logical. Queens coming off certainly is a significant reduction in king safety, but it should not drop to zero with rooks and minors still on the board, until things get settled/locked in better...