But fortunately WB does already much better than that. The current stable version in fact gives correct ruling for all 104 examples given with the Asia rules on www.clubxiangqi.com . It also follows your interpretation of the rules that chasing is illegal even when checking. (So I will have to change that in my engine.) Only in the "Appendix" to these rules there is an example it des not agree with. This is an odd-ball case, where periodiclly subverting and restoring the protection of a piece is ruled as a chase of tht piece by another, non-moving Rook. This is difficult to implement, as it is not clear how the concept of a perpetual sacrifice should be extended to a case where you subvert the protection, rathere than attacking the piece itself. And it seems extremely rare anyway.phhnguyen wrote:If WB always rules a chasing as a draw, I think there will not be fair games between a strong engine which knows that rule and a weak / newbie engine which does not install it and easily try to have a draw game or gain a piece by illegal chasing.
Indeed, WB uses very inefficent code for detecting move legality, in check, etc., which would be completely inacceptable in an engine. The chase-detection code I hve written is similar in spirit. I just run the legal-move generator a number of times, with different call-backs: first after the move to list all captures, then before the move, to eliminate all captures that already existed, then to test the legality of a reverse capture ('sacrifice / offer to exchange') and to find a legal recapture (for determining protection), where applicable.I believe that both you and me (as well as some GM) don't really understand some of those rules. Some other rules we can understand but very hard to implement (such as detecting protected piece).
However, we can implement correctly 95% of all rules. For WB, an advantage/luck is that it doesn't have to care much about the search speed as normal engine. Thus, you have more chance to write the code.
In fact I now do approximately the same in my engine (except that the check-test to verify move legality is done a little more efficiently than just generating all opponent moves), because I wanted to worry about efficiency only after establishing how important the problem was. Currently I address the efficiency problem by only doing the chase test when the remaining search depth > 2.
OK, this is the imterpretation that WB uses also. I was in doubt, because checks and chases are in a different class (if A perpetually checks, and B perpetually chases a Rook, A is ruled to lose, while A chasing a Rook and B chasing a Horse would be ruled draw).I am in office and can't not check the position now (I will check and answer you later). But from your description, I guess black loses IF Cannon is not protected.
Loops with checks in it do raise other problems for chase determination, though: being in check makes most of your pseudo-legal moves illegal, to come back after you resolve the check. Should such enabling of an attack by changing your in-check status be counted as a chase?
My statement was based on the test gauntlets I play with my engine: To evaluate a change I typically play 500 40/1 games and 400 40/2 games, 100 per opponent. Against opponents without chase detection I tipycally find 10 games of the 100 end in a forfeit by chasing.Opps, you may need to study more Xiangqi games.
Both perpetual checking and chasing are very important, especial for computer sw. Perhaps one may focuse easily on checking than chasing a Pawn because the King is much more value than the Pawn. However, chasing may break the rule and should forfeit by a loss.
I see the chasing potently occures in at least 1/4 of total games and most of them one side would be lost if continues.
IMHO, implement Xianqi rules is one of the hardest problems and may take you a lot of time, effort.