syzygy wrote: ↑Sat Feb 28, 2026 6:11 pm
Rein Halbersma wrote: ↑Sat Feb 28, 2026 2:35 pm
syzygy wrote: ↑Wed Feb 04, 2026 5:45 pm
When we are in g2, we have loaded 19 slices (a1-h1,a2-h2,f3,g3,h3).
[d]8/8/8/8/8/5kkk/kkkkkkkk/kkkkkkkk b - - 0 1
[...]
19 K-slices take up 97.9 GB, so 128 GB of RAM would be comfortable.
I'm trying to understand this thread. So far I understand the 462 wK/bK slicing, and also that unmoving a bK requires 9 slices in RAM at the minimum. But where does the number 19 come from? For the g2 diagram, what benefits bring the 10 slices in the a1-e1-a2-e2 rectangle being in RAM?
The 19 comes from the maximum number of slices that have to be kept in memory before you can save slices to disk (or release them from memory if they were loaded from disk) because they are "finished". A slice is finished if all its "neighbouring" slices have been processed.
For example, consider computing the wtm predecessors of the btm loss-in-n positions.
In this case we are looking at moves and unmoves by white, so the bK stays on the same square.
So we first place the bK on b1 and let the wK move through the squares in normal order a1-h1, a2-h2,....,a8-h8.
The wK cannot be on a1,b1,c1, so we start with wK on d1.
If we unmove btm loss-in-n positions with bK,wK on b1,d1, we reach wtm positions with bK on b1 and wK on one of d1,d2,e1,e2. So we need 4 slices in RAM corresponding to (b1,d1), (b1,d2), (b1,e1), (b1,e2).
Now we move wK to e1 and we need to add RAM slices for (b1,f1) and (b1,f2).
And so on: as we move wK to f1,g1,h1,d2,e2, we create RAM slices for bK on b1 and wK on g1,g2,h1,h2,c3,d3,e3,f3.
Now notice that once we have finished unmoving from (b1,e2), we are done with the slice (b1,d1): it is not possible to reach this wtm slice by unmoving from a btm slice which has not already been processed. So we save the wtm slice corresponding to (b1,d1) to disk, and we can use the freed up RAM for another slice (like (b1,g3) since we will now place the wK on f2).
The "worst" case scenario is when the bK is not near the wK and the wK is not on ranks 1 and 8. In this worst case, 2*8+3=19 slices are enough:
8/8/KKKKK3/KKKKKKKK/2KKKKKK/8/8/1k6 w - - 0 1
Here we are processing (b1,d5). Once finished, (b1,c4) can be released, the wK moves to e5, and (b1,f6) is added to RAM.
Once (b1,h8) is done, every slice still in RAM can be saved to disk, the bK moves to c1, and wK traverses the board again.
The bK can be restricted to a1-d1-d4. If the bK is on the diagonal a1-d4, the wK only visits the a1-h1-h8 triangle.
The verification step (to verify a potential loss-in-n found by unmoving from a win-in-(n-1)) works in exactly the same way, except now we load K-slices into RAM from disk (with "wins" bitmaps) before processing instead of saving them to disk after processing.
With colours reversed, it is the same. Just fix the wK in one of the a1-d1-d4 squares and let the bK traverse the board.
Now it's just a matter of mapping all these slices to the same naming scheme.