Page 1 of 8

Perpetual chasing in Xiangqi

Posted: Tue Jul 13, 2010 8:41 am
by hgm
In Xiangqi it is not allowed to force the opponent into repetition. So like in Chess, after the same position repeats for the 3rd time, the game can be claimed. But unlike Chess, the result is not always a draw. If, all the moves between the current position and the one two occurrences before were forcing moves, that side loses!

Now exactly which moves are forcing, and which not, depends on the local rules. Checks are considered forcing under any rule set, so perpetual checking is always forbidden. But on threatening mate-in-1, or threatening to gain material through deep tactic, like a skewer ("check and capture"), the rules differ. In "China mainland rule" all this is forbidden, making these rules practically unimplementable. Computer Xiangqi therefore usually follows Asia rules, which are highly simplified. Basically in Asia rules, only making a direct attack on a piece will be considered a forcing move. Mate threats, or material gains after an exchange of multiple moves does not count. Forcing moves that are not checks are referred to as chases.

Even with that simplification, Asia rules are highly complex. In the official description, 104 example diagrams are given of perpetual chases, or repeats that are not to be considered chases (and thus draws). The following set of rules seems to cover all these 104 cases, though:
Asia rule wrote:1) Checking is considers a worse offence than chasing another piece. So if one side is perpetually checking, and the other is perpetually chasing, the checking side loses. All chases are equal, though: if one side perpetually chases a Rook, and the other a Pawn, it is draw.

2) To make a forbidden perpetual chase, you must really chase the same piece on every move of the repeat cycle. (And it does not matter which piece does the chasing: two (or multiple) pieces taking turns to chase one is still forbidden. ) Having a single non-forcing move in the cycle ("one check, one idle", "one chase, one idle") completely acquits you of chase charges. Also alternately chasing two different pieces (including "one check, one chase") is allowed.

3) A chase must be a _new_ attack on a piece. If you could already capture piece A with piece B before move M, then being able to capture A with B after M does not threaten anything new, and is not a chase. E.g. moving a Rook along the attack ray is not creating a new attack. (Checks, obviously, always are new.) Note that one move can result in mutiple chases, both on multiple targets, (e.g. forks) and by multiple perpetrators (e.g. discovered attacks). They all must be judged separately.

4) A newly created attack is in general only considered forcing (i.e. a chase) if the target is not protected. If it can be recaptured on the same square, the attack is not a chase. (Note that the possibility to recapture might depend on how the piece is captured, in case of multiple attackers, so this has to be judged per (attacker, victim)-pair, and is not an intrinsic property of the victim.) But there are some exceptions that are declared either always a chase or never a chase, irrespective of the protected status of the victim:
- Attacks of Horse or Cannon on Rook are always a chase
- Attacks on a Pawn that has not crossed the River are never a chase
- Attacks by a Pawn or King are never a chase
- Attacks on a King are of course always checks

5) An attack on a piece is also not considered a chase if the piece can capture its attacker (which must be of equal type) back. The possibility for such pre-emptive self-defence is considered as good as having a protector that can retaliate. Such attacks are called "sacrifices" or "offers to exchange", not chases. Note that it does not matter if you can pre-emptively capture the attacker with another piece than the chased one, or if the chase victim can capture a piece other than the one chasing it.

6) In all cases only legal moves are taken under consideration. Pseudo-legal captures that are not legal are to be completely ignored. This applies to the attacks itself, to recaptures by a protector, or to pre-emptive counter captures. On the other hand, if the move is legal, does not have to be a good one. Even if it gets you mated in one after making it, or loses you heavy material, the move should be taken into account. (E.g. when a piece is twice attacked, and only once protected, recapturing might be suicidal, but the piece still counts as protected.)
These are the rules according to which WinBoard adjudicates repetitive Xiangqi games. This thread was created to discuss cases where this might lead to controversion (or wrong) adjudications.

Re: Perpetual chasing in Xiangqi

Posted: Tue Jul 13, 2010 11:08 am
by hgm
This is a good example of a controversial call, that follows from strictly applying the rules given above:

3a1ke2/4a4/4e4/RH6p/p3c1p2/9/2C2h3/4H3E/4A4/1r1AK4 w 2 44

Image

44. Kf0 Cf5+ 45. Ke0 Ce5 46. Kf0 Cf5+ 47. Ke0 Ce5
{Xboard adjudication: perpetual chasing} 1-0


WinBoard comes to this verdict because it considers the Advisor on e1 as being chased. For one, it is not protected: the Advisor on d0 is a "false protector", because it is pinned by the Rook on b0, and the King (when on e0) is a false protector because Ae1 is also under attack by the black Horse, so the King could not recapture after Ce5xe1.

So the move Ce5 is chasing Ae1, by creating a new attack on it with the moved Cannon. And Cf5+ undoes the pinning of the Horse on f3 by the King, (Kings are not allowed to directly face each other in Xianngqi), so that it creates an attack by that Horse on the same Advisor, which was not possible before (because of the pin). So this move also chases.

Both moves create a new attack on the same unprotected Advisor, hence perpetual chase. It does this next to a "one check, one idle", which in itself would be allowed.


There are two aspects that make this controversial:

1) Creating a new attack by resolving a pin. There is no explicit example amongst the 104 diagrams that come with the Asia rules where this method to create a new legal capture is used. There are plenty of other examples where creating an attack by one piece through moving another (Discovered attacks, Cannon activation) are defined to be chases. Even when the piece that moves would in itself be allowed to chase in direct attack (i.e. is a King or Pawn, diagram 71-73). There are also examples where a Rook creating new pseudo-legal attacks on a Cannon (in an attempt to block its passage) that are not legal attacks (because the Rook is pinned) is not considered a chase (diagram 63).

2) Normally aiming a second attacker on a singly protected piece is not considered a chase (diagram 86-89). But if the single protector is a King, a second attacker makes the recapture illegal. Normally a recapture that leaves your King in check would not count ("false protector", diagrams 83-85). These are all examples where you put yourself in check by moving a pinned piece away, though, not where you step into check with the King itself.

3) Can a move that delivers check be a chase at the same time? Judging if a move attacks something is normally done by having the opponent null move, and allowing the side that just moved two moves in a row. But when in check, the null move is illegal. So this can be very tricky.

Re: Perpetual chasing in Xiangqi

Posted: Tue Jul 13, 2010 11:16 am
by hgm
Note that I made a PGN file that contains all diagrams of Asia rulse (as described, for example, on ( http://www.clubxiangqi.com/rules/asiarule.htm ). It can be downloaded from

http://home.hccnet.nl/h.g.muller/AsiaRule.pgn

Re: Perpetual chasing in Xiangqi

Posted: Tue Jul 13, 2010 1:11 pm
by hgm
To illustrate point (3) mentioned above, I composed the following position:

Code: Select all

9 . . . . k . e . c
8 C . . . a . . C r
7 . . . . c . . R .
6 . . . . . . . . p
5 . . . . . . . . .
4 . . . . . . . . .
3 . . . . . . . . .
2 . . . . E . . . .
1 . . . . A . . . .
0 . . . . K A E . .
  a b c d e f g h i
(I switched to using ASCII diagrams, as the rendering of XQ diagrams does not seem to work in this forum.)

1.Ch9+ Af9 2.Ch8 Ae8 3. Ch9+ Af9 4. Ch8 Ae8

The move Ch9+ activates Ca8xi8 as well as delivering check. Af9 resolves both threats, but Ch8 reactivates it again. So next to a "one check, one idle" against the King, white could be considered chasing Rh8 with Ca8.

But now look at the issues this raises in a slightly modified position:

Code: Select all

9 . . . . k . e . c
8 C . . . . r . C h
7 . . . . c . . R .
6 . . . . . . . . p
5 . . . . . . . . .
4 . . . . . . . . .
3 . . . . . . . . .
2 . . . . E . . . .
1 . . . . A . . . .
0 . . . . K A E . .
  a b c d e f g h i
I replaced Ri8 by a Horse, so that the attack of Ca8 on it is not automatically a chase, but it depends on the Hh8 being protected. In addition I replaced Ae8 by Rf8, to provide a protector. Now

1. Ch9+ Rf9 2. Ch8 Re8 3. Ch9+ Rf9 4. Ch8 Re8

Again Ch8 activates Ca8xi8, and the Horse is not protected on this move. So that is a chase. But after Ch9+, unblocking Ca8xi8 again, the Horse is protected by Rf8. Or is it, really???

After Cf8+ <null> Ca8xi8 black cannot capture back very well with Rf8xi8. Because that leaves him in check, just as the null move did, and it was just his luck that we decided to capture the Horse, rather than his King.

So how to handle this?
1) We can decide that the Horse is indeed not protected, because after Ca8xi8 Rf8xi8 leaves black in check, and Rf8 thus is a false protector. In this case we would have a forbidden perpetual chase here (next to the check).
2) We can replace the null move by some other check evasion, for the purpose of judging if the newly attacked piece wasprotected or not. But what if there are none? Or if the only one interferes with the new attack we want to judge (like here: Ke8 blocks Ca8xi8.)
3) We could temporarily 'lift the King from the board' in stead of the null move, before judging. This does not seem to be the proper thing to do, though: it would also liberate genuinely pinned pieces, for example. It is also theoretically possible that removing the King interferes with the newly created capture, or with the recapture, because the King acted as platform for a Cannon in either of those.
4) We could introduce a new class of legality ('semi-legal moves'), made from positions where the mover is in check, in order to distinguish moves that leave your King in check into moves that merely leave your King in the existing check, and moves that create a new way to capture King (possibly, but not necessarily, resolving the pre-existing way). The protected status of a piece could then be redifined as the existence of a semi-legal move to recapture.
5) Of course we could decide that a check is never a chase to the same time, so the entire problem does never occur.

It seems to me that (2) and (3) are not viable. Solution (5) is by far the easiest, and actually what China mainland rules prescribe. But Asia rules leave out this clause, and this is usually taken as an indication that it does not apply. (4) is doable, but very cumbersome, and looks a bit artificial / arbitrary. (1) is what WinBoard currently would do.

Re: Perpetual chasing in Xiangqi

Posted: Thu Jul 15, 2010 1:30 am
by Greg Strong
Oh WOW. I now have ChessV supporting all the Xiangqi rules except for this nasty, heinous chasing crap. Kinda makes my ill just thinking about it... I have no idea how I'm going to do it, (probably a topic for a separate thread), but my first question is: amateur human players really understand all of this?!?

P.S. Way to go H. G., studying it this deeply, making PGNs for all those positions, discovering this ambiguity, etc. Thanks for all your hard work making chess variants more computer-friendly.

Re: Perpetual chasing in Xiangqi

Posted: Thu Jul 15, 2010 2:22 am
by phhnguyen
Very nice that you make a wide public discussion about a very hard problem of Xiangqi.

I am interested on the position you post here. Let me re-post it in the gif format:

Image

I guess that we may see a lot of games with similar positions but almost all of us have not realized there is a chase as you descried here. Some points we should discuss more:

1) What is a chase?
Let me quote from AFX rules:
"Perpetual chase: Player A makes a succession of chasing moves, while player B answers each move by moving away the piece under attack, or resolving the chase with another piece. If A continues to attack the piece move after move, he is making a "perpetual chase"."

- So as I understand in a chase one piece should be attacked and then escape from that attacking. The second action is "escape" but not "become protected".
- The move Kf0 actually is an action to sacrifice the Advisor Ae1. By that action, White does not move away nor protect that piece

2) Can a checking/resolve-checking move be also a chase?
I agree with you about that point and it may be the most controversial. I will add few more examples about that case.

When playing / watching Xiangqi games, it seems that all players would focus on checks and how to escape from those checks and ignore other aspects. So I think we can ignore any chase (if it has) for Black and that game should be considered as a check and an idle - draw.



hgm wrote:This is a good example of a controversial call, that follows from strictly applying the rules given above:

3a1ke2/4a4/4e4/RH6p/p3c1p2/9/2C2h3/4H3E/4A4/1r1AK4 w 2 44

Image

44. Kf0 Cf5+ 45. Ke0 Ce5 46. Kf0 Cf5+ 47. Ke0 Ce5
{Xboard adjudication: perpetual chasing} 1-0


WinBoard comes to this verdict because it considers the Advisor on e1 as being chased. For one, it is not protected: the Advisor on d0 is a "false protector", because it is pinned by the Rook on b0, and the King (when on e0) is a false protector because Ae1 is also under attack by the black Horse, so the King could not recapture after Ce5xe1.

So the move Ce5 is chasing Ae1, by creating a new attack on it with the moved Cannon. And Cf5+ undoes the pinning of the Horse on f3 by the King, (Kings are not allowed to directly face each other in Xianngqi), so that it creates an attack by that Horse on the same Advisor, which was not possible before (because of the pin). So this move also chases.

Both moves create a new attack on the same unprotected Advisor, hence perpetual chase. It does this next to a "one check, one idle", which in itself would be allowed.


There are two aspects that make this controversial:

1) Creating a new attack by resolving a pin. There is no explicit example amongst the 104 diagrams that come with the Asia rules where this method to create a new legal capture is used. There are plenty of other examples where creating an attack by one piece through moving another (Discovered attacks, Cannon activation) are defined to be chases. Even when the piece that moves would in itself be allowed to chase in direct attack (i.e. is a King or Pawn, diagram 71-73). There are also examples where a Rook creating new pseudo-legal attacks on a Cannon (in an attempt to block its passage) that are not legal attacks (because the Rook is pinned) is not considered a chase (diagram 63).

2) Normally aiming a second attacker on a singly protected piece is not considered a chase (diagram 86-89). But if the single protector is a King, a second attacker makes the recapture illegal. Normally a recapture that leaves your King in check would not count ("false protector", diagrams 83-85). These are all examples where you put yourself in check by moving a pinned piece away, though, not where you step into check with the King itself.

3) Can a move that delivers check be a chase at the same time? Judging if a move attacks something is normally done by having the opponent null move, and allowing the side that just moved two moves in a row. But when in check, the null move is illegal. So this can be very tricky.

Re: Perpetual chasing in Xiangqi

Posted: Thu Jul 15, 2010 6:10 am
by phhnguyen
hgm wrote:To illustrate point (3) mentioned above, I composed the following position:

Code: Select all

9 . . . . k . e . c
8 C . . . a . . C r
7 . . . . c . . R .
6 . . . . . . . . p
5 . . . . . . . . .
4 . . . . . . . . .
3 . . . . . . . . .
2 . . . . E . . . .
1 . . . . A . . . .
0 . . . . K A E . .
  a b c d e f g h i
(I switched to using ASCII diagrams, as the rendering of XQ diagrams does not seem to work in this forum.)

1.Ch9+ Af9 2.Ch8 Ae8 3. Ch9+ Af9 4. Ch8 Ae8

The move Ch9+ activates Ca8xi8 as well as delivering check. Af9 resolves both threats, but Ch8 reactivates it again. So next to a "one check, one idle" against the King, white could be considered chasing Rh8 with Ca8.

But now look at the issues this raises in a slightly modified position:

Code: Select all

9 . . . . k . e . c
8 C . . . . r . C h
7 . . . . c . . R .
6 . . . . . . . . p
5 . . . . . . . . .
4 . . . . . . . . .
3 . . . . . . . . .
2 . . . . E . . . .
1 . . . . A . . . .
0 . . . . K A E . .
  a b c d e f g h i
I replaced Ri8 by a Horse, so that the attack of Ca8 on it is not automatically a chase, but it depends on the Hh8 being protected. In addition I replaced Ae8 by Rf8, to provide a protector. Now

1. Ch9+ Rf9 2. Ch8 Re8 3. Ch9+ Rf9 4. Ch8 Re8

Again Ch8 activates Ca8xi8, and the Horse is not protected on this move. So that is a chase. But after Ch9+, unblocking Ca8xi8 again, the Horse is protected by Rf8. Or is it, really???

After Cf8+ <null> Ca8xi8 black cannot capture back very well with Rf8xi8. Because that leaves him in check, just as the null move did, and it was just his luck that we decided to capture the Horse, rather than his King.

So how to handle this?
1) We can decide that the Horse is indeed not protected, because after Ca8xi8 Rf8xi8 leaves black in check, and Rf8 thus is a false protector. In this case we would have a forbidden perpetual chase here (next to the check).
2) We can replace the null move by some other check evasion, for the purpose of judging if the newly attacked piece wasprotected or not. But what if there are none? Or if the only one interferes with the new attack we want to judge (like here: Ke8 blocks Ca8xi8.)
3) We could temporarily 'lift the King from the board' in stead of the null move, before judging. This does not seem to be the proper thing to do, though: it would also liberate genuinely pinned pieces, for example. It is also theoretically possible that removing the King interferes with the newly created capture, or with the recapture, because the King acted as platform for a Cannon in either of those.
4) We could introduce a new class of legality ('semi-legal moves'), made from positions where the mover is in check, in order to distinguish moves that leave your King in check into moves that merely leave your King in the existing check, and moves that create a new way to capture King (possibly, but not necessarily, resolving the pre-existing way). The protected status of a piece could then be redifined as the existence of a semi-legal move to recapture.
5) Of course we could decide that a check is never a chase to the same time, so the entire problem does never occur.

It seems to me that (2) and (3) are not viable. Solution (5) is by far the easiest, and actually what China mainland rules prescribe. But Asia rules leave out this clause, and this is usually taken as an indication that it does not apply. (4) is doable, but very cumbersome, and looks a bit artificial / arbitrary. (1) is what WinBoard currently would do.
I prefer (5): I am engine programmer and of course I like an easier life ;)

I don't like (1) because it seems be hard and uncommon result for White (for me, it is a check and an idle - draw).

I believe that Asia rules still be ambiguous for "dual tasks" (such as chasing when checking) of attacking pieces.

Re: Perpetual chasing in Xiangqi

Posted: Thu Jul 15, 2010 6:24 am
by phhnguyen
Let me add one more example about "dual task"

FEN "3ak3c/4a4/2r6/9/9/9/9/4R3E/4A3r/1C1AKR3 w 0 1"
{--------------
. . . a k . . . c
. . . . a . . . .
. . r . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . R . . . E
. . . . A . . . r
. C . A K R . . .
white to play
--------------}
1. Cb9+ Rc9 2. Cb1 Rc1 3. Cb9+ Rc9 4. Cb1 Rc1

Image

The White Cannon is doing one check and one chase. The Black side has only one move to resolve the check and one move to resolve the chase. Unfortunately, both those moves can be considered as a chase to that Cannon.

What should we score that game? A draw or White's win?

Re: Perpetual chasing in Xiangqi

Posted: Thu Jul 15, 2010 6:58 am
by TonyJH
I wonder how existing Xiangqi GUIs and internet Xiangqi servers enforce perpetual chasing. For instance, whether they follow "Asian" rules, or use a simpler algorithm, or what. I'm referring to both casual GUIs and sites (like Yahoo games HK) and the more serious ones as well. I guess they probably don't all do it the same way.

Re: Perpetual chasing in Xiangqi

Posted: Thu Jul 15, 2010 7:44 am
by hgm
phhnguyen wrote:The White Cannon is doing one check and one chase. The Black side has only one move to resolve the check and one move to resolve the chase. Unfortunately, both those moves can be considered as a chase to that Cannon.

What should we score that game? A draw or White's win?
This one, at least, is easy to answer. (So let's start with that):

Rule 18 at http://www.clubxiangqi.com/rules/asiarule.htm says:

18. A Rook cannot perpetually chase an unprotected Cannon even if the Cannon is perpetually threatening to checkmate, has a check, or has a check and a chase. ...

It then continues to give examples, amongst which diagram 37:
Image
Diagram 37: Red (in Capital) moves first
R8+1 c1+1
R8-1 c1-1
R8+1 c1+1
R8-1 c1-1
R8+1 ....

Explanation:
Black Cannon's "one check and one chase" is allowed but not Red Rook's perpetual chasing of the Black Cannon. Red has to change.
This is exactly the situation you describe, in this case alternately checkin and chasing Hi1, and resolving both by interposing the Rook (and thus counter-chasing the Cannon). So this should be ruled a chase.

From this example it follows that at least check evasions should be judged for chasing.

Actually, this case occurs quite often in practice (chasing agains "one-check, one chase", or "one check, one idle"). Initially I had my engine programmed to only judge loops on chasing that did not have any checks in them. So the engine would think this a draw, but WinBoard would consider it a chase, and forfeit the engine. I ran into several forfeits before I changed it in the engine. Engines that are not chase-protected at all, also do this quite often. There must be at least a dozen cases in the 682 chase examples I have collected so far, if not a multiple of that.

So this is far from purely hypothetical; It does not only happen with R against C, but also with R against H, where R blocks the Horse's check, thus counter-attacking it, and when the Horse escapes with its idle move, attack it again with the Rook.