target = pos.checkers();
}
- // Remove inaccesible squares (outside board + wall squares)
+ // Remove inaccessible squares (outside board + wall squares)
target &= pos.board_bb();
moveList = generate_pawn_moves<Us, Type>(pos, moveList, target);
// capture the flag
if ( capture_the_flag_piece()
&& flag_move()
- && (capture_the_flag(sideToMove) & pieces(sideToMove, capture_the_flag_piece())))
+ && (popcount(capture_the_flag(sideToMove) & pieces(sideToMove, capture_the_flag_piece()))>=flag_piece_count()))
{
- result = (capture_the_flag(~sideToMove) & pieces(~sideToMove, capture_the_flag_piece()))
+ result = (popcount(capture_the_flag(~sideToMove) & pieces(~sideToMove, capture_the_flag_piece()))>=flag_piece_count())
&& sideToMove == WHITE ? VALUE_DRAW : mate_in(ply);
return true;
}
if ( capture_the_flag_piece()
&& (!flag_move() || capture_the_flag_piece() == KING)
- && (capture_the_flag(~sideToMove) & pieces(~sideToMove, capture_the_flag_piece())))
+ && (popcount(capture_the_flag(~sideToMove) & pieces(~sideToMove, capture_the_flag_piece()))>=flag_piece_count()) )
{
bool gameEnd = true;
// Check whether king can move to CTF zone
Bitboard capture_the_flag(Color c) const;
bool flag_move() const;
bool check_counting() const;
+ int flag_piece_count() const;
int connect_n() const;
CheckCount checks_remaining(Color c) const;
MaterialCounting material_counting() const;
return var->flagMove;
}
+inline int Position::flag_piece_count() const {
+ assert(var != nullptr);
+ return var->flagPieceCount;
+}
+
inline bool Position::check_counting() const {
assert(var != nullptr);
return var->checkCounting;
return v;
}
+ Variant* kono_variant() { //https://en.wikipedia.org/wiki/Five_Field_Kono
+ Variant* v = chess_variant_base()->init();
+ v->maxRank = RANK_5;
+ v->maxFile = FILE_E;
+ v->reset_pieces();
+ v->add_piece(CUSTOM_PIECE_1, 'p', "mF"); //diagonally, no capture
+ v->startFen = "ppppp/p3p/5/P3P/PPPPP w - - 0 1";
+ v->flagPiece = CUSTOM_PIECE_1;
+ v->flagRegion[WHITE] = make_bitboard(SQ_A5, SQ_B5, SQ_C5, SQ_D5, SQ_E5, SQ_A4, SQ_E4);
+ v->flagRegion[BLACK] = make_bitboard(SQ_A1, SQ_B1, SQ_C1, SQ_D1, SQ_E1, SQ_A2, SQ_E2);
+ v->flagPieceCount = 7;
+ return v;
+ }
+
+ Variant* fox_and_hounds_variant() { //https://boardgamegeek.com/boardgame/148180/fox-and-hounds
+ Variant* v = chess_variant_base()->init();
+ v->reset_pieces();
+ v->add_piece(CUSTOM_PIECE_1, 'h', "mfF"); //Hound
+ v->add_piece(CUSTOM_PIECE_2, 'f', "mF"); //Fox
+ v->startFen = "1h1h1h1h/8/8/8/8/8/8/4F3 w - - 0 1";
+ v->stalemateValue = -VALUE_MATE;
+ v->flagPiece = CUSTOM_PIECE_2;
+ v->flagRegion[WHITE] = Rank8BB;
+ return v;
+ }
+
// Three-check chess
// Check the king three times to win
// https://lichess.org/variant/threeCheck
add("isolation", isolation_variant());
add("isolation7x7", isolation7x7_variant());
add("snailtrail", snailtrail_variant());
+ add("fox-and-hounds", fox_and_hounds_variant());
+ add("kono", kono_variant());
#ifdef ALLVARS
add("duck", duck_variant());
#endif
int extinctionOpponentPieceCount = 0;
PieceType flagPiece = NO_PIECE_TYPE;
Bitboard flagRegion[COLOR_NB] = {};
+ int flagPieceCount = 1;
bool flagMove = false;
bool checkCounting = false;
int connectN = 0;
# flagRegionBlack: black's target region for capture the flag win rule [Bitboard] (default: )
# flagMove: black gets one more move after white captures the flag [bool] (default: false)
# checkCounting: enable check count win rule (check count is communicated via FEN, see 3check) [bool] (default: false)
+# flagPieceCount: number of flag pieces that have to be in the flag zone [int] (default: 1)
# connectN: number of aligned pieces for win [int] (default: 0)
# materialCounting: enable material counting rules [MaterialCounting] (default: none)
# countingRule: enable counting rules [CountingRule] (default: none)