shaochuan / Xiangqi

Chinese chess, a strategy board game for two players.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implement rule "flying general"

hartwork opened this issue · comments

Thanks for such a quick reaction!

The flying generals rule is not applied correctly, though. The generals are not allowed to ever face each other, a situation which would put both parties in check. The configuration shown on http://www.hartwork.org/public/flying-generals-issue.png is not allowed but currently permitted by the implementation. Please fix.

PS: Please re-open this ticket before there is a fix.

From my understanding, this is the rule of flying general. When the generals face each other, the game will be over, and the one who takes the turn will win the game.

Let me quote from the book "Chinese chess" by H. T. Lau (emphasis mine):

[T]he two kings cannot be positioned on the same vertical line without any other piece between them. (In a sense, the king would be able to make a long jump and capture the other king if the two were so aligned.) Thus, in Figure 4, assuming that it is red's move, red's king may not move one space to the right. In Figure 5 (red's move), red cannot move its knight, since doing so would bring the two opposing kings onto the same line without any other piece intervening.

I would attach figure 4 and 5 if I had an easy way right now, maybe I'll do later. The text itself should work even without the figures, though.

So to summarize:

  • The facing situation must not happen; the general would fly, he never does.
  • The "flying general" rule must be respected by all pieces, not just the king.

The free software implementation hoxchess seems to got it right, if you want to see it in action. To play with two human players in hoxchess: In the start-up dialog pick "Play with Computer", then check the "Play with yourself" check box. Example moves: red A4+5, blue A6+5, red K5=4. Now trying to apply blue K5=6 raises "Move is not valid".

Please re-open, the issue is not fixed.