From: H.G. Muller Date: Sun, 19 May 2013 21:03:09 +0000 (+0200) Subject: Implement variant ASEAN X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=30ded7c1180da9dc3dc703d92f4c0617ea092647;p=xboard.git Implement variant ASEAN This is basically a clone of Makruk, with as only difference the depth of the promotion zone, the initial setup, and the pieceToCharTable. --- diff --git a/backend.c b/backend.c index b43a970..8554b56 100644 --- a/backend.c +++ b/backend.c @@ -388,6 +388,7 @@ PosFlags (index) case VariantShatranj: case VariantCourier: case VariantMakruk: + case VariantASEAN: case VariantGrand: flags &= ~F_ALL_CASTLE_OK; break; @@ -557,6 +558,13 @@ ChessSquare makrukArray[2][BOARD_FILES] = { /* [HGM] (movGen knows about Shatran BlackKing, BlackMan, BlackKnight, BlackRook } }; +ChessSquare aseanArray[2][BOARD_FILES] = { /* [HGM] (movGen knows about Shatranj Q and P) */ + { WhiteRook, WhiteKnight, WhiteMan, WhiteFerz, + WhiteKing, WhiteMan, WhiteKnight, WhiteRook }, + { BlackRook, BlackKnight, BlackMan, BlackFerz, + BlackKing, BlackMan, BlackKnight, BlackRook } +}; + #if (BOARD_FILES>=10) ChessSquare ShogiArray[2][BOARD_FILES] = { @@ -1158,6 +1166,7 @@ InitBackEnd1 () case Variant3Check: /* should work except for win condition */ case VariantShatranj: /* should work except for all win conditions */ case VariantMakruk: /* should work except for draw countdown */ + case VariantASEAN : /* should work except for draw countdown */ case VariantBerolina: /* might work if TestLegality is off */ case VariantCapaRandom: /* should work */ case VariantJanus: /* should work */ @@ -5090,7 +5099,8 @@ SendMoveToICS (ChessMove moveType, int fromX, int fromY, int toX, int toY, char break; case WhitePromotion: case BlackPromotion: - if(gameInfo.variant == VariantShatranj || gameInfo.variant == VariantCourier || gameInfo.variant == VariantMakruk) + if(gameInfo.variant == VariantShatranj || gameInfo.variant == VariantCourier || + gameInfo.variant == VariantMakruk || gameInfo.variant == VariantASEAN) snprintf(user_move, MSG_SIZ, "%c%c%c%c=%c\n", AAA + fromX, ONE + fromY, AAA + toX, ONE + toY, PieceToChar(WhiteFerz)); @@ -5902,6 +5912,12 @@ InitPosition (int redraw) startedFromSetupPosition = TRUE; SetCharTable(pieceToChar, "PN.R.M....SKpn.r.m....sk"); break; + case VariantASEAN: + pieces = aseanArray; + nrCastlingRights = 0; + startedFromSetupPosition = TRUE; + SetCharTable(pieceToChar, "PN.R.Q....BKpn.r.q....bk"); + break; case VariantTwoKings: pieces = twoKingsArray; break; @@ -6030,7 +6046,7 @@ InitPosition (int redraw) pawnRow = gameInfo.boardHeight - 7; /* seems to work in all common variants */ if(pawnRow < 1) pawnRow = 1; - if(gameInfo.variant == VariantMakruk || gameInfo.variant == VariantGrand) pawnRow = 2; + if(gameInfo.variant == VariantMakruk || gameInfo.variant == VariantASEAN || gameInfo.variant == VariantGrand) pawnRow = 2; /* User pieceToChar list overrules defaults */ if(appData.pieceToCharTable != NULL) @@ -6322,7 +6338,8 @@ ChessSquare DefaultPromoChoice (int white) { ChessSquare result; - if(gameInfo.variant == VariantShatranj || gameInfo.variant == VariantCourier || gameInfo.variant == VariantMakruk) + if(gameInfo.variant == VariantShatranj || gameInfo.variant == VariantCourier || + gameInfo.variant == VariantMakruk || gameInfo.variant == VariantASEAN) result = WhiteFerz; // no choice else if(gameInfo.variant == VariantSuicide || gameInfo.variant == VariantGiveaway) result= WhiteKing; // in Suicide Q is the last thing we want @@ -6407,7 +6424,8 @@ HasPromotionChoice (int fromX, int fromY, int toX, int toY, char *promoChoice, i } // we either have a choice what to promote to, or (in Shogi) whether to promote - if(gameInfo.variant == VariantShatranj || gameInfo.variant == VariantCourier || gameInfo.variant == VariantMakruk) { + if(gameInfo.variant == VariantShatranj || gameInfo.variant == VariantCourier || + gameInfo.variant == VariantMakruk || gameInfo.variant == VariantASEAN) { *promoChoice = PieceToChar(BlackFerz); // no choice return FALSE; } @@ -7053,7 +7071,7 @@ CanPromote (ChessSquare piece, int y) if(gameInfo.variant == VariantShogi || gameInfo.variant == VariantXiangqi || gameInfo.variant == VariantSuper || gameInfo.variant == VariantGreat || gameInfo.variant == VariantShatranj || gameInfo.variant == VariantCourier || - gameInfo.variant == VariantMakruk) return FALSE; + gameInfo.variant == VariantMakruk || gameInfo.variant == VariantASEAN) return FALSE; return (piece == BlackPawn && y == 1 || piece == WhitePawn && y == BOARD_HEIGHT-2 || piece == BlackLance && y == 1 || @@ -14508,6 +14526,7 @@ EditPositionMenuEvent (ChessSquare selection, int x, int y) if(gameInfo.variant == VariantShatranj || gameInfo.variant == VariantXiangqi || gameInfo.variant == VariantCourier || + gameInfo.variant == VariantASEAN || gameInfo.variant == VariantMakruk ) selection = (ChessSquare)((int)selection - (int)WhiteQueen + (int)WhiteFerz); goto defaultlabel; @@ -17131,7 +17150,8 @@ PositionToFEN (int move, char *overrideCastling) } if(gameInfo.variant != VariantShogi && gameInfo.variant != VariantXiangqi && - gameInfo.variant != VariantShatranj && gameInfo.variant != VariantCourier && gameInfo.variant != VariantMakruk ) { + gameInfo.variant != VariantShatranj && gameInfo.variant != VariantCourier && + gameInfo.variant != VariantMakruk && gameInfo.variant != VariantASEAN ) { /* En passant target square */ if (move > backwardMostMove) { fromX = moveList[move - 1][0] - AAA; @@ -17415,7 +17435,8 @@ ParseFEN (Board board, int *blackPlaysFirst, char *fen) /* read e.p. field in games that know e.p. capture */ if(gameInfo.variant != VariantShogi && gameInfo.variant != VariantXiangqi && - gameInfo.variant != VariantShatranj && gameInfo.variant != VariantCourier && gameInfo.variant != VariantMakruk ) { + gameInfo.variant != VariantShatranj && gameInfo.variant != VariantCourier && + gameInfo.variant != VariantMakruk && gameInfo.variant != VariantASEAN ) { if(*p=='-') { p++; board[EP_STATUS] = EP_NONE; } else { diff --git a/common.h b/common.h index 4df1a46..049d428 100644 --- a/common.h +++ b/common.h @@ -338,6 +338,7 @@ typedef enum { VariantGreat, VariantTwilight, VariantMakruk, + VariantASEAN, VariantSChess, VariantGrand, VariantSpartan, @@ -384,6 +385,7 @@ typedef enum { "great",\ "twilight",\ "makruk",\ + "asean",\ "seirawan",\ "grand",\ "spartan",\ diff --git a/dialogs.c b/dialogs.c index a9c6414..d6cf378 100644 --- a/dialogs.c +++ b/dialogs.c @@ -426,7 +426,7 @@ static Option variantDescriptors[] = { { 0, 0, 275, NULL, NULL, NULL, NULL, Label, warning }, { 0, 0, 275, NULL, NULL, NULL, NULL, Label, "Variants marked with * can only be played\nwith legality testing off"}, { 0, SAME_ROW, 0, NULL, NULL, NULL, NULL, Break, ""}, -{ VariantFairy, 0, 135, NULL, (void*) &Pick, "#BFBFBF", NULL, Button, N_("fairy")}, +{ VariantASEAN, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_("ASEAN")}, { VariantGreat, SAME_ROW, 135, NULL, (void*) &Pick, "#BFBFFF", NULL, Button, N_("Great Shatranj (10x8)")}, { VariantSChess, 0, 135, NULL, (void*) &Pick, "#FFBFBF", NULL, Button, N_("Seirawan")}, { VariantFalcon, SAME_ROW, 135, NULL, (void*) &Pick, "#BFBFFF", NULL, Button, N_("falcon (10x8)")}, @@ -444,7 +444,8 @@ static Option variantDescriptors[] = { { VariantShogi, SAME_ROW, 135, NULL, (void*) &Pick, "#BFFFFF", NULL, Button, N_("shogi (9x9)")}, { VariantSpartan, 0, 135, NULL, (void*) &Pick, "#FF0000", NULL, Button, N_("Spartan")}, { VariantXiangqi, SAME_ROW,135, NULL, (void*) &Pick, "#BFFFFF", NULL, Button, N_("xiangqi (9x10)")}, -{ VariantNormal, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_(" ")}, // dummy, to have good alignment +{ VariantFairy, 0, 135, NULL, (void*) &Pick, "#BFBFBF", NULL, Button, N_("fairy")}, +//{ VariantNormal, 0, 135, NULL, (void*) &Pick, "#FFFFFF", NULL, Button, N_(" ")}, // dummy, to have good alignment { VariantCourier, SAME_ROW,135, NULL, (void*) &Pick, "#BFFFBF", NULL, Button, N_("courier (12x8)")}, { 0, NO_OK, 0, NULL, NULL, "", NULL, EndMark , "" } }; diff --git a/moves.c b/moves.c index d59542a..8cd3434 100644 --- a/moves.c +++ b/moves.c @@ -573,7 +573,7 @@ GenPseudoLegal (Board board, int flags, MoveCallback callback, VOIDSTAR closure, /* Shogi Pawn and Silver General: first the Pawn move, */ /* then the General continues like a Ferz */ case WhiteMan: - if(gameInfo.variant != VariantMakruk) goto commoner; + if(gameInfo.variant != VariantMakruk && gameInfo.variant != VariantASEAN) goto commoner; case SHOGI WhitePawn: case SHOGI WhiteFerz: if (rf < BOARD_HEIGHT-1 && @@ -584,7 +584,7 @@ GenPseudoLegal (Board board, int flags, MoveCallback callback, VOIDSTAR closure, break; case BlackMan: - if(gameInfo.variant != VariantMakruk) goto commoner; + if(gameInfo.variant != VariantMakruk && gameInfo.variant != VariantASEAN) goto commoner; case SHOGI BlackPawn: case SHOGI BlackFerz: if (rf > 0 && @@ -1400,7 +1400,8 @@ Disambiguate (Board board, int flags, DisambiguateClosure *closure) } else if (closure->kind == WhitePromotion || closure->kind == BlackPromotion) { if(c == NULLCHAR) { // missing promoChar on mandatory promotion; use default for variant - if(gameInfo.variant == VariantShatranj || gameInfo.variant == VariantCourier || gameInfo.variant == VariantMakruk) + if(gameInfo.variant == VariantShatranj || gameInfo.variant == VariantCourier || + gameInfo.variant == VariantMakruk || gameInfo.variant == VariantASEAN) c = PieceToChar(BlackFerz); else if(gameInfo.variant == VariantGreat) c = PieceToChar(BlackMan); diff --git a/winboard/resource.h b/winboard/resource.h index 7ad0f61..d9f2ce4 100644 --- a/winboard/resource.h +++ b/winboard/resource.h @@ -504,6 +504,7 @@ #define OPT_VariantMakruk 1529 #define OPT_VariantSChess 1530 #define OPT_VariantSpartan 1531 +#define OPT_VariantASEAN 1532 #define OPT_VariantGrand 1534 #define IDC_Files 1550 #define IDC_Ranks 1551 diff --git a/winboard/winboard.rc b/winboard/winboard.rc index 2ae52e6..e75cc19 100644 --- a/winboard/winboard.rc +++ b/winboard/winboard.rc @@ -728,6 +728,8 @@ BEGIN 94,70,10 CONTROL "&makruk",OPT_VariantMakruk,"Button",BS_AUTORADIOBUTTON,80, 104,70,10 + CONTROL "&ASEAN",OPT_VariantASEAN,"Button",BS_AUTORADIOBUTTON,80, + 114,70,10 CONTROL "&gothic",OPT_VariantGothic,"Button",BS_AUTORADIOBUTTON,154,14, 70,10 CONTROL "&capablanca",OPT_VariantCapablanca,"Button",BS_AUTORADIOBUTTON,154, diff --git a/winboard/woptions.c b/winboard/woptions.c index 1979228..a97248b 100644 --- a/winboard/woptions.c +++ b/winboard/woptions.c @@ -853,6 +853,7 @@ int radioButton[] = { OPT_VariantGreat, -1, // Twilight, OPT_VariantMakruk, + OPT_VariantASEAN, OPT_VariantSChess, OPT_VariantGrand, OPT_VariantSpartan, // Spartan diff --git a/xboard.texi b/xboard.texi index d59246f..2a82bae 100644 --- a/xboard.texi +++ b/xboard.texi @@ -3429,6 +3429,7 @@ cylinder Pieces wrap around the board edge knightmate King moves as Knight, and vice versa super Superchess (shuffle variant with 4 exo-pieces) makruk Thai Chess (shatranj-like, P promotes on 6th rank) +asean ASEAN Chess (a modernized version of Makruk) spartan Spartan Chess (black has unorthodox pieces) fairy A catchall variant in which all piece types known to XBoard can participate (8x8)