hgm wrote:You could just dedicate an extra thread to EGT generation, in addition to your search threads. You then either suspend one of the search threads, or the generation thread. That way you would never have to worry about saving the state of the generator.
Yes, that would work too - and it would work very nicely in an environment where I'm allowed to use more than one thread anyway. But I want to have a fall-back option in case I'm running in an environment where I'm not supposed to use more than one core. Of course I can still launch he generator in a separate thread and simply wait for it to finish (or time to run out).
Note that what makes this attractive is the fact that EGTs with Pawns, like KRPPPKRPP, are not really single EGTs at all, but fragment into P-slices. Because you know what Pawn structure you have in the root, you can discard most of the P-slices as unreachable. Especially with blocked Pawns there aren't too many P-slices that you can reach, and you only have to generate for those.
I haven't really thought about how to handle table bases with pawns (other than you lose the symmetry; probably all of it if we're generating for the position we need). Am I far off in thinking that I would simply take the pawns as given, assume they're fixed, and then move the pieces around? Perhaps have one mobile pawn?
My guess is that it would be better to decide statically in the root which EGTs you are going to generate. The time it would take is largely predictable, and explodes with each extra non-Pawn. So when the root is in KRB...KRN... with ... some Pawns, the situation is completely hopeless, with each P-slice being an unsymetrical 6-men. At this stage you probably would plan to do KR...KR... and KB...KN..., to prepare for either trade. The search might reach too many non-sensical material signatures. If one side has a dangerous passer you might want to repare for having to sac your minor for it, and also build that one.
I'd still prefer to leave it to the search to tell me what positions I might need, but it may just be a detail. Certainly deciding just based on the root position will be easier. Still, if the search never probes KR…KR… I'd prefer to not waste time (or storage space, but a 4 men double-sided table should be < 4 MB) generating it, but there would have to be some heuristic against generating "pointless" tablebases to get rid of some of the nonsense that the search explores.
The downside to doing this, of course, is that I don't figure out that I
will need a particular tablebase, but that I figure out that I
would have needed it. Hopefully before it becomes essential.
The most challenging issue in selective generation is to handle promotions. When you are generating complete EGTs, it is not that much of a problem that KRPPKRP in theory can convert to KQQRKQR: the latter is not that much bigger, Pawns venturing on 48 squares, Queens on 64. But with P-slices a Pawn that was constrained to a file, (and then being able to only reach the forward part of that file) has perhaps 3-4 possible squares, which jumps up to 64 on promotion. Obviously, you would not want to waste time on frivolous promotions.
Now what saves the day here is that in almost all P-slices of KQRPKRP, the game is not only totally won for white, but can actually be won 'with a handicap'. E.g. when you would alter the rules such that a white non-capture with a Pawn counts as an instant loss, and similarly for allowing black to move with a Queen... Most P-slices would still be totally won. This exploits the huge promotion gain or orthodox Chess. End-games that were interesting before promotion tend to become a walk-over after the first promotion. The handicap rules are of course designed to prevent you could ever convert to KQQRKRP or KQRPKQR. P-slices that are still 100% won with the handicap would certainly be so without it. And with DTC/DTZ you would not really care how they were won. So you would never have to do their bulky successors.
Makes sense to me. I would certainly try to avoid KQQRKRP, which would be pretty pointless unless black can promote its pawn immediately. Even then it'll probably simplify very quickly (to mate). I know there are things like KQQK or even KQQQK available out there, but it seems pretty pointless.
There's the tacky issue of underpromotions, which are probably completely irrelevant except maybe promotion to knight (with check). I'd prefer to create tables that assume I will win when I promote a pawn, and then let the search tell me what I need afterwards.
[Edit] perhaps 'totally won' should be softened a little bit here: there will of course be positions where white is checkmated from the start in KQRPKRP, no matter where the Pawns are. Such positions will remain lost whether white is allowed to advance his Pawn or to let a black Queen survive, or not. So the actual test would be to recalculate the P-slice under the assumption that the white or black promotion are winning, rather than losing and then see if there are positions in it that change result. If all second promotions are 'don't' cares, you just assume the worst, and there is no need to calculate them.
I guess what you really want is a generator for WDLX, where X is a 'don't know'. Yoou can than start to assume that the positions with a second promotion are X, and then generate backwards through the P-slices to see how far the X propagates. Eventually you will reach X-free P-slices.
Sounds like a good use for that redundant bit in two-sided bitbases.