Natural TB

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Rebel, chrisw

User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Natural TB

Post by Evert »

bob wrote: DTM tables have problems, as has been discussed here in the last year (the conversion of a real win into a cursed win and therefore a draw. They also lead to unnatural play (I remember a game vs a GM many years ago where Crafty sacrificed a queen for nothing, in order to translate into a KNNKP ending that was won.
So conceivably, one could, in that situation, detect that you enter the TB because the stronger side sacrifices a piece (your opponent captured and now you have a won TB position, but your own last move was not a capture). In that situation, you know that you have at least a mate-in-X, maybe (probably) better if you don't sacrifice for the conversion. So you can treat the TB score as a lower-bound and continue the search (or switch to a win-seeking or mate search).

Does nothing for Elo, of course, but should be nice for analysis.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Natural TB

Post by bob »

Evert wrote:
bob wrote: DTM tables have problems, as has been discussed here in the last year (the conversion of a real win into a cursed win and therefore a draw. They also lead to unnatural play (I remember a game vs a GM many years ago where Crafty sacrificed a queen for nothing, in order to translate into a KNNKP ending that was won.
So conceivably, one could, in that situation, detect that you enter the TB because the stronger side sacrifices a piece (your opponent captured and now you have a won TB position, but your own last move was not a capture). In that situation, you know that you have at least a mate-in-X, maybe (probably) better if you don't sacrifice for the conversion. So you can treat the TB score as a lower-bound and continue the search (or switch to a win-seeking or mate search).

Does nothing for Elo, of course, but should be nice for analysis.
How do you know that the score before the sac is at least a mate in N? IE suppose you have 5 piece files, but you have a won KNNKP vs you have an extra queen. Leaving the queen on, you might not be able to search to a forced mate, but by checking the opponent where he has to capture (say king is at h8 and you play Qg7+ forcing him to take and transition to a position you know is winning) you end up in a much more difficult ending to win, and it looks unnatural.

Once you are IN a 5 piece ending, your work is not done if using Nalimov, which does not consider the 50 move rule. You might have two choices, move one is a mate in 70 with no captures or pawn pushes, move two is a mate in 80, but the 50 move rule gets reset at move 40. The latter wins, the former draws, but the search prefers the shorter mate which draws (cursed win using current terminology). Again, a problem to solve.
syzygy
Posts: 5557
Joined: Tue Feb 28, 2012 11:56 pm

Re: Natural TB

Post by syzygy »

Michel wrote:
If you capture into a won TB position, then you can cut the tree there: the result of the sub-tree is known. Similar, if you capture into a lost TB position, then you are done: you know that position is lost.
There is a small cosmetic difference in case you are looking for a mate at root. A cut at a TB win/loss may mask a forced mate deeper in the tree which could become part of the PV.

So if window contains mate scores it may make sense (for example in analysis) to enable some kind of mate searching mode.
Yes, this is more or less what I proposed here. If there is reason to look for a more accurate score than "TB win" (which is only the case if "TB win" < beta), then continue the search of the subtree (but without probing TBs, obviously). If the continued search finds a mate, return the mate score. Otherwise, return the "TB win" score as the mate is apparently still too deep to find.
syzygy
Posts: 5557
Joined: Tue Feb 28, 2012 11:56 pm

Re: Natural TB

Post by syzygy »

Michel wrote:So we should think of a tbwin,draw,loss as a lowerbound, exact score, upperbound... Is this theoretically correct?
At the moment, SF treats a TB win exactly like a mate (but with a lower score), including the subtraction of the distance from root to TB win etc. So SF will not look "beyond" the TB win until the TB win is on the board.

If the search is adapted to search "beyond" the TB win if TB_win < beta, then TB_win would effectively become the exact score returned by searches of the position that do not yet manage to find mate (except that it will have this distance to the root added to / subtracted from it). Once the position is searched with enough depth, mate will be found and the search will return a mate value instead. But it is completely normal that searching deeper leads to a different score.

I think there is no theoretical problem here, but I may overlook something. I have not implemented this in my own engine.
syzygy
Posts: 5557
Joined: Tue Feb 28, 2012 11:56 pm

Re: Natural TB

Post by syzygy »

Dirt wrote:
mcostalba wrote:As a secondary side effect I am trying hard to avoid DTZ probing because I think that if only WDL tables are present we can easily have 5-men in memory (374M for WDL against 922M for WDL+DTZ)
Is loading in one 5-piece DTZ table per game too much? I suppose if you are very short of time it might be, but that decision looks to be better made at the time.
Exactly...

Maybe Marco thinks DTZ is being probed all around the search tree?
syzygy
Posts: 5557
Joined: Tue Feb 28, 2012 11:56 pm

Re: Natural TB

Post by syzygy »

lucasart wrote:To sum up:
* Negative: We lose the "best defense" (defined as: maximize DTZ when you're losing). Sure it has no elo impact, especially if then opponent uses TBs, but it has an educational value for those studying endgames if SF can show the correct defense in TB positions.
I am sorry, but yet again an example of unwillingness to think for a few seconds.

Of course you lose playing strength. Botched-up SF will not be able to win a DTZ=99 winning position against current SF.
* Positive: Symmetrically, we lose the "best attack" defined as minimizing DTZ. However, the real target is DTM not DTZ. More often than not, we see these unnatural sacrifices aiming at reducing DTZ instead of aiming at reducing DTM (for which it's best to let the search do its work). So I think we have a gain overall in this area.
Again, you apparently do not really know what you are talking about.
In a 5-piece position with 5-piece TBs, current SF does not make any unnatural sacrifices. If you don't understand this, you lack knowledge of what SF is actually doing. And personally I think it a bad idea to try to "fix" or "improve" code that you simply have not taken the time to understand in the first place.
* Positive: code simplification. And we don't need DTZ tables (reduce by half the size of the download for users).
The users will be delighted!
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Natural TB

Post by Evert »

bob wrote: How do you know that the score before the sac is at least a mate in N?
Because you can drop the piece to make it so. You know the position is won, but the win you found involves dropping a piece. Sure, it could be a necessary sacrifice, but in this example that seems unlikely.
So if you assume that is the case, then you can do a mate-search to see whether you can do better.

It's no different from finding the long-but-easy mate instead of the fast-but-difficult mate (due to reductions/extensions). Normally you don't try to find a faster mate once you've established that the root position leads to mate, but you could.
IE suppose you have 5 piece files, but you have a won KNNKP vs you have an extra queen. Leaving the queen on, you might not be able to search to a forced mate,
Well, that's the rub: you might not be able to search to the supposed faster mate. Either way, by not searching for it you're sure not to find it.
All of this makes more sense for analysis than for game-play though.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Natural TB

Post by bob »

Evert wrote:
bob wrote: How do you know that the score before the sac is at least a mate in N?
Because you can drop the piece to make it so. You know the position is won, but the win you found involves dropping a piece. Sure, it could be a necessary sacrifice, but in this example that seems unlikely.
So if you assume that is the case, then you can do a mate-search to see whether you can do better.

It's no different from finding the long-but-easy mate instead of the fast-but-difficult mate (due to reductions/extensions). Normally you don't try to find a faster mate once you've established that the root position leads to mate, but you could.
IE suppose you have 5 piece files, but you have a won KNNKP vs you have an extra queen. Leaving the queen on, you might not be able to search to a forced mate,
Well, that's the rub: you might not be able to search to the supposed faster mate. Either way, by not searching for it you're sure not to find it.
All of this makes more sense for analysis than for game-play though.
This fails in several ways. What about KNN vs KP? You can't drop the pawn as it is a draw. And what if, in the KNNQ vs KP you drop the queen and find it is a mate, what do you do? Search without using the tables to avoid tossing the queen? I'd bet one could construct a number of endgame positions where the trade wins by a long mate, but not trading leads to a forced draw.

When you have imperfect information, you make imperfect decisions. I don't see the point in trying for the most aesthetic win, any win will do. Humans generally don't find the shortest mate yet we don't see anyone complaining.

There was a time when "computer move" meant a bad/terrible move. Today it usually means "something the humans didn't see or understand, but it is clearly winning."
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Natural TB

Post by bob »

syzygy wrote:
Dirt wrote:
mcostalba wrote:As a secondary side effect I am trying hard to avoid DTZ probing because I think that if only WDL tables are present we can easily have 5-men in memory (374M for WDL against 922M for WDL+DTZ)
Is loading in one 5-piece DTZ table per game too much? I suppose if you are very short of time it might be, but that decision looks to be better made at the time.
Exactly...

Maybe Marco thinks DTZ is being probed all around the search tree?
His comments and your explanation would seem to make that not so likely? It's been a known problem since WDL hit the street.

This seems to be more about trying to avoid some of the silly sacrifices to reach won endgame positions that we see... First, I am not sure it is possible to do so and second, I certainly don't see why it is worth any effort.
syzygy
Posts: 5557
Joined: Tue Feb 28, 2012 11:56 pm

Re: Natural TB

Post by syzygy »

bob wrote:
syzygy wrote:
Dirt wrote:
mcostalba wrote:As a secondary side effect I am trying hard to avoid DTZ probing because I think that if only WDL tables are present we can easily have 5-men in memory (374M for WDL against 922M for WDL+DTZ)
Is loading in one 5-piece DTZ table per game too much? I suppose if you are very short of time it might be, but that decision looks to be better made at the time.
Exactly...

Maybe Marco thinks DTZ is being probed all around the search tree?
His comments and your explanation would seem to make that not so likely? It's been a known problem since WDL hit the street.
If he is aware that current SF only probes DTZ at the root, then why would he be concerned about RAM that DTZ might take up?
This seems to be more about trying to avoid some of the silly sacrifices to reach won endgame positions that we see... First, I am not sure it is possible to do so and second, I certainly don't see why it is worth any effort.
We agree on that.