Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add xiangqi(chinese chess) support #565

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

gaintpd
Copy link

@gaintpd gaintpd commented May 23, 2020

Hi there, This is my implementation of the xiangqi support to cutechess. The code is implemented in last November. and I have test the implementation using the chess engine maxqi, hoixiangqi, sjaakii, fairy-stockfish largeboard edition several hundred times.

@gaintpd
Copy link
Author

gaintpd commented May 23, 2020

add the manchu chess support to cutechess, this support is implemented in the end of last year.

@gaintpd
Copy link
Author

gaintpd commented May 23, 2020

@artoj This is the minixiangqi implementation, It works quite well on the Ubuntu 18.04 LTS, compiled by Qt 5.11.3, but the minixiangqi implementation always cause a crash on the windows 10 platform. which is very weird. Special attention is should be payed to merge this implementation to the master branch before the detailed review.
Screenshot from 2020-05-23 20-22-00

@ilaripih
Copy link
Member

This is seriously cool! I tested it briefly on Ubuntu and I'll test more on Windows 10 later this week.

I think the GraphicsBoard code should be split into subclasses (or new BoardPainter delegate classes) instead of having if...else code and separate board-painting methods for Chess board, Xiangqi board and Mini Xiangqi board. I can do that, it looks like it should be easy.

@gaintpd
Copy link
Author

gaintpd commented Jun 30, 2020

Thank you very much for your positive evaluation. And it is really a wonderful news that you have the solution to remove the stupidity that was brought by the if else sentence, which is a boring for me(I noticed this stupidity, but I did not come up with a good solution yet).

At the same time, attention is also needed to pay to the member function squareAt and squarePos of GraphicsBoard, there are the same amount of if else sentence too.

I also paint the Janggi board in the Janggi PR. There is a person that request me to paint the Makruk and Sittuyin regional chess board. I have paint them all. I will open a new PR this evening. Here is the issue the open in my fork. gaintpd#3

@gaintpd gaintpd changed the title add the xiangqi(chinese chess) support add xiangqi(chinese chess) support Aug 16, 2020
@alwey
Copy link
Contributor

alwey commented Oct 16, 2020

@gaintpd: Do you think it is possible to also include Chinese notation at some point without too much effort or complications?

@gaintpd
Copy link
Author

gaintpd commented Oct 20, 2020

@alwey My approach to make the xiangqi game notation in the Chinese character format is not incompatible with the chess game notation, and the the two formats cant co-exist simutaneously for Xiangqi. Since cutechess is widely used in the non-Chinese areas, so the code support Chinese format was removed purposely in this patch.

FYI: The approach is quite simple, rewrite the code in the EasternBoard class, the specific functions are moveString and moveFromString.

@QueensGambit
Copy link
Contributor

QueensGambit commented Apr 28, 2021

Thank you for your great work @gaintpd !
I think the perpetual check chasing rule is still missing and games are often adjudicated as a Draw by 5-fold repetition instead of a loss for the engine which gives perpetual checks.

In the following a small example.
Starting from move 28., Fairy-SF 11.2 evaluates the position as a mate in one.

[Event "My Tournament"]
[Site "?"]
[Date "2021.04.28"]
[Round "14"]
[White "Fairy-SF 11.2 - 1 Thread"]
[Black "XiangqiAra-Dev (20210428) - 4 Threads"]
[Result "1/2-1/2"]
[FEN "r1bakabnr/9/1cn4c1/p1p1p1p1p/9/9/P1P1P1P1P/1C3C3/R8/1NBAKABNR b - - 0 1"]
[GameDuration "00:01:40"]
[GameEndTime "2021-04-28T13:09:21.968 CEST"]
[GameStartTime "2021-04-28T13:07:41.033 CEST"]
[PlyCount "66"]
[SetUp "1"]
[TimeControl "60+0.25"]
[Variant "xiangqi"]

1... Ca8 {-0.08/17 1.6s} 2. Ng3 {+0.44/16 2.9s} Rb10 {-0.14/22 1.7s}
3. Bce3 {+0.47/15 0.51s} g6 {+0.06/19 1.5s} 4. Rh1 {+0.65/15 0.80s}
Ni8 {0.00/20 1.7s} 5. Nd2 {+0.29/17 6.5s} Cg8 {+0.18/23 1.3s}
6. Rh6 {+0.47/14 0.42s} i6 {+0.40/17 1.5s} 7. Rxg6 {+0.79/17 2.9s}
Rh10 {+0.27/19 1.7s} 8. g5 {+0.13/18 3.0s} c6 {+0.25/18 1.7s}
9. Nf5 {+1.30/16 1.0s} Nh6 {+0.57/23 1.0s} 10. Nd6 {+0.45/18 8.1s}
Nxd6 {+0.99/22 1.0s} 11. Rxd6 {+0.56/15 0.38s} Ng4 {+1.21/22 1.5s}
12. Rd7 {+1.18/17 3.2s} Rh2 {+1.76/19 1.3s} 13. Cb2 {+0.89/15 1.5s}
Rxb2 {+1.96/14 1.0s} 14. Rxb2 {+2.54/13 0.73s} Rf2 {+1.71/18 1.8s}
15. Bi3 {+2.57/15 5.3s} Ch8 {+2.78/19 1.8s} 16. g6 {+3.16/14 2.2s}
Ch1+ {+2.98/21 1.0s} 17. Ae2 {+2.19/14 1.5s} Nh2 {+4.54/19 1.8s}
18. Ad3 {-7.36/17 2.8s} Cxa4 {+4.84/18 1.5s} 19. Cf9 {-3.74/13 0.90s}
Ca1+ {+5.61/18 1.3s} 20. Rb1 {-3.87/19 1.3s} Rxf9 {+5.97/18 0.76s}
21. Ke2 {-8.13/18 4.1s} Rf1 {+6.47/16 1.5s} 22. Rxe7+ {-4.50/15 0.86s}
Bge8 {+6.18/28 2.0s} 23. Rxa1 {-2.27/14 0.41s} Ci1 {+5.53/24 2.0s}
24. Beg5 {-2.66/16 0.93s} Rf2+ {+5.39/24 2.0s} 25. Ke1 {-1.27/14 0.40s}
Rf1+ {+5.34/24 2.0s} 26. Ke2 {-2.66/5 0s} Rf2+ {+5.46/22 0.52s}
27. Ke1 {-4.00/18 0.31s} Rf1+ {+5.31/24 2.1s} 28. Ke2 {+M1/29 0s}
Rf2+ {+5.42/24 0.77s} 29. Ke1 {+M1/245 0.003s} Rf1+ {+5.18/24 2.2s}
30. Ke2 {+M1/21 0s} Rf2+ {+5.38/23 1.0s} 31. Ke1 {+M1/245 0.003s}
Rf1+ {+5.35/25 1.3s} 32. Ke2 {+M1/1 0s} Rf2+ {+5.63/22 0.52s}
33. Ke1 {+M1/245 0.003s} Rf1+ {+5.47/21 1.2s}
34. Ke2 {+M1/11 0s, Draw by 5-fold repetition} 1/2-1/2

@ilaripih
Copy link
Member

ilaripih commented Jul 3, 2021

Took long enough, but I finally refactored the GUI stuff which is located in this branch: https://github.com/cutechess/cutechess/tree/pr/565

Unfortunately there are many other quality/consistency issues that prevent us from merging this code:

  • The perpetual check chasing rule showcased by @QueensGambit
  • Pieces don't snap into place when they're dragged in Minixiangqi. Only after an additional click the move is finished. I don't know what causes this, the problem is not there in normal Xiangqi.
  • Minixiangqiboard::inCheck() used to crash with the default starting position. I made a quick and dirty fix which may not address the issue completely. Perft unit tests would be very useful here, like we have for other variants.
  • Code style (e.g. indentation and other whitespace) doesn't follow Cute Chess style.
  • The EasternBoard class seems to be mostly copy-paste code from WesternBoard, with lots of code lines and comments that are not needed and simply don't apply to Eastern variants. This would need to be refactored so that the amount of new code is minimal.

@titandino88
Copy link

titandino88 commented Sep 14, 2023

Any plans when xiangqi will be made available to public release?

@jeffli678
Copy link

Is there any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants