Natural TB

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

Moderators: hgm, Rebel, chrisw

PK
Posts: 893
Joined: Mon Jan 15, 2007 11:23 am
Location: Warsza

Re: Natural TB

Post by PK »

I think there was a discussion a while back about mate-distance pruning. Does it serve a purpose? Yes, but it doesn't change the outcome of the game. Does it add Elo? No, because it doesn't change the outcome of the game.
Doesn't it? Suppose an engine is searching a position with a couple of non-lethal mate threats to a decent depth. Checkmates are avoidable, but it takes time to learn about it. Mate distance pruning reduces this time a bit, so the engine has a bit more time for non-losing alternatives.

Of course the Elo gain is small, but it is there.
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: Natural TB

Post by mcostalba »

Michel wrote:
Scholars just understand legacy and always lack behind new developments (never anticipate or foresee them), sometime even many years later...
Remember when you were pushing for dynamic contempt in SF as a magic bullet?

When people said caution was required (extra ordinary claims require extra ordinary proof) you made similar comments.

But in the end dynamic contempt didn't work did it?
Well, I don't' remember this thing about contempt, actually I didn't like it and I still don't like contempt even if it is merged in SF since long ago.

But if I really pushed for dynamic contempt (or anything else new) and it failed, well I would push again in the future and redoing the same "mistake" for anything that seems new and encouraging to me.

I am not worried to do such mistakes, if the alternative is don't do anything because was already done by people very long ago: this is not how things progress, how things evolve.

New developments pass through doing and mistake! There was never progress in defending the status quo (even more with pure argumentative and qualitative positions, without any quantitative and experimental evidence).
User avatar
hgm
Posts: 27790
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Natural TB

Post by hgm »

syzygy wrote:Yes, and then it still makes the "unnatural" move. To avoid that, the engine will somehow have to decide that it does not want the TB win: "My position is so good that there must be a win that does not involve sacking my queen". That should be possible to implement, but of course it will then fail to win won games in certain circumstances.
I don't think it has to be as bad as that. You can still do it in a way that guarantees the win:

In the root, decide which moves preserve the forced win. This can be done by never allowing alpha in the root to rise above the score for a tablebase win. Moves that fail low compared to this threshold are removed from the move list. Then redo the search using only the moves that preserve the win, where you disabled probing of all 'inferior' tables.

The worst thing that can happen then is that it gets very reluctant to win in pathological cases (e.g. where the sacrifice is really the only way to win, because the superfluous piece was trapped anyway). It would then muddle on for a long time without sacrifice, until the 50-move barrier forces it to make the conversion. Arguably even this should count as 'natural play', as it is exactly what a human player would do when he is not bright enough to realize that the better material against normal expectation could not do the job.

It would still make the sacrifice early when the forced conversion was in danger of evaporating (i.e. none of the other moves can be proven to be a win). But in this case it could be seen as a brilliant sacrifice. (E.g. it could be that you sac a Queen, and some moves later gain it back, or get a new one through promotion, and only win the inferior end-game because of that.)

You could also do it the other way around: after you established the root contains a forced win, first search with probing inferior EGTs disabled. Each time a move beats alpha you repeat the search with the probing now enabled. If the move returns a tablebase win, you are done with this iteration. If not, the move is not acceptable (at this depth), and you continue the iteration with the next move. So at ply level 1 any fail low would trigger a verification search with all probing on to prove it fails 'very low' (i.e. a tablebase loss), and if it doesn't, you return beta instead of the fail-low score.
Michel
Posts: 2272
Joined: Mon Sep 29, 2008 1:50 am

Re: Natural TB

Post by Michel »

I am not worried to do such mistakes, if the alternative is don't do anything because was already done by people very long ago: this is not how things progress, how things evolve.
The point is not about making mistakes. The point is about refraining from insulting language when people point out obvious problems with your ideas.

In this case you claim that with refusing immediate TB cutoffs - when a-b search dictates you should take them - you can somehow make a better search.

It may be that you have done a briljant new discovery (which then should be explained) but standard scientific practice based on centuries of experience dictates this should not be the default assumption.

Indeed the idea should be carefully tested and to compare apples with apples the optimizations you added on top of it should also be tried with the traditional a-b implementations of TB search where TB scores are just regular a-b bounds (e.g. like in Texel).
Ideas=science. Simplification=engineering.
Without ideas there is nothing to simplify.
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: Natural TB

Post by mcostalba »

Michel wrote: Indeed the idea should be carefully tested
Of course it should be carefully tested!

The point is that the traditional approach of people to TB assumes (implicitly and even without realizing it) that without TB engine is lost. This is very wrong and even more wrong today with powerful engines/hardware we have: engine is able to find the win in 99.9% of cases all alone by itself. TB is just the cherry on the cake in the very rare cases engine is not able to work out the position. If you start from this point of view (that is somewhat controversial), you will see that perhaps TB could "hint" the engine more then strictly command it and perhaps these extra hints are enough not to lose ELO in normal games.

Another point of view you should think of is that TB are not needed (to increase ELO) when root position is in TB. This is perhaps even more controversial than the assumption above, but IMO TB are useful to make the engine stronger in the middle-game, not in the endgame. It's in the middle-game that you lack the depth to workout the endgame at the end of the PV, and it's in the middlegame that TB can more often overrule the search (because at middlegame the search of the endgames sub-tree is very shallow and mainly rely on the evaluation). Assuming the above it is possible that probing at the end of the search is more efficient because you call probe less times (for instance all null search, razoring, etc don't end up in a TB probe because engine cut-offs earlier), but at the same time it is still a valuable help for the search. So as you see, the picture is much more complex than simply choosing what TB win/loss scores to return. So complex that only testing legacy vs natural TB in real games will give us the answer.
syzygy
Posts: 5557
Joined: Tue Feb 28, 2012 11:56 pm

Re: Natural TB

Post by syzygy »

Evert wrote:
syzygy wrote:Yes, and then it still makes the "unnatural" move. To avoid that, the engine will somehow have to decide that it does not want the TB win: "My position is so good that there must be a win that does not involve sacking my queen". That should be possible to implement, but of course it will then fail to win won games in certain circumstances.
Of course you play the "unnatural" move if you don't find an alternate win; I don't think anyone argues doing anything different.
I'm not really sure that everybody here thinks "unnatural" moves are (sometimes) acceptable. But we agree that they are if no other move is known to win.
If you don't look for an alternative win, you're sure not to find it. That you look for it doesn't mean that you will find it (assuming it does exists).

Again though, I think it's only remotely relevant for analysis. If you just want to win the game and don't care how, none of these cosmetic effects matter.

I think there was a discussion a while back about mate-distance pruning. Does it serve a purpose? Yes, but it doesn't change the outcome of the game. Does it add Elo? No, because it doesn't change the outcome of the game. This is not so different.
The added element here is that at least some of the "solutions" proposed (not yours) are certain to change the outcome of some games.
Daniel Shawul
Posts: 4185
Joined: Tue Mar 14, 2006 11:34 am
Location: Ethiopia

Re: Natural TB

Post by Daniel Shawul »

Good job!
Positive: code simplification. And we don't need DTZ tables (reduce by half the size of the download for users)
That is why Scorpio bitbases have only WDL. 6-men are just 48 GBs. Compare that to syg-bulky-gyz :lol: :lol:
Rein Halbersma
Posts: 741
Joined: Tue May 22, 2007 11:13 am

Re: Natural TB

Post by Rein Halbersma »

mcostalba wrote: Another point of view you should think of is that TB are not needed (to increase ELO) when root position is in TB. This is perhaps even more controversial than the assumption above, but IMO TB are useful to make the engine stronger in the middle-game, not in the endgame. It's in the middle-game that you lack the depth to workout the endgame at the end of the PV, and it's in the middlegame that TB can more often overrule the search (because at middlegame the search of the endgames sub-tree is very shallow and mainly rely on the evaluation). Assuming the above it is possible that probing at the end of the search is more efficient because you call probe less times (for instance all null search, razoring, etc don't end up in a TB probe because engine cut-offs earlier), but at the same time it is still a valuable help for the search. So as you see, the picture is much more complex than simply choosing what TB win/loss scores to return. So complex that only testing legacy vs natural TB in real games will give us the answer.
In draughts, databases give a lot more ELO than in chess. The problem there is not that you want to second-guess db wins/losses, but rather that db draws can be too pessimistic! A db draw in an advantageous position is something that you might want to ignore. Trying to distinguish db draws from heuristic draws in an alpha-beta framework leads into speculative play.
syzygy
Posts: 5557
Joined: Tue Feb 28, 2012 11:56 pm

Re: Natural TB

Post by syzygy »

Michel wrote:
I am not worried to do such mistakes, if the alternative is don't do anything because was already done by people very long ago: this is not how things progress, how things evolve.
The point is not about making mistakes. The point is about refraining from insulting language when people point out obvious problems with your ideas.
The best thing of course is starting this thread claiming to have added something new to SF which was not new at all. Or take something like
mcostable wrote:The idea is to use TB but avoiding the unnatural TB scores and in particular the DTZ ones (hiding mates, unnatural sacrifices, etc)
Whatever current SF does with DTZ, it certainly is in no way responsible for any unnatural moves or scores. But Marco does not know this. Or maybe now he understands, but obviously he will not admit.
mcostable wrote:but retain the 'good play' of syzygy where 'good play' is defined as follow:

If in a given position SF with old syzygy leads to a win, then it should do also now with 'Natural TB'
So, quite clearly, it does not. I know this without testing, because without DTZ it is simply not possible to achieve this "good play". 2+2=4.

In the meantime, it seems Marco has understood that probing only at the leaves is not a particularly good idea. I guess it took him a lot of testing to realise that 2+2 remains 4. And for the rest, exactly nothing that I have stated has been refuted by him.

Maybe we should tell him about the problem of squaring the circle and that it has been mathematically proven to be impossible. We could create a special corner on this forum for his weekly solutions.
syzygy
Posts: 5557
Joined: Tue Feb 28, 2012 11:56 pm

Re: Natural TB

Post by syzygy »

Rein Halbersma wrote:
mcostalba wrote: Another point of view you should think of is that TB are not needed (to increase ELO) when root position is in TB. This is perhaps even more controversial than the assumption above, but IMO TB are useful to make the engine stronger in the middle-game, not in the endgame. It's in the middle-game that you lack the depth to workout the endgame at the end of the PV, and it's in the middlegame that TB can more often overrule the search (because at middlegame the search of the endgames sub-tree is very shallow and mainly rely on the evaluation). Assuming the above it is possible that probing at the end of the search is more efficient because you call probe less times (for instance all null search, razoring, etc don't end up in a TB probe because engine cut-offs earlier), but at the same time it is still a valuable help for the search. So as you see, the picture is much more complex than simply choosing what TB win/loss scores to return. So complex that only testing legacy vs natural TB in real games will give us the answer.
In draughts, databases give a lot more ELO than in chess. The problem there is not that you want to second-guess db wins/losses, but rather that db draws can be too pessimistic! A db draw in an advantageous position is something that you might want to ignore. Trying to distinguish db draws from heuristic draws in an alpha-beta framework leads into speculative play.
Yes, this an area where improvement certainly is possible. Unfortunately there is no good way for SF to know whether the opponent is using TBs as well.

If the opponent has no TBs, then a cursed win has a very high probability of being won (by current SF, that is). And a cursed loss is sure to be drawn against any opponent (again, by current SF). So -0.01 for a cursed loss is exactly right (ignoring contempt), but a cursed loss should probably count as at least +1 unless the opponent is expected to use TBs.

And more generally it is certainly true that not all TB draws are equal. If for no other reason, distinguishing slightly between a drawn KRPPvKR and a drawn KNPvKRP could mean the avoidance of unnatural conversions into drawn TB positions that are unnecessarily inferior.

One can think of many other potential improvements to how current SF handles TBs. After all, the current implementation was intended only as a reference implementation. But, as with everything in science and engineering, finding improvements is facilitated by prior understanding of the issues involved.