Natural TB

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

Moderators: hgm, Rebel, chrisw

jhellis3
Posts: 546
Joined: Sat Aug 17, 2013 12:36 am

Re: Natural TB

Post by jhellis3 »

The point is that by not playing the immediate sacrifice (and doing some other useful move instead) you may bring a win nearer which may ultimately not involve any sacrifice at all.
From a human perspective, it might make some sense if they are not sure if the sac is a 100% win. Stall and look for something better...

An engine on the other hand, is going to see to depth X, and all else being equal there is no reason to guess that it will be able to find a shorter or "better" win later as available time is an ever decreasing commodity. Of course if it can see the "better" win it will take it, but it won't speculatively gamble on the existence of one. The engine also does not suffer from doubt as humans do. So I would say if a human could have the certainty of an engine, he or she would play in the same way. Obviously, this is not the case, but I would say both approaches are logical given their respective operating conditions.
petero2
Posts: 688
Joined: Mon Apr 19, 2010 7:07 pm
Location: Sweden
Full name: Peter Osterlund

Re: Natural TB

Post by petero2 »

bob wrote:(1) sacrificing your queen takes you into a won 6 piece ending, but one which is harder to win than keeping the queen on. Unfortunately, you can't search nearly deep enough to see the win with the queen kept on the board, so transitioning to the egtb win is the only winning option you can see;
Do you have an example of such a position? It seems to me that if you are enough ahead to still be able to win after a queen sacrifice, you will also often be able to force a more advantageous trade if you keep searching.

The hardest position I could find after arbitrarily trying some positions was this:
[D]8/4bk2/4br2/8/8/8/8/QRRK4 w - - 0 1
Even in this position it only takes texel about 2.5 seconds to find something better than the queen sacrifice:

Code: Select all

  1	+7.74	126	0:00.00	Qe5 Rf1+ 
  2	+7.69	567	0:00.00	Qe5 Rf5 
  2	+20.51	693	0:00.00	Qxf6+ Kxf6 
  2	+20.51	809	0:00.00	Qxf6+ Ke8 Qxe6 
  3	+98.29	866	0:00.00	Qxf6+ Ke8 Qxe6 
  3	+7.22	1092	0:00.00	Qxf6+ Ke8 Qxe7+ Kxe7 
  3	+98.85	1165	0:00.00	Qxf6+ Kxf6 
  4	+98.85	1390	0:00.00	Qxf6+ Kxf6 
  5	+98.85	3522	0:00.02	Qxf6+ Kxf6 Rc6 Kf7 
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+ Kc4 Qxh5 Kb3 Qa5 Kb2 Qa4 Kb1 Ke3 Kb2 Kd2 Kb1 Kc3 Kc1 Qa1# 
 14	+99.71	537.2M	0:16.96	Rc7 Bg4+ Kd2 Rd6+ Ke3 Re6+ Kf4 Bh5 Rxe7+ Rxe7 Rb6 Re6 Rxe6 Kxe6 Qe5+ Kd7 Qxh5 Kc6 Qa5 Kd6 Kf5 Kc6 Ke6 Kb7 Kd6 Kb8 Kc6 Kc8 Qc7# 
 15	+99.73	897.7M	0:30.05	Rc7 Bg4+ Kd2 Rd6+ Ke3 Re6+ Kf4 Bh5 Rxe7+ Rxe7 Kg5 Bf3 Qf6+ Ke8 Qxf3 Rg7+ Kh6 Ra7 Qc6+ Kf7 Qd6 Re7 Qg6+ Kf8 Rf1+ Rf7 Qxf7# 
 16	+99.73	1868.5M	1:06.13	Rc7 Rf5 Rxe7+ Kxe7 Qg7+ Bf7 Rb7+ Ke6 Ke2 Bh5+ Kd3 Rd5+ Ke4 Bf3+ Kxf3 Ra5 Qc3 Ra3 Qxa3 Kd5 Qc1 Ke5 Qc5+ Ke6 Ke4 Kf6 Qf5# 
I don't doubt there exist positions that would require a long search to find something better than a queen sacrifice, but I guess such positions are very rare.
syzygy
Posts: 5563
Joined: Tue Feb 28, 2012 11:56 pm

Re: Natural TB

Post by syzygy »

bob wrote:Just as there is no solution when you have to choose between the two following cases:

(1) sacrificing your queen takes you into a won 6 piece ending, but one which is harder to win than keeping the queen on. Unfortunately, you can't search nearly deep enough to see the win with the queen kept on the board, so transitioning to the egtb win is the only winning option you can see;

(2) keeping your queen, knowing that the sac wins, and NOT knowing that keeping the queen on doesn't draw or lose.

There's not any way to solve that, nor is there any reason to spend time trying to solve it. The goal is to win the game.
Exactly. The solution is to declare it a non-problem :-)

But if it needs to be improved, then it would first be necessary to pin down what is "acceptable" behaviour and what is not. For example, if the PV ends in a queen sac into a winning 6-piece position, is that considered problematic? Is it considered problematic that the engine reports a winning score when it has determined with 100% certainty that the position is a win?

And when is this a problem? In engine-engine play? Or in human-engine play? Or for analysis?

If someone is using TBs in analysis, is it REALLY a problem if the engine proposes a queen sac in a KQBBvKN position? Why would anyone serious spend time analysing a plainly winning KQBBvKN position in the first place? (Btw, current SF with 6-piece TBs will certainly not sack its queen in a winning KQBBvKN position. But it might do so in a KQBBNvKN position.)

I agree that pure DTZ-minimising play is problematic for TCEC spectators.
I also agree that playing out 6-piece endgames in TCEC is problematic where the winning side has 6-piece TBs and does not speed up its play.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Natural TB

Post by Evert »

bob wrote: There's not any way to solve that, nor is there any reason to spend time trying to solve it. The goal is to win the game.
If that is your only goal, then indeed there is nothing to fix or discuss: you find a win, you play the sequence of moves and call it a day.

If your goal is something other than simply winning the game, then it becomes more interesting, and then one can decide whether it's worth spending time thinking about the issue (and whether or not it should be considered a problem).

The transition from a score based on evaluation ("heuristic") to tablebase score is a form of evaluation discontinuity, albeit a purely cosmetic issue (unlike the discontinuity that occurs if one uses a hard switch from opening to end-game scoring). If one thinks there's something to solve here, then perhaps some sort of smoothing can help (I'm not sure how; one doesn't normally smoothen the discontinuity between a heuristic evaluation and a mate score either).
But a Multi-PV like approach seems more reasonable, and fits better with what one could already do for analysis purposes.
BBauer
Posts: 658
Joined: Wed Mar 08, 2006 8:58 pm

Re: Natural TB

Post by BBauer »

I remember trying to solve several times a chess problem from a news
paper.
I gave the problem to stockfish but did not got the mate in n, but a mate in n+1.
So I tried MultiPV. Here I saw several mates in n+1 and some 123.xx scores.
Now I removed syzygy use and I got the mate in n I was after.

Should this be the solution?
Kind regards
Bernhard
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Natural TB

Post by bob »

Vinvin wrote:
bob wrote:
Laskos wrote:
Vinvin wrote:
Laskos wrote:

Code: Select all

(Avg game length = 8.915 sec)
...
Way to short to be serious. Not shorter than 5 sec/move, please !

The only difference (between Syzygy and natural) should be when there's positions with 5 pieces or less, isn't it ? Because with more than 5 pieces, they play same moves (from the WDL files).
So, natural draw instead of winning games with 5 pieces. What are these positions (if you saved games) ?
I think TBs can be tested at ultra-fast, but it's safer to test at a bit longer tc. Also, as Marco observed, the result for 6-10 men endgames is within error margins, too few games. Yes, I don't know how Natural can be in any way better than Syzygy from more than 5 pieces.

Here are examples of 5-men hard wins, I have several hundred of them, please check these. Natural fails to win copiously on many of them.

8/8/8/8/3n4/6K1/k7/2B2B2 w - -
2B5/6B1/3K4/8/8/8/2kn4/8 w - -
4B3/6n1/8/8/1K5k/8/8/6B1 w - -
8/8/8/8/8/1n6/1k3K1B/1B6 w - -
6n1/8/7k/1K6/7B/5B2/8/8 w - -
8/8/8/6Bk/8/8/K7/5Bn1 w - -
8/3BB3/8/8/4k3/1K6/5n2/8 w - -
6K1/k7/8/8/8/3n1B2/3B4/8 w - -
4k3/8/3n4/8/8/8/4B1K1/B7 w - -
8/4n3/4B3/8/8/4B3/1K6/5k2 w - -
1B3k2/8/8/8/6n1/2K5/8/7B w - -
2k2B2/8/8/8/8/8/6B1/K2n4 w - -
6B1/B3n3/8/8/8/5K2/8/1k6 w - -
3BK3/8/8/5B2/8/5k2/8/n7 w - -
8/1B6/3B4/2K5/8/4n3/2k5/8 w - -
6K1/k7/8/2n1B3/6B1/8/8/8 w - -
1K3B1k/8/8/8/8/5n2/8/5B2 w - -
Are you using a somewhat unusual definition of "copiously"??? IE does this mean easily, or quickly, or with least loss of material? I assume it does not mean that "natural fails to win when it should in many of them?"
I search in dictionaries, "copiously" means "In abundant quantity". It's not a bad word in this context.
(In French it's about the same word for the same meaning : "copieusement" )
I understand the meaning, but it didn't fit quite right in the statement to me. "abundant quantity of what?" Wins? Material (not sacrificed)? Etc...
syzygy
Posts: 5563
Joined: Tue Feb 28, 2012 11:56 pm

Re: Natural TB

Post by syzygy »

Evert wrote:But a Multi-PV like approach seems more reasonable, and fits better with what one could already do for analysis purposes.
Multi-PV is not going to help where the only win that the engine can see is by a conversion into TBs. Basically the engine will need to decide that it does not want the TB win...
syzygy
Posts: 5563
Joined: Tue Feb 28, 2012 11:56 pm

Re: Natural TB

Post by syzygy »

bob wrote:I understand the meaning, but it didn't fit quite right in the statement to me. "abundant quantity of what?" Wins? Material (not sacrificed)? Etc...
Perhaps "by many moves"? They are all winning positions that are difficult to convert within the 50-move rule, I guess.
syzygy
Posts: 5563
Joined: Tue Feb 28, 2012 11:56 pm

Re: Natural TB

Post by syzygy »

BBauer wrote:I remember trying to solve several times a chess problem from a news
paper.
I gave the problem to stockfish but did not got the mate in n, but a mate in n+1.
So I tried MultiPV. Here I saw several mates in n+1 and some 123.xx scores.
Now I removed syzygy use and I got the mate in n I was after.
This is because the mate-in-n at some point reached a 6-piece position and at that point got evaluated as a TB win.

Solving this without sacrificing strength would be an improvement. I have already outlined an approach that I think should work, but have not yet tried to implement it. (Texel probably already does this and more.)

The solution would still not prevent queen sacs, though. (It might prevent a few of them.)
jhellis3
Posts: 546
Joined: Sat Aug 17, 2013 12:36 am

Re: Natural TB

Post by jhellis3 »

Here is the fix applied to vanilla SF if anyone is interested:

https://github.com/jhellis3/Stockfish/tree/tb_fix_1

[D]8/2P1P3/3k4/8/8/4K3/P2p1p2/8 b - -

512MB Hash, Single Thread:

Vanilla (with TBs) @ ~200 seconds: Depth 51, score +123.xx, short line displayed

Patch @ ~200 seconds: Depth 49, score Mate in 14, full line displayed (starts returning mate scores at d31)

Vanilla (sans TBs) @ ~80 seconds: Depth 40, score Mate in 14, full line displayed (starts returning mate scores at d35)