ask here: http://www.talkchess.com/forum/viewtopic.php?t=59904Onegin wrote:Why not use both DTM and DTZ metrics instead of using engine search?
or here http://www.talkchess.com/forum/viewtopic.php?t=47681
this is technical topic for devs
Moderator: Ras
ask here: http://www.talkchess.com/forum/viewtopic.php?t=59904Onegin wrote:Why not use both DTM and DTZ metrics instead of using engine search?
If they returned DTM they would be DTM tables, not WDL tables. WDL tables only return whether the position is a win, draw or loss. That is why they are called WDL tables. So the Syzygy tables are not really WDL tables but a kind of extended WDL, as they also contain cursed wins and blessed losses as 4th and 5th possibility.Onegin wrote:I am a member of TalkChess.com and I accidentally stumbled into your discussion. I am an average computer user but can anybody answer my simple question about Syzygy tablebases. Why wdl TBs do NOT return DTM metric but simply a number -2, -1, 0, 1 or 2. Why not use both DTM and DTZ metrics instead of using engine search?
Yes, I've seen those forums before, the ones you posted links to, especially the first post on Syzygy tablebases by de Man. That was 3 years ago when he first created those TBs. But I'm still not sure I know how they work. So I thought somebody could answer some questionsyurikvelo wrote:ask here: http://www.talkchess.com/forum/viewtopic.php?t=59904Onegin wrote:Why not use both DTM and DTZ metrics instead of using engine search?
or here http://www.talkchess.com/forum/viewtopic.php?t=47681
this is technical topic for devs
So, the engine uses the following algorithm:hgm wrote:If they returned DTM they would be DTM tables, not WDL tables. WDL tables only return whether the position is a win, draw or loss. That is why they are called WDL tables. So the Syzygy tables are not really WDL tables but a kind of extended WDL, as they also contain cursed wins and blessed losses as 4th and 5th possibility.Onegin wrote:I am a member of TalkChess.com and I accidentally stumbled into your discussion. I am an average computer user but can anybody answer my simple question about Syzygy tablebases. Why wdl TBs do NOT return DTM metric but simply a number -2, -1, 0, 1 or 2. Why not use both DTM and DTZ metrics instead of using engine search?
The engine only needs WDL information on end-games it is not in yet at the root; the more detailed DTx info is only helpful for choosing a move in the end-game you are currently in. For end-games you will pass through on the way to a win the only thing of importance is to convert to a won position (or a not-lost position when defending), and you would only have to worry about how to win it once you get there. WDL stores much less information per position, so the WDL tables are smaller, and therefore also faster in usage.
You could use both DTM and DTZ50 metrics: Just play the move that DTM-wise is best, and according to DTZ50 and your current ply-counter setting would still be a win. Disadvantage is that you have to have both DTM and DTZ50 tables around, and the DTM tables are nearly an order of magnitude larger than the DTZ50. That would give you a very good approximation of the behavior most users want without the need for any search. If you would use DTM tables adapted to avoid conversion to cursed wins (as sort of partial DTM50), it would even be perfect.
I think you first need to have a good idea of how an engine works in general. This thread is not really the best place to learn about that.Onegin wrote:So, the engine uses the following algorithm:
1. WDL table returned value 2. Position is won. Use the same DTM approach as in the case of DTM based tablebases (Nalimov, for example)
2. WDL table returned value 1. Position is won, but drawn under 50 move rule. Use DTZ information to zero ply counter at the same time making sure you select only won position from WDL table. You also need to make sure you arrive at the zeroing move before 50 move rule expires.
3. WDL table returned value 0. Position is drawn. Same as in case 1, use usual TB approach.
4. WDL returned value -1 or -2. Same as in cases 1 and 2, only with reverse colors
???
My tables don't distinguish between a distance of 10 moves to a cursed win and a distance of 60 moves to a real win. Both are stored essentially as "60" (and that improves compression a bit). That is enough to convert a cursed win if the 50-move rule is ignored, but does not help so much in finding an optimal swindling strategy (whatever that might be... if the opponent uses the same tables nothing will help anyway).hgm wrote:If you are in a cursed win, the situation is tricky. You would have to know whether the win is cursed because you cannot force conversion quickly enough in the current phase, or whether you can timely force conversions, but they are all cursed in the next phase. In the latter case you might not want to go for the quickest conversion, but for a conversion to the 'least cursed' win in the next phase that you can force within 50 moves in the current phase. I don't know if that is the info you will find in the DTZ tables.
No, I'm not a developer, I'm a user. I'll try to find user's forum next time, I didn't know. This is my first participation in a TalkChess forum. I don't know how an engine works but I noticed that when I use Stockfish in the endgame calculation Arena GUI shows # of TB hits and there are two types of behavior: 1. small # of TB hits (several hits, up to 30-40) 2. very large # of TB hits (up to tens of thousands), number which is comparable to the # nodes the engine goes through. I couldn't find an explanation for such a behavior and started thinking about EGTBssyzygy wrote:I think you first need to have a good idea of how an engine works in general. This thread is not really the best place to learn about that.Onegin wrote:So, the engine uses the following algorithm:
1. WDL table returned value 2. Position is won. Use the same DTM approach as in the case of DTM based tablebases (Nalimov, for example)
2. WDL table returned value 1. Position is won, but drawn under 50 move rule. Use DTZ information to zero ply counter at the same time making sure you select only won position from WDL table. You also need to make sure you arrive at the zeroing move before 50 move rule expires.
3. WDL table returned value 0. Position is drawn. Same as in case 1, use usual TB approach.
4. WDL returned value -1 or -2. Same as in cases 1 and 2, only with reverse colors
???
If you really want to know, there is the source code. If you cannot read source code, then the goal of really understanding how things work might not be achievable anyway. If you just want to know at a "user's level", then this is a developers forum and therefore the wrong place.
Code: Select all
bool c = ( !pos.count<PAWN>(BLACK)
|| ( pos.count<PAWN>(WHITE)
&& pos.count<PAWN>(BLACK) >= pos.count<PAWN>(WHITE)));
pawn.pawnCount[0] = pos.count<PAWN>(c ? WHITE : BLACK);
pawn.pawnCount[1] = pos.count<PAWN>(c ? BLACK : WHITE);
Code: Select all
if ((ptr->piece.flags & 1) != bside && !ptr->symmetric) {
*success = -1;
return 0;
}
Code: Select all
if (ptr->piece.flags & 2)
res = ptr->piece.map[ptr->piece.map_idx[wdl_to_map[wdl + 2]] + res];
if (!(ptr->piece.flags & pa_flags[wdl + 2]) || (wdl & 1))
res *= 2;
The short answer is that this how the generator selects the leading color, and so how the TB files are organised.mcostalba wrote:Here we are with my daily questions
I have seen this code to assign leading pawn color (at least this is what I understand):
For me it is not clear the condition, because you assign leading color to white if black has no pawns, and this is understandable, but then, if both have pawns, you assign leading color to the side with _less_ pawns, and this I don't' understand, shouldn't be the opposite?Code: Select all
bool c = ( !pos.count<PAWN>(BLACK) || ( pos.count<PAWN>(WHITE) && pos.count<PAWN>(BLACK) >= pos.count<PAWN>(WHITE))); pawn.pawnCount[0] = pos.count<PAWN>(c ? WHITE : BLACK); pawn.pawnCount[1] = pos.count<PAWN>(c ? BLACK : WHITE);
The DTZ tables are one-sided, i.e. they store positions only for white to move or only for black to move.In probe_dtz_table there is one early-fail logic that I don't understand.
Code: Select all
if ((ptr->piece.flags & 1) != bside && !ptr->symmetric) { *success = -1; return 0; }
First I'll quote the comment explaining the result returned by probe_dtz():and also the mapping of the score, in particular what is 'map' and what is used for?
Code: Select all
if (ptr->piece.flags & 2) res = ptr->piece.map[ptr->piece.map_idx[wdl_to_map[wdl + 2]] + res];
Code: Select all
// Probe the DTZ table for a particular position.
// If *success != 0, the probe was successful.
// The return value is from the point of view of the side to move:
// n < -100 : loss, but draw under 50-move rule
// -100 <= n < -1 : loss in n ply (assuming 50-move counter == 0)
// 0 : draw
// 1 < n <= 100 : win in n ply (assuming 50-move counter == 0)
// 100 < n : win, but draw under 50-move rule
Code: Select all
if (!(ptr->piece.flags & pa_flags[wdl + 2]) || (wdl & 1))
res *= 2;
You're welcomeCare to elaborate a bit on those? Thanks in advance.