Perpetual chasing in Xiangqi

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
hgm
Posts: 27789
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: A method to implement Asian rule

Post by hgm »

OK, so your rule is not that is _can_ attack, but that it _does_ attack back, to be considered fair.

It becomes a bit difficult to come up with sensible examples if it is not clear what rule you apply. But anyway, my two rules (1) and (2) are different. Are you claiming that your rule is equivalent to one of these two. If so, which one?
User avatar
phhnguyen
Posts: 1434
Joined: Wed Apr 21, 2010 4:58 am
Location: Australia
Full name: Nguyen Hong Pham

Re: A method to implement Asian rule

Post by phhnguyen »

hgm wrote:OK, so your rule is not that is _can_ attack, but that it _does_ attack back, to be considered fair.

It becomes a bit difficult to come up with sensible examples if it is not clear what rule you apply. But anyway, my two rules (1) and (2) are different. Are you claiming that your rule is equivalent to one of these two. If so, which one?
For the first glance, I think it is (1). However, it may be a mix between them. Only after you or me implement and test carefully, we will know what it will be.

The (1) and/or (2) should be equivalent to (3) because they all are for solving the same problem: Cannon chases Rook to protect other by subverted attack.
User avatar
hgm
Posts: 27789
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: A method to implement Asian rule

Post by hgm »

If they are equivalent, I would prefer to implement (1) or (2), because that judges the sides independently from each other. For each existing capture of the chasing side I have to remove those of protected pieces, those that were already possible before the move and not protected then, those that were still possible after the opponent's reply and not protected then. (Where I of course would start with removing the captures that obviously cannot be chases, because they are with K or P, or because they are between equal pieces that can pre-emptively capture back, and where a Rook would by default count as unprtected against any C or H attack.)

So at each stage, I know what the attacker is, and what the protector is. It is only very little trouble to check if the attacker was in between the victim and the protector. Personally, I think that (2) follows the description of Asia rule more closely than (1).

Now let us leave this protection-subversion business, as it will perhaps be only responsible for 0.1% of all chases anyway. Much more important is the in-check problem. About 10% of all chases involved a "one check, one idle" pattern. Most of the time the pattern is like this:

Code: Select all

. . . k . a . . .
. . . . a c . . .
. . . . . H . . .
. . . . R . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
1.Rd6+ Ke9 2.Re6 Ke8 3.Rd6+

White is doing one check, one idle. But we know from other examples that the side evading the check must be tested for chasing. In this case, his Advisor on e8 is statically attacking Hf7. But that attack is static as pseudo-legal attack only. In reality it is modulated. After every black move, it becomes legal. Every white move than makes it illegal.

So WinBoard currenlty rules black to be perpetually chasing the Horse, and hence a white win. Do you agree with that?

This pattern, of an alternating check and pin, occurs quite fequently. The details differ: the pinned piece making the chase can also be Horse or Elephant. The pinning piece can also be Cannon (with one extra piece on both d- and e-file.
User avatar
phhnguyen
Posts: 1434
Joined: Wed Apr 21, 2010 4:58 am
Location: Australia
Full name: Nguyen Hong Pham

Re: A method to implement Asian rule

Post by phhnguyen »

hgm wrote:If they are equivalent, I would prefer to implement (1) or (2), because that judges the sides independently from each other. For each existing capture of the chasing side I have to remove those of protected pieces, those that were already possible before the move and not protected then, those that were still possible after the opponent's reply and not protected then. (Where I of course would start with removing the captures that obviously cannot be chases, because they are with K or P, or because they are between equal pieces that can pre-emptively capture back, and where a Rook would by default count as unprtected against any C or H attack.)

So at each stage, I know what the attacker is, and what the protector is. It is only very little trouble to check if the attacker was in between the victim and the protector. Personally, I think that (2) follows the description of Asia rule more closely than (1).
I have been trying to use (1) and (2) (score subverted attack of Cannon). Still trouble to explain both game 61 and A3. They both have very similar pattern:

Cannon of 1st side - Rook of 2nd side - piece A of 1st side - piece B of 2nd side - Cannon of 1st side

In 61, piece B is a Horse, in A3, piece B is a Rook. We have to score so 61 as a win for Rook side, but A3 as a draw.

Of course the simplest way is to announce the pattern C - R - a piece - R - C as an exception case of draw (so we don't need to use any (1), (2) or (3). But I hope to find a better explanation which introduces as less exceptions as possible.

Can we all work together to solve that problem?
Now let us leave this protection-subversion business, as it will perhaps be only responsible for 0.1% of all chases anyway. Much more important is the in-check problem. About 10% of all chases involved a "one check, one idle" pattern. Most of the time the pattern is like this:

Code: Select all

. . . k . a . . .
. . . . a c . . .
. . . . . H . . .
. . . . R . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .
1.Rd6+ Ke9 2.Re6 Ke8 3.Rd6+

White is doing one check, one idle. But we know from other examples that the side evading the check must be tested for chasing. In this case, his Advisor on e8 is statically attacking Hf7. But that attack is static as pseudo-legal attack only. In reality it is modulated. After every black move, it becomes legal. Every white move than makes it illegal.

So WinBoard currenlty rules black to be perpetually chasing the Horse, and hence a white win. Do you agree with that?
Yes, I agree. Black chases White Horse clearly.
This pattern, of an alternating check and pin, occurs quite fequently. The details differ: the pinned piece making the chase can also be Horse or Elephant. The pinning piece can also be Cannon (with one extra piece on both d- and e-file.
User avatar
hgm
Posts: 27789
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: A method to implement Asian rule

Post by hgm »

phhnguyen wrote:I have been trying to use (1) and (2) (score subverted attack of Cannon). Still trouble to explain both game 61 and A3. They both have very similar pattern:

Cannon of 1st side - Rook of 2nd side - piece A of 1st side - piece B of 2nd side - Cannon of 1st side

In 61, piece B is a Horse, in A3, piece B is a Rook. We have to score so 61 as a win for Rook side, but A3 as a draw.

Of course the simplest way is to announce the pattern C - R - a piece - R - C as an exception case of draw (so we don't need to use any (1), (2) or (3). But I hope to find a better explanation which introduces as less exceptions as possible.

Can we all work together to solve that problem?
You lost me completely here. What do you mean when you say "Rook of 2nd side"? There are no Rook moves in the diagram 61 I have! Just Elephants and Horses. And no Cannon moves in A3.

In my algorithm, when judging the black moves in 61, I would see:
a) before the move: Rc2 attacks Cb2 (which is protected by Ch2)
b) after the move: Rc2 attacks Cb2 (which is now unprotected)

This means the subtraction operator will not remove this capture from the chase list, because the protected state is made worse by the move. (Had it been equal or better, it should have been removed, as attacker and victim are both the same.) But in method (1) this would qualify the move as a chase by subversion, because only the protected state was different, and I mark Rc2xb2 as a lesser violation. The other case would have been

a) before move: A does not attack B (protection of B irrelevant)
b) after move: A does attack B (which is unprotected)

Here the attack status differs, so it is a chase by direct attack (major violation), and I don't even have to consider the protection before the move. (All other combinations of attack and protection before/after would be thrown out immediately, as they can never be chases.) In both cases, a capture that passes (i.e. is not removed from the list) would still be checked after the opponent's reply, to verify that either

A) the attack no longer exists
B) the attack still exists, but the victim is now protected

If (A) or (B) is the case, I keep the move in the list, but whether it was (A) or (B) will not affect the qualification as protecton subversion or direct attack. (Of course it will affect the chase as a whole, because the position after the reply will be the starting position for the next move of this side. So if we have case (B), the victim is now protected even before the move, so to chase it would require subversion of that protection, possibly with or without a new attack on it. But this will all be taken into account when judging the next move.)

With rule (1) the intersection operator would have to keep track of the violence level: if you decide to keep a capture because the victim was the same as that of another capture already in the list, you would have to give it the lowest violence level of the two. Which means that you really would have to go through the entire existing list to determine the highest violence level for any attack on that piece in the old list.

With rule (2) additional tests would be required when a subversion chase is found. In particular it would test if attacker was Rook, protector was Cannon, and both were attacking the victim from the same direction. If this was the case, I remove that capture immediately from the list, just as I would when it had not been a chase because the victim was protected after the move, or the attacker was K or P. There would be no reason in this case to keep track of a level of violence. (I guess that this might make (2) simpler than (1).)
User avatar
phhnguyen
Posts: 1434
Joined: Wed Apr 21, 2010 4:58 am
Location: Australia
Full name: Nguyen Hong Pham

Re: A method to implement Asian rule

Post by phhnguyen »

hgm wrote: You lost me completely here. What do you mean when you say "Rook of 2nd side"? There are no Rook moves in the diagram 61 I have! Just Elephants and Horses. And no Cannon moves in A3.
Sorry, but I don't lose you. I said about a chasing pattern, not moves.
In my algorithm, when judging the black moves in 61, I would see:
a) before the move: Rc2 attacks Cb2 (which is protected by Ch2)
b) after the move: Rc2 attacks Cb2 (which is now unprotected)

This means the subtraction operator will not remove this capture from the chase list, because the protected state is made worse by the move. (Had it been equal or better, it should have been removed, as attacker and victim are both the same.) But in method (1) this would qualify the move as a chase by subversion, because only the protected state was different, and I mark Rc2xb2 as a lesser violation. The other case would have been

a) before move: A does not attack B (protection of B irrelevant)
b) after move: A does attack B (which is unprotected)

Here the attack status differs, so it is a chase by direct attack (major violation), and I don't even have to consider the protection before the move. (All other combinations of attack and protection before/after would be thrown out immediately, as they can never be chases.) In both cases, a capture that passes (i.e. is not removed from the list) would still be checked after the opponent's reply, to verify that either

A) the attack no longer exists
B) the attack still exists, but the victim is now protected

If (A) or (B) is the case, I keep the move in the list, but whether it was (A) or (B) will not affect the qualification as protecton subversion or direct attack. (Of course it will affect the chase as a whole, because the position after the reply will be the starting position for the next move of this side. So if we have case (B), the victim is now protected even before the move, so to chase it would require subversion of that protection, possibly with or without a new attack on it. But this will all be taken into account when judging the next move.)

With rule (1) the intersection operator would have to keep track of the violence level: if you decide to keep a capture because the victim was the same as that of another capture already in the list, you would have to give it the lowest violence level of the two. Which means that you really would have to go through the entire existing list to determine the highest violence level for any attack on that piece in the old list.

With rule (2) additional tests would be required when a subversion chase is found. In particular it would test if attacker was Rook, protector was Cannon, and both were attacking the victim from the same direction. If this was the case, I remove that capture immediately from the list, just as I would when it had not been a chase because the victim was protected after the move, or the attacker was K or P. There would be no reason in this case to keep track of a level of violence. (I guess that this might make (2) simpler than (1).)
Explaining results of all Asia rule examples is not too hard but A3 (the re-edited version).

I can explain the result of game 61 in some different ways using different rules. However, the main problem of how to make that explanation doesn't conflict with A3 still remains.
User avatar
hgm
Posts: 27789
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: A method to implement Asian rule

Post by hgm »

phhnguyen wrote:Sorry, but I don't lose you. I said about a chasing pattern, not moves.
So the pieces you mention are the pieces that are attacked on the various moves? It is really very hard for me to onderstand what you mean, if you don't explain your terminology. "Chasing pattern" means nothing to me. A chasing move has both an attacker and a victim, and the attacker need not be the mover...
Explaining results of all Asia rule examples is not too hard but A3 (the re-edited version).

I can explain the result of game 61 in some different ways using different rules. However, the main problem of how to make that explanation doesn't conflict with A3 still remains.
I still cannot understand why you think (the adapted) A3 is difficult. Both sides are chasing by direct attack, none is checking. Thus draw. IMO it is one of the most trivial examples of the entire set.
User avatar
phhnguyen
Posts: 1434
Joined: Wed Apr 21, 2010 4:58 am
Location: Australia
Full name: Nguyen Hong Pham

Re: A method to implement Asian rule

Post by phhnguyen »

Hi Muller,

I have tried to use subverted protection to score the chase. However, it seems not be enough to explain some games which are not in Asia rule. For example, the game bellow has not any subversion but both sides are chasing each other:

[Event "Computer Chess Game"]
[Site "SCHAAK_PC"]
[Date "2010.06.01"]
[Round "1.1"]
[White "HaQiKi D 1.6i"]
[Black "Cyclonee 1.01"]
[Result "1-0"]
[TimeControl "40/600"]
[Variant "xiangqi"]
[Number "16"]

1. g4 Hc7 2. Hg2 c5 3. Ri1 Hg7 4. Rc1 Hd5 5. Cb5 Hc7 6. Cb6 Ci7 7. c4 Rh9
8. Ch4 cxc4 9. Rxc4 Cb8 10. Hc2 Cc8 11. Cc6 Hce8 12. Cb6 Hc7 13. Cc6 Hce8
14. Cb6 Hc7
{Xboard adjudication: perpetual chasing} 1-0

When trying to explain that game and others I see we may ignore subversion but use some simpler rules which have been mentioned already in Asia rule:

1) By above game, we need to "punish" the Black because Cannon chases Rook. It means Cannon chasing Rook is more violent than Rook chasing any smaller piece

2) Because of game 40 Asian rule, when a Rook and a Cannon chase the pinned Rook, we should score Rook (as well as any others) chases pinned Rook as more violent.

Do you like above rules?

/Pham
User avatar
hgm
Posts: 27789
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: A method to implement Asian rule

Post by hgm »

phhnguyen wrote:For example, the game bellow has not any subversion but both sides are chasing each other:
It took me some time to figure out why this is not mutual chase. Because indeed, first I thought that the black Cannon was being chased too, and I could not understand why WinBoard adjudicated the game to white.

But the key is that Cc6 is not a chasing move, because it is C on C, and Cc8xc6 is possible as 'self-defense'. So it does not matter that Cc8 is unprotected, Cc6 does not count as chasing it. There are no other pieces that chase it on that move. So white has one chase, one idle, which is allowed. Black has two chases against the Rook with the Cannon, however.
User avatar
phhnguyen
Posts: 1434
Joined: Wed Apr 21, 2010 4:58 am
Location: Australia
Full name: Nguyen Hong Pham

Re: A method to implement Asian rule

Post by phhnguyen »

Oops, sorry, my program has a bug in the code for detecting exchange after improving it.

BTW, I have completed all implementations and tests. Will post full and completed algorithm soon.