In my view the typical application of a KPK recognizer that uses a bitbase is the normal search which also has repetition detection. None of these problems should occur there: in the given example the search will prefer Kf5 after 4 iterations.hgm wrote:Well, it depends on the depth. I don't think it will be possible without King term if you restrict the search depth to 1 ply, for instance. In situations other than a simple rule-of-squares race, you need more King moves than Pawn moves to win against best defence. E.g. with Ke4, Pe3 vs Ke6 (btm) after Kd6 both Kf5 and Kf4 are winning, but only Kf5 is progress. So if because of move-gen ordering it happens to prefer Kf4, it would never make progress. Relying on rep-draw code to force progress is a tricky thing, because it also often backfires; In the given example you might think that the second time it would play Kf5 because it now recognizes Kf4 as a draw, but in fact there won't be a second time, because after Kd6, Kf4, Ke6 the only winning move Ke4 is now tainted as rep-draw, so it will accept that the position is drawn now, and pick a random drawing move.
Restricting the search to 1 ply might seem a bit extreme, but it is of course exactly what you do if you want to build a recognizer for this end-game.
Iteration 1 might return 1.Kf4 as PV move, as you say.
Iteration 2: 1.Kf4 Ke6 (win).
Iteration 3: 1.Kf4 Ke6 2.Ke4 (win).
Iteration 4: 1.Kf4 Ke6 2.Ke4 Kd6 (rep draw). But now it still finds 1.Kf5 (e.g. Ke7 2.Ke5 Kd7) as new PV at the root.
Restricting the search to 1 ply is not "typical" in my eyes. A perfect recognizer that you can use in a 1-ply search would be based on a DTM tablebase, not a bitbase, so that you always select among those moves which have the shortest path to mate. Using a bitbase together with a complex evaluation does not make much sense to me.
In many practical cases where a KPK position is reached within a deeper search of a "bigger" endgame you will not need the complex evaluation part at all since the "win" or "draw" information itself will already lead to a cutoff.