I ran 32 basic xiangqi endgame verdicts against Pikafish at depth 26 and against chessdb.cn, which is a lookup rather than a search and covered 27 of them exactly. Final sweep is 31 of 32 agreeing, one leaning.
Two things in here that don't have chess analogues and that I'd expect to matter for anyone writing a xiangqi engine.
Perpetual check is a loss, not a draw. The side giving check has to vary or forfeit. So the standard chess resource for saving a lost position inverts, and a defence built on repeated checks hands over the point.
The natural limit (自然限着) draws the game after 60 moves by each side with no capture, whatever the evaluation says. A book win needing 70 moves of technique is not a win you can play. I let Pikafish play the one unresolved row out against itself and it broke through on move 34, with 26 to spare, which is the only reason that verdict stands.
Both are easy to read past in an English summary and expensive to read past at the board. Positions and the checker are in the repo, on my own site.
https://brianhliou.com/posts/xiangqi-basic-endgames/
Xiangqi endgame verdicts vs Pikafish: where an engine and a rules corpus disagree
Moderator: Ras
-
brianhliou
- Posts: 1
- Joined: Thu Aug 27, 2026 1:09 am
- Full name: Brian Liou
-
hgm
- Posts: 28524
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: Xiangqi endgame verdicts vs Pikafish: where an engine and a rules corpus disagree
Is this 60-move rule a new one, or only something that applies in computer games? I thought classical Xiangqi did not have such a rule. 60 moves does not seem very generous, if the weak side still has attacking pieces. After every move that made progress, it could start a perpetual check sequence, and continue that until it reaches the maximum number of repetitions (4?) it can afford with being declared a loss. So it can safely gp through 3 check cycles of 4 ply each (wasting 12 ply), after which the forced mate progresses 2 ply, and he can start another 12-ply delaying tactic. WIth less than 1/6 of the moves actually progressing the game, you would only have 10 moves to force the mate.
In the H+C vs H case, I am not surprised that search cannot find it. It might sound impressive that an engine searches 40 moves or more, but it can only do that by aggressive pruning of the search tree. To search the full tree it would probably only reach depth 8-10 ply. The problem is that the pruning is not really sensible unless the evaluation already knows which positions are likely to be closer to the mate than others. A comparable case is the KBN-K end-game in Chess, where practically every position with the strong side on move is a guaranteed win. But even the most advanced search, such as that of Stockfish, will not be able to find the mate (which can take 34 moves = 67 ply) unless the evaluation knows that progress can be approximately measured by the distance of the bare King to the corner of the color of the Bishop. With that knowledge the search can start pruning all branches where the bare King 'escapes', focusing it towards the mate.
I am not sure whether similar heuristics in the case of the Xiangqi KCHAAEE-KHAAEE end-game exist, and, if so, whether the Pikafish evaluation is aware of it. If not it might consider 40-move lines that are completely pointless, and do not make any progress at all. It will probably discover at some depth that it can force the weak side to a position that its evaluation, for this piece composition, considers most unfavorable. But if that means whether it is also closer to a mate remains to be seen.
Are the defensive pieces of the strong side really significant in this end-game? I.e., what is the rule for KCH-KHAAEE? A lone Horse is harmless even for a defenseless King, so from that perspecctive no defenders are needed, and they might only be in the way. But I suppose the Cannon can benefit from a mount, so an extra A could be essential.
Is this really out of reach for retrograde analysis? If I calculated right KCH-KHAAEE contains some 12G board positions, which sounds doable. Often an end-game can be simplified by putting restrictions on the strong side; if he can then still win with this restriction, he could certainly win without it. E.g. in KR-KAAEE you can restrict the Rook to be on the enemy half, as there should be no need to ever retreat it to your own half. (For lateral movement, the 7th rank should do, as it is always unobstructed.) Extra A or E of the strong side can be ignored when they are all on ranks behind their King (as they cannot obstruct a Rook that is not allowed to go there). This can strongly reduce the size of the table 6you need to prove a win.
In the H+C vs H case, I am not surprised that search cannot find it. It might sound impressive that an engine searches 40 moves or more, but it can only do that by aggressive pruning of the search tree. To search the full tree it would probably only reach depth 8-10 ply. The problem is that the pruning is not really sensible unless the evaluation already knows which positions are likely to be closer to the mate than others. A comparable case is the KBN-K end-game in Chess, where practically every position with the strong side on move is a guaranteed win. But even the most advanced search, such as that of Stockfish, will not be able to find the mate (which can take 34 moves = 67 ply) unless the evaluation knows that progress can be approximately measured by the distance of the bare King to the corner of the color of the Bishop. With that knowledge the search can start pruning all branches where the bare King 'escapes', focusing it towards the mate.
I am not sure whether similar heuristics in the case of the Xiangqi KCHAAEE-KHAAEE end-game exist, and, if so, whether the Pikafish evaluation is aware of it. If not it might consider 40-move lines that are completely pointless, and do not make any progress at all. It will probably discover at some depth that it can force the weak side to a position that its evaluation, for this piece composition, considers most unfavorable. But if that means whether it is also closer to a mate remains to be seen.
Are the defensive pieces of the strong side really significant in this end-game? I.e., what is the rule for KCH-KHAAEE? A lone Horse is harmless even for a defenseless King, so from that perspecctive no defenders are needed, and they might only be in the way. But I suppose the Cannon can benefit from a mount, so an extra A could be essential.
Is this really out of reach for retrograde analysis? If I calculated right KCH-KHAAEE contains some 12G board positions, which sounds doable. Often an end-game can be simplified by putting restrictions on the strong side; if he can then still win with this restriction, he could certainly win without it. E.g. in KR-KAAEE you can restrict the Rook to be on the enemy half, as there should be no need to ever retreat it to your own half. (For lateral movement, the 7th rank should do, as it is always unobstructed.) Extra A or E of the strong side can be ignored when they are all on ranks behind their King (as they cannot obstruct a Rook that is not allowed to go there). This can strongly reduce the size of the table 6you need to prove a win.