This is an XBoard patch that makes it possible to use XBoard for Ataxx. It implements two things:
1) With argument -variant atx one enables 'Ataxx mode' where every enemy surrounding the to-square of a move will flip color.
2) With argument -dropMenu true, and if the pieceToCharTable only contains a single piece type (like -pieceToCharTable ".X.....o...."), a right-click on a square will not pop up a menu for selecting the piece you want to drop there, but drops it immediately. This allows you to play the 1-step moves as drops on the to-square by a simple right-click.
Code: Select all
diff --git a/backend.c b/backend.c
index b6088f6..c44f5e8 100644
--- a/backend.c
+++ b/backend.c
@@ -400,6 +400,7 @@ PosFlags (int index)
case VariantLosers:
flags |= F_MANDATORY_CAPTURE; //[HGM] losers: sets flag so TestLegality rejects non-capts if capts exist
break;
+ case VariantAtaxx:
case VariantAtomic:
flags |= F_IGNORE_CHECK | F_ATOMIC_CAPTURE;
break;
@@ -1257,6 +1258,7 @@ InitBackEnd1 ()
and doesn't know captures are mandatory */
case VariantTwoKings: /* should work */
case VariantAtomic: /* should work except for win condition */
+ case VariantAtaxx: /* should work except for win condition */
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 */
@@ -8085,7 +8087,7 @@ Deselect ()
int
RightClick (ClickType action, int x, int y, int *fromX, int *fromY)
{ // front-end-free part taken out of PieceMenuPopup
- int whichMenu; int xSqr, ySqr;
+ int whichMenu; int xSqr, ySqr, n, i, t, side;
if(seekGraphUp) { // [HGM] seekgraph
if(action == Press) SeekGraphClick(Press, x, y, 2); // 2 indicates right-click: no pop-down on miss
@@ -8181,11 +8183,15 @@ RightClick (ClickType action, int x, int y, int *fromX, int *fromY)
if(gameMode == TwoMachinesPlay || gameMode == AnalyzeMode ||
gameMode == AnalyzeFile || gameMode == IcsObserving) return -1;
case EditGame:
+ case BeginningOfGame:
noZip:
if (xSqr < 0 || ySqr < 0) return -1;
if (!appData.dropMenu || appData.testLegality &&
gameInfo.variant != VariantBughouse &&
gameInfo.variant != VariantCrazyhouse) return -1;
+ n = t = 0; side = (currentMove & 1)*BlackPawn;
+ for(i=WhitePawn; i<BlackPawn; i++) if(PieceToChar(i + side) != '.') n++, t = i + side;
+ if(n == 1) whichMenu = 5; else
whichMenu = 1; // drop menu
break;
default:
@@ -8202,6 +8208,7 @@ RightClick (ClickType action, int x, int y, int *fromX, int *fromY)
else
*fromY = BOARD_HEIGHT - 1 - *fromY;
+ if(whichMenu == 5) DropMenuEvent(t, *fromX, *fromY), whichMenu = -2; // only one type; choose it
return whichMenu;
}
@@ -10744,7 +10751,8 @@ ApplyMove (int fromX, int fromY, int toX, int toY, int promoChar, Board board)
board[handSize-1-p][0] = WHITE_TO_BLACK captured;
}
}
- } else if (gameInfo.variant == VariantAtomic) {
+ }
+ if (gameInfo.variant == VariantAtomic) {
if (captured != EmptySquare) {
int y, x;
for (y = toY-1; y <= toY+1; y++) {
@@ -10757,6 +10765,17 @@ ApplyMove (int fromX, int fromY, int toX, int toY, int promoChar, Board board)
}
board[toY][toX] = EmptySquare;
}
+ } else if (gameInfo.variant == VariantAtaxx) {
+ int y, x;
+ for (y = toY-1; y <= toY+1; y++) {
+ for (x = toX-1; x <= toX+1; x++) {
+ if (y >= 0 && y < BOARD_HEIGHT && x >= BOARD_LEFT && x < BOARD_RGHT && (x != toX || y != toY)) {
+ if(board[toY][toX] >= BlackPawn) {
+ if(board[y][x] < BlackPawn) board[y][x] += BlackPawn;
+ } else if(board[y][x] >= BlackPawn && board[y][x] < EmptySquare) board[y][x] -= BlackPawn;
+ }
+ }
+ }
}
if(gameInfo.variant == VariantSChess && promoChar != NULLCHAR && promoChar != '=' && piece != WhitePawn && piece != BlackPawn) {
@@ -15980,6 +15999,7 @@ DropMenuEvent (ChessSquare selection, int x, int y)
moveType = BlackDrop;
break;
case EditGame:
+ case BeginningOfGame:
moveType = WhiteOnMove(currentMove) ? WhiteDrop : BlackDrop;
break;
default:
diff --git a/common.h b/common.h
index 55daf29..6fb73d9 100644
--- a/common.h
+++ b/common.h
@@ -414,6 +414,7 @@ typedef enum {
VariantASEAN,
VariantLion,
VariantChuChess,
+ VariantAtaxx,
VariantUnknown /* Catchall for other unknown variants */
} VariantClass;
@@ -464,6 +465,7 @@ typedef enum {
"asean",\
"lion",\
"elven",\
+ "atx",\
"unknown" \
}
The remaining configuring can be done by existing XBoard options (and can also be done by the engine through a 'setup' command):
xboard -variant atx -ncp -dropMenu true -pieceToCharTable ".X.....o...." -boardWidth 7 -boardHeight 7 -fen "X5o/7/7/7/7/7/o5X w" =men "X:mAmD@;o:mAmD@"
Of course you can also redefine the piece graphics to more suitable images through -pieceImageDirectory.