From: ianfab Date: Thu, 16 Aug 2018 20:55:26 +0000 (+0200) Subject: Support clobber X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=bacc9c8b70a29c3bd5fd464eda55b4d04fe3317a;p=fairystockfish.git Support clobber https://en.wikipedia.org/wiki/Clobber bench: 4737198 --- diff --git a/src/bitboard.cpp b/src/bitboard.cpp index a722a73..8794578 100644 --- a/src/bitboard.cpp +++ b/src/bitboard.cpp @@ -173,6 +173,7 @@ void Bitboards::init() { { -1, 1, 15, 17 }, // euroshogi knight { -8, -1, 1, 7, 8, 9 }, // gold { -8, -1, 1, 8 }, // horse + { -8, -1, 1, 8 }, // clobber { -9, -8, -7, -1, 1, 7, 8, 9 }, // commoner { -9, -8, -7, -1, 1, 7, 8, 9 } // king }; @@ -198,6 +199,7 @@ void Bitboards::init() { { -1, 1, 15, 17 }, // euroshogi knight { -8, -1, 1, 7, 8, 9 }, // gold { -8, -1, 1, 8 }, // horse + {}, // clobber { -9, -8, -7, -1, 1, 7, 8, 9 }, // commoner { -9, -8, -7, -1, 1, 7, 8, 9 } // king }; @@ -223,6 +225,7 @@ void Bitboards::init() { {}, // euroshogi knight {}, // gold { NORTH_EAST, SOUTH_EAST, SOUTH_WEST, NORTH_WEST }, // horse + {}, // clobber {}, // commoner {} // king }; @@ -248,6 +251,7 @@ void Bitboards::init() { {}, // euroshogi knight {}, // gold { NORTH_EAST, SOUTH_EAST, SOUTH_WEST, NORTH_WEST }, // horse + {}, // clobber {}, // commoner {} // king }; @@ -273,6 +277,7 @@ void Bitboards::init() { 0, // euroshogi knight 0, // gold 7, // horse + 0, // clobber 0, // commoner 0 // king }; @@ -298,6 +303,7 @@ void Bitboards::init() { 0, // euroshogi knight 0, // gold 7, // horse + 0, // clobber 0, // commoner 0 // king }; diff --git a/src/position.cpp b/src/position.cpp index 5ab0ca9..c2b40da 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -705,7 +705,7 @@ bool Position::legal(Move m) const { } // no legal moves from target square - if ((type_of(m) == DROP || type_of(m) == NORMAL) && !(moves_bb(us, type_of(moved_piece(m)), to, 0) & board_bb())) + if (immobility_illegal() && (type_of(m) == DROP || type_of(m) == NORMAL) && !(moves_bb(us, type_of(moved_piece(m)), to, 0) & board_bb())) return false; // illegal drops diff --git a/src/position.h b/src/position.h index 79c271a..7656a31 100644 --- a/src/position.h +++ b/src/position.h @@ -108,6 +108,7 @@ public: bool drop_loop() const; bool captures_to_hand() const; bool first_rank_drops() const; + bool immobility_illegal() const; // winning conditions Value stalemate_value(int ply = 0) const; Value checkmate_value(int ply = 0) const; @@ -352,6 +353,11 @@ inline bool Position::first_rank_drops() const { return var->firstRankDrops; } +inline bool Position::immobility_illegal() const { + assert(var != nullptr); + return var->immobilityIllegal; +} + inline Value Position::stalemate_value(int ply) const { assert(var != nullptr); Value v = var->stalemateValue; diff --git a/src/types.h b/src/types.h index aac7022..66874ac 100644 --- a/src/types.h +++ b/src/types.h @@ -211,6 +211,7 @@ enum Value : int { EuroShogiKnightValueMg = 400, EuroShogiKnightValueEg = 400, GoldValueMg = 600, GoldValueEg = 600, HorseValueMg = 1500, HorseValueEg = 1500, + ClobberPieceValueMg = 300, ClobberPieceValueEg = 300, CommonerValueMg = 600, CommonerValueEg = 600, MidgameLimit = 15258, EndgameLimit = 3915 @@ -221,7 +222,7 @@ const int PIECE_TYPE_BITS = 5; // PIECE_TYPE_NB = pow(2, PIECE_TYPE_BITS) enum PieceType { NO_PIECE_TYPE, PAWN, KNIGHT, BISHOP, ROOK, QUEEN, FERS, MET = FERS, ALFIL, SILVER, KHON = SILVER, AIWOK, BERS, DRAGON = BERS, CHANCELLOR, - AMAZON, KNIBIS, BISKNI, SHOGI_PAWN, LANCE, SHOGI_KNIGHT, EUROSHOGI_KNIGHT, GOLD, HORSE, COMMONER, KING, + AMAZON, KNIBIS, BISKNI, SHOGI_PAWN, LANCE, SHOGI_KNIGHT, EUROSHOGI_KNIGHT, GOLD, HORSE, CLOBBER_PIECE, COMMONER, KING, ALL_PIECES = 0, PIECE_TYPE_NB = 1 << PIECE_TYPE_BITS diff --git a/src/variant.cpp b/src/variant.cpp index c0abfaf..f2e7e11 100644 --- a/src/variant.cpp +++ b/src/variant.cpp @@ -253,6 +253,7 @@ void VariantMap::init() { v->promotedPieceType[BISHOP] = HORSE; v->promotedPieceType[ROOK] = DRAGON; v->mandatoryPiecePromotion = true; + v->immobilityIllegal = true; return v; } (); const Variant* judkinsshogi = [&]{ @@ -281,6 +282,7 @@ void VariantMap::init() { v->promotedPieceType[SILVER] = GOLD; v->promotedPieceType[BISHOP] = HORSE; v->promotedPieceType[ROOK] = DRAGON; + v->immobilityIllegal = true; return v; } (); const Variant* minishogi = [&]{ @@ -307,6 +309,7 @@ void VariantMap::init() { v->promotedPieceType[SILVER] = GOLD; v->promotedPieceType[BISHOP] = HORSE; v->promotedPieceType[ROOK] = DRAGON; + v->immobilityIllegal = true; return v; } (); const Variant* losalamos = [&]{ @@ -351,6 +354,20 @@ void VariantMap::init() { // TODO: illegal checkmates return v; } (); + const Variant* clobber = [&]{ + Variant* v = new Variant(); + v->maxRank = RANK_6; + v->maxFile = FILE_E; + v->reset_pieces(); + v->add_piece(CLOBBER_PIECE, 'p'); + v->startFen = "PpPpP/pPpPp/PpPpP/pPpPp/PpPpP/pPpPp w 0 1"; + v->promotionPieceTypes = {}; + v->doubleStep = false; + v->castling = false; + v->stalemateValue = -VALUE_MATE; + v->immobilityIllegal = false; + return v; + } (); // Add to UCI_Variant option add("chess", chess); @@ -382,6 +399,7 @@ void VariantMap::init() { add("almost", almost); add("chigorin", chigorin); add("shatar", shatar); + add("clobber", clobber); } void VariantMap::add(std::string s, const Variant* v) { diff --git a/src/variant.h b/src/variant.h index ec76193..6126673 100644 --- a/src/variant.h +++ b/src/variant.h @@ -52,6 +52,7 @@ struct Variant { bool dropLoop = false; bool capturesToHand = false; bool firstRankDrops = false; + bool immobilityIllegal = false; // game end Value stalemateValue = VALUE_DRAW; Value checkmateValue = -VALUE_MATE;