Use the same syntax for custom king as for other custom pieces.
Closes #363.
// piece types
for (PieceType pt = PAWN; pt <= KING; ++pt)
{
+ if (pt == CUSTOM_PIECES_ROYAL)
+ // reserved custom royal/king slot
+ continue;
+
// piece char
std::string name = piece_name(pt);
else if (DoCheck)
std::cerr << name << " - Missing Betza move notation" << std::endl;
}
+ else if (pt == KING)
+ {
+ if (keyValue->second.size() > 1)
+ {
+ // custom royal piece
+ v->customPiece[CUSTOM_PIECES_ROYAL - CUSTOM_PIECES] = keyValue->second.substr(2);
+ v->kingType = CUSTOM_PIECES_ROYAL;
+ }
+ else
+ v->kingType = KING;
+ }
}
// mobility region
std::string capitalizedPiece = name;
parse_attribute("castlingKingFile", v->castlingKingFile);
parse_attribute("castlingKingPiece", v->castlingKingPiece, v->pieceToChar);
parse_attribute("castlingRookPiece", v->castlingRookPiece, v->pieceToChar);
- parse_attribute("kingType", v->kingType, v->pieceToChar);
parse_attribute("checking", v->checking);
parse_attribute("dropChecks", v->dropChecks);
parse_attribute("mustCapture", v->mustCapture);
std::cerr << "Can not use kings with blastOnCapture." << std::endl;
if (v->flipEnclosedPieces)
std::cerr << "Can not use kings with flipEnclosedPieces." << std::endl;
- // We can not fully check custom king movements at this point
+ // We can not fully check support for custom king movements at this point,
+ // since custom pieces are only initialized on loading of the variant.
+ // We will assume this is valid, but it might cause problems later if it's not.
if (!is_custom(v->kingType))
{
const PieceInfo* pi = pieceMap.find(v->kingType)->second;
PIECE_TYPE_NB = 1 << PIECE_TYPE_BITS,
KING = PIECE_TYPE_NB - 1,
CUSTOM_PIECES_END = KING - 1,
+ CUSTOM_PIECES_ROYAL = CUSTOM_PIECES_END,
CUSTOM_PIECES_NB = CUSTOM_PIECES_END - CUSTOM_PIECES + 1,
ALL_PIECES = 0,
};
### Custom pieces
# Custom pieces can be defined by using one of the available slots:
-# customPiece1, customPiece2, ..., customPiece26
+# customPiece1, customPiece2, ..., customPiece25
# E.g., pawns without double steps could be described as:
# customPiece1 = p:mfWcfF
#
+# You can define custom king movements in the same way you can define another custom piece.
+# E.g., to make the king move like a centaur:
+# king = k:KN
+# In constrast to other custom pieces the Betza notation for the king is optional though
+# and defaults to a standard chess king (betza: K) when skipped, e.g.:
+# king = k
+#
# The movements of custom pieces can be defined using the Betza notation.
# https://www.gnu.org/software/xboard/Betza.html
# In Fairy-Stockfish only a subset of Betza notation can be used. The supported features are:
# castlingKingFile: starting file of the castlingKingPiece if there can be more than one of that type [File] (default: e)
# castlingKingPiece: first piece type that participates in castling [PieceType] (default: k)
# castlingRookPiece: second piece type that participates in castling [PieceType] (default: r)
-# kingType: piece type defining moves of king/royal piece (default: k)
# checking: allow checks [bool] (default: true)
# dropChecks: allow checks by piece drops [bool] (default: true)
# mustCapture: captures are mandatory (check evasion still takes precedence) [bool] (default: false)
doubleStep = false
castling = false
+# Centaurking
+# A variant demonstrating how to define a custom royal piece movement
+[centaurking:chess]
+king = k:KN
+
# Mahajarah and the Sepoys
# https://en.wikipedia.org/wiki/Maharajah_and_the_Sepoys
[maharajah]