XBoard/Mini Xiangqi

Discussion of chess software programming and technical issues.

Moderator: Ras

User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

XBoard/Mini Xiangqi

Post by Evert »

I just found out that there exists a 7x7 Xiangqi variant (http://mlwi.magix.net/bg/minixiangqi.htm) and figured it would be fun to make SjaakII play it. This turned out to be quite easy:

Code: Select all

##########################################################
# Mini XiangQi, http://mlwi.magix.net/bg/minixiangqi.htm #
##########################################################
Variant: Mini Xiangqi
Board: 7x7
FEN: "rchkhcr/p1ppp1p/7/7/7/P1PPP1P/RCHKHCR w 0 1"
XBoard pieces: "PH.R.....K.C.ph.r.....k.c."
XBoard parent: "xiangqi"
Zone: palace = c1,d1,e1,c2,d2,e2,c3,d3,e3,c5,d5,e5,c6,d6,e6,c7,d7,e7

Piece: Knight
Move: leap (1,0)+(1,1)&(2,1)
Symbol: "H", "H,h"
Value: 400

Piece: Cannon
Move: slide (H,V)
Capture: hop (H,V)
Symbol: "C", "C,c"
Value: 450

Piece: Rook
Move: slide (H,V)
Symbol: "R", "R,r"
Value: 950

Piece: King
Move: leap (0,1)
Prison: palace, palace
Symbol: "K", "K,k"
Flags: royal

Piece: Pawn
Move: aleap (1,0)|(0,1)|(-1,0)
Symbol: "P", "P,p"
Value: 200

Rule: taboo, chase rule
Rule: checkmate = win
Rule: stalemate = win
Rule: repeat3 = draw
However, there is a cosmetic issue with XBoard: the Xiangqi board colouring is absolute, so changing the board size does not move the palaces around. Additionally, in this case the board has an odd number of ranks (there is no river) so it doesn't make sense to flip colours hald-way along the board. I applied the following patch to my local copy, which makes the board one solid colour if the variant is Xiangqi and the board has an odd number of ranks, and it centres the palaces. It may be useful to include something like it upstream:

Code: Select all

--- ../xboard-6ffd7b3/board.c	2015-02-21 20:08:00.000000000 +0100
+++ board.c	2015-03-20 17:21:57.000000000 +0100
@@ -252,12 +252,14 @@
     int square_color;
 
     if (gameInfo.variant == VariantXiangqi) {
-        if (column >= 3 && column <= 5 && row >= 0 && row <= 2) {
-            square_color = 1;
-        } else if (column >= 3 && column <= 5 && row >= 7 && row <= 9) {
-            square_color = 0;
-        } else if (row <= 4) {
+        int col1 = gameInfo.boardWidth / 3;
+        int col2 = col1 + 2;
+        if (column >= col1 && column <= col2 && row >= 0 && row <= 2) {
+            square_color = 1 - (gameInfo.boardHeight & 1);
+        } else if (column >= col1 && column <= col2 && row >= gameInfo.boardHeight-3 && row < gameInfo.boardHeight) {
             square_color = 0;
+        } else if (row < gameInfo.boardHeight/2) {
+            square_color = gameInfo.boardHeight & 1;
         } else {
             square_color = 1;
         }
User avatar
hgm
Posts: 28481
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: XBoard/Mini Xiangqi

Post by hgm »

Interesting, I was not aware that this was a difference between XBoard and WinBoard. The latter already does center the Palace, making it 3 or 4 wide, depending on whether the board width is even or odd. Always 3 deep, however. But when the board-height is odd, it draws a 1-wide River half-way the board.

I guess the XBoard code is still from a patch by the HoiChess/HoiXiangqi author, from before WinBoard was merged back into XBoard.

I wll have a look at it.