hgm wrote: ↑Tue Sep 24, 2024 2:32 pm
syzygy wrote: ↑Sat Sep 21, 2024 7:35 pm
[d]8/8/3F4/8/8/k6f/8/1K6 w

White wins in 63 ply?

FairyGen says "mate in 30", and if we double that and add 3 ply, like in the previous case, that is indeed 63.

Thanks. I have now adapted my engine to play shatranj (or at least let it know the rules), so I can generate the full lines. I think I have now fixed all the bugs (and hopefully did not introduce any in the pawn generation code). The full "mate" (with Q instead of F) here is:

1.Kc2 Ka4 2.Kd3 Kb5 3.Ke4 Kc6 4.Qe5 Kd7 5.Kf5 Kc6 6.Qf4 Kd5 7.Qg5 Qg2 8.Kf4 Qf1 9.Ke3 Ke5 10.Qh4 Kf5 11.Kf3 Kg6 12.Kg4 Qe2 13.Qg3 Qd3 14.Kf4 Qc4 15.Ke5 Kg5 16.Ke4 Qb5 17.Qf4+ Kf6 18.Kd5 Kf5 19.Qe3 Kg4 20.Ke4 Kg3 21.Qd4 Kf2 22.Qe5 Qa4 23.Kd4 Kf3 24.Qd6 Kf4 25.Qc5 Kf5 26.Qb4 Ke6 27.Kc5 Qb3 28.Qa3 Qa2 29.Kb4 Qb1 30.Kb3 Kd5 31.Kb2 Qa2 32.Kxa2

With DTZ I don't have to decide how to "count" a bare king position: the conversion of the position into the bare king position is a zeroing move. And stalemate is simply treated as a mate.

[d]8/8/8/8/5F2/7k/2K5/n7 w

White wins in 15 ply?

"Mate in 6" through 1. Kc3 (and then pick off the trapped Knight with the Ferz). 2*6+3 = 15.

1.Kc3 Kg2 2.Qe5 Kf3 3.Qd6 Ke4 4.Qc5 Kd5 5.Qb4 Kc6 6.Qa3 Kb5 7.Qb2 Nc2 8.Kxc2

[d]2k2F2/8/8/8/8/8/4n3/2K5 w[d]

Black wins in 40 ply?

After 1.Kd2 the black move (1... Ng1) says "mate in 18", and 2*18+3 = 39. So 40 ply in total. (FairyGen in console mode can only play and report DTx for the winning player.)

1.Kd2 Ng1 2.Qg7 Kd7 3.Ke3 Ke6 4.Kf2 Nh3+ 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 Kc1 64.Ka2 Qb2 65.Qxb2+

syzygy wrote: ↑Sat Sep 21, 2024 6:21 pmWhite wins in 43 ply:

[d]F7/7k/8/8/f7/8/8/K7 w

This seems suspect. Do you have a way to verify whether this is a win for white?

FairyGen does not see a win here.

Indeed this position is a draw. I still had some bugs relating to detecting and evaluating bare king positions, which probably caused this error.

The "hardest" KPPvKP position (not actually hard since my engine finds it immediately even without TBs):

[d]7k/2p5/2P5/8/2P4K/8/8/8 b - -

1...Kg8 2.Kg4 Kf7 3.Kf5 Ke7 4.Ke5 Kf7 5.Kd4 Ke6 6.Kc5 Ke7 7.Kb4 Kd8 8.Ka4 Kc8 9.Kb5 Kb8 10.Kc5 Ka7 11.Kd4 Ka6 12.Ke5 Kb6 13.Kd5 Ka5 14.Ke6 Kb4 15.Kd7 Ka3 16.Kxc7

A "cursed" position (cursed win for white, i.e. black can draw by the 50-move rule):

[d]7K/k6P/8/2p5/8/8/P7/8 b - -

1...Kb6 2.Kg7 Kc6 3.Kf6 Kd6 4.Kf5 Kd5 5.Kf4 Kd4 6.Kf3 Kd3 7.Kf2 Kd2 8.h8=Q

resulting in:

[d]7Q/8/8/2p5/8/8/P2k1K2/8 b - - 0 8

Now the pawns can walk and promote and it ends up in a position that needs more than 50 moves.

Highest DTZ for 5-piece tables (DTZ = 179):

[d]1Q3b2/8/8/8/8/8/8/K2k2B1 w - -

1.Be3 Ke2 2.Bc1 Kd3 3.Qc7 Kc2 4.Be3 Kd3 5.Bg5 Ke4 6.Qb6 Kd5 7.Be3 Kd4 8.Bc5 Kc4 9.Be7 Kd5 10.Qc5 Ke6 11.Bg5 Kd5 12.Be3 Ke4 13.Bc1 Kd5 14.Ba3 Kc4 15.Kb2 Bh6 16.Kc2 Bf4 17.Kd1 Kb3 18.Bc1 Kc4 19.Be3 Kd3 20.Bg5 Kc4 21.Qb6 Kb5 22.Qc7 Kc6 23.Qd8 Kd5 24.Qe7 Bh6 25.Ke2 Ke4 26.Be3 Bf4 27.Bc1 Bh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