King opposition

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

King opposition

Post by lucasart »

As a general rule of thumb, which kind of direct opposition (distance = 2) is better, when it is *your* turn to play:

1/ kings are front of each other (eg. D4 and D6)
2/ kings are one knight move away from each other (eg. D4 and C6)
3/ kings are diagonally opposed (eg. D4 and B6)

This is something I would like to experiment with, in the context of pawn endings only.
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
Aleks Peshkov
Posts: 892
Joined: Sun Nov 19, 2006 9:16 pm
Location: Russia

Re: King opposition

Post by Aleks Peshkov »

King endgame is about Zugzwang.
When you are on move, you bonus opponent's king for opposition.

(1) and partially (3) is in favor for not side to move.
(2) and many others do not mean anything, unless you can occupy an opposition later.
cetormenter
Posts: 170
Joined: Sun Oct 28, 2012 9:46 pm

Re: King opposition

Post by cetormenter »

The Stockfish team tried experimenting with this. Perhaps not enough effort was put into the idea but in the end the tests failed. Surprisingly it seems that NOT having the opposition did better than having it. However this probably was just statistical noise and one of the tests got lucky/unlucky.

http://tests.stockfishchess.org/tests/v ... 344346beea

http://tests.stockfishchess.org/tests/v ... 344346beec
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: King opposition

Post by lucasart »

cetormenter wrote:The Stockfish team tried experimenting with this. Perhaps not enough effort was put into the idea but in the end the tests failed. Surprisingly it seems that NOT having the opposition did better than having it. However this probably was just statistical noise and one of the tests got lucky/unlucky.

http://tests.stockfishchess.org/tests/v ... 344346beea

http://tests.stockfishchess.org/tests/v ... 344346beec
What I tried in DiscoCheck is to alter the value of a tempo in cases of king opposition for pawn endgames. I followed Alex's advice and scores 1/ and 3/ worst (tempo = -4cp i/o +4cp), and for 2/ I used tempo = 0. The difference was not measurable, and possibly a regression.

So I abandonned the idea. It doesn't mean that the idea of using king opposition cannot work, but I don't think it can work in such a simplistic form. In a pawn endgame, when I looked at the positions where the conditions were triggered, I realized that the vast majority is determined by the pawns, and the relationship between the kings and the pawns. The opposition is just looking at kings in isolation and is a very minor factor.

Regarding the SF patch, I think they did it the wrong way around: they bonus the side to move for having the frontal opposition. Instead it should be a penalty, as pointed out by Alex Peshkov.
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
cetormenter
Posts: 170
Joined: Sun Oct 28, 2012 9:46 pm

Re: King opposition

Post by cetormenter »

Did you look at both of the links? The second one was a bug fix to fix exactly that issue. I believe the patch failed simply because there was too much weight given to this term. If one side had the opposition then it would be given ~15.5 CP (40 / 258) of an advantage. I believe like you said, that this idea is being applied too simplistically as there are many positions where you do not need to strive to gain the opposition. Also, this factor does not take into account the ability of the opponent to gain back the opposition. Through a series of pawn moves your opponent may be able to regain opposition and then take the game.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: King opposition

Post by bob »

lucasart wrote:As a general rule of thumb, which kind of direct opposition (distance = 2) is better, when it is *your* turn to play:

1/ kings are front of each other (eg. D4 and D6)
2/ kings are one knight move away from each other (eg. D4 and C6)
3/ kings are diagonally opposed (eg. D4 and B6)

This is something I would like to experiment with, in the context of pawn endings only.
Opposition is opposition. Not quite sure what you are asking. It is simply a measure of which king has to "give way"...

I also don't understand 2. There you don't have opposition. With the kings at d4/d6, whomever has to move has to give way. Ditto for the diagonal opposition. But in case 2, the side to move has direct opposition because the king on c6 can move to d6 and has direct opposition, or the king on d4 can move to c4, again with direct opposition.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: King opposition

Post by bob »

cetormenter wrote:The Stockfish team tried experimenting with this. Perhaps not enough effort was put into the idea but in the end the tests failed. Surprisingly it seems that NOT having the opposition did better than having it. However this probably was just statistical noise and one of the tests got lucky/unlucky.

http://tests.stockfishchess.org/tests/v ... 344346beea

http://tests.stockfishchess.org/tests/v ... 344346beec
This makes no sense. Opposition is critical in KPK, for example. If you don't know about opposition, you have practically no chance of winning when you should win, or drawing when you should (from losing side)...
syzygy
Posts: 5563
Joined: Tue Feb 28, 2012 11:56 pm

Re: King opposition

Post by syzygy »

bob wrote:
cetormenter wrote:The Stockfish team tried experimenting with this. Perhaps not enough effort was put into the idea but in the end the tests failed. Surprisingly it seems that NOT having the opposition did better than having it. However this probably was just statistical noise and one of the tests got lucky/unlucky.

http://tests.stockfishchess.org/tests/v ... 344346beea

http://tests.stockfishchess.org/tests/v ... 344346beec
This makes no sense. Opposition is critical in KPK, for example. If you don't know about opposition, you have practically no chance of winning when you should win, or drawing when you should (from losing side)...
You claimed recently that having or not having KPK knowledge in whatever form really did not matter in terms of Elo.

Anyway, Stockfish has a bitbase for KPK.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: King opposition

Post by bob »

syzygy wrote:
bob wrote:
cetormenter wrote:The Stockfish team tried experimenting with this. Perhaps not enough effort was put into the idea but in the end the tests failed. Surprisingly it seems that NOT having the opposition did better than having it. However this probably was just statistical noise and one of the tests got lucky/unlucky.

http://tests.stockfishchess.org/tests/v ... 344346beea

http://tests.stockfishchess.org/tests/v ... 344346beec
This makes no sense. Opposition is critical in KPK, for example. If you don't know about opposition, you have practically no chance of winning when you should win, or drawing when you should (from losing side)...
You claimed recently that having or not having KPK knowledge in whatever form really did not matter in terms of Elo.

Anyway, Stockfish has a bitbase for KPK.
I simply gave an example of where opposition is important. However, if you are going to analyze endgame positions, this will certainly be significant... In real games, not so much.
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: King opposition

Post by lucasart »

bob wrote: This makes no sense. Opposition is critical in KPK, for example. If you don't know about opposition, you have practically no chance of winning when you should win, or drawing when you should (from losing side)...
Your reasoning is flawed, because the "you" in this sentence refers to a human player. Yes, of course, human players think in terms of opposition to win a winnable KPK endgame. But my engine, even at the most stupidly fast time control, will easily win any winnable KPK endgame, simply by passed pawn knowledge (which incentivised pushing the passed pawn): the search finds the way to push the pawn.

Also, testing results are what they are. Making sense or not is completely irrelevant. There are thousands of things that make sense, and have been tried (in SF and many other engines), but did not work. There are even things that work but don't make sense. Of course it's more of an intellectual satisfaction when you add an eval term that makes sense and works in testing, but it doesn't happen that often in my experience (when you have passed the stage of getting all the basics right in your eval).
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.