From c0a94e4231633b6894e1ea313bdcf253b0d0019c Mon Sep 17 00:00:00 2001 From: RainRat Date: Wed, 17 Apr 2024 08:11:50 -0700 Subject: [PATCH 1/5] wallOrMove bug fix (#763) --- src/position.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/position.cpp b/src/position.cpp index ade4798d1..b9f34be44 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -1558,7 +1558,7 @@ void Position::do_move(Move m, StateInfo& newSt, bool givesCheck) { Piece captured = piece_on(type_of(m) == EN_PASSANT ? capture_square(to) : to); if (to == from) { - assert((type_of(m) == PROMOTION && sittuyin_promotion()) || (is_pass(m) && pass(us))); + assert((type_of(m) == PROMOTION && sittuyin_promotion()) || (is_pass(m) && (pass(us) || var->wallOrMove ))); captured = NO_PIECE; } st->capturedpromoted = is_promoted(to); @@ -2128,7 +2128,7 @@ void Position::undo_move(Move m) { assert(type_of(m) == DROP || empty(from) || type_of(m) == CASTLING || is_gating(m) || (type_of(m) == PROMOTION && sittuyin_promotion()) - || (is_pass(m) && pass(us))); + || (is_pass(m) && (pass(us) || var->wallOrMove))); assert(type_of(st->capturedPiece) != KING); // Reset wall squares From 0e89b9aa4341fe68d6f1202e7c395d70cf3d9b0b Mon Sep 17 00:00:00 2001 From: yjf2002ghty <47345902+yjf2002ghty@users.noreply.github.com> Date: Tue, 23 Apr 2024 00:47:10 +0800 Subject: [PATCH 2/5] Khan's chess & Shinobi Chess+ (#778) --- src/variants.ini | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/variants.ini b/src/variants.ini index fd5b50497..688cce0d3 100644 --- a/src/variants.ini +++ b/src/variants.ini @@ -1927,3 +1927,46 @@ customPiece2 = p:mW connectValue = loss stalemateValue = win connectPieceTypes = m + +#https://www.pychess.org/variants/shinobiplus +[shinobiplus:crazyhouse] +pieceToCharTable = - +commoner = c +bers = d +dragonHorse = f +archbishop = j +fers = m +shogiKnight = h +lance = l +promotionRegionWhite = *7 *8 +promotionRegionBlack = *1 *2 *3 +promotionPieceTypes = - +promotedPieceType = p:c m:b h:n l:r +mandatoryPiecePromotion = true +stalemateValue = loss +nFoldRule = 4 +perpetualCheckIllegal = true +startFen = rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/4K3[JDFCLHM] w kq - 0 1 +capturesToHand = false +whiteDropRegion = *1 *2 *3 *4 +immobilityIllegal = true +flagPiece = k +flagRegionWhite = *8 +flagRegionBlack = *1 + +#https://www.pychess.org/variants/khans +[khans:chess] +pieceToCharTable = - +centaur = h +knibis = a +kniroo = l +customPiece1 = t:mNcK +customPiece2 = s:mfhNcfW +promotionPawnTypesBlack = s +promotionPieceTypesBlack = t +stalemateValue = loss +nMoveRuleTypesBlack = s +flagPiece = k +flagRegionWhite = *8 +flagRegionBlack = *1 +startFen = lhatkahl/ssssssss/8/8/8/8/PPPPPPPP/RNBQKBNR w KQ - 0 1 From 50adcffd957aaa2b4729409518549fc3107b9c33 Mon Sep 17 00:00:00 2001 From: yjf2002ghty <47345902+yjf2002ghty@users.noreply.github.com> Date: Mon, 29 Apr 2024 20:02:17 +0800 Subject: [PATCH 3/5] Fix stack overflow when depth is too deep (#780) --- src/movegen.h | 34 ++++++++++++++++++++++++++++++++-- src/types.h | 13 +++++++++++-- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/movegen.h b/src/movegen.h index bbb35b391..3047bf6ce 100644 --- a/src/movegen.h +++ b/src/movegen.h @@ -55,12 +55,37 @@ inline bool operator<(const ExtMove& f, const ExtMove& s) { template ExtMove* generate(const Position& pos, ExtMove* moveList); +constexpr size_t moveListSize = sizeof(ExtMove) * MAX_MOVES; + /// The MoveList struct is a simple wrapper around generate(). It sometimes comes /// in handy to use this class instead of the low level generate() function. template struct MoveList { - explicit MoveList(const Position& pos) : last(generate(pos, moveList)) {} + +#ifdef USE_HEAP_INSTEAD_OF_STACK_FOR_MOVE_LIST + explicit MoveList(const Position& pos) + { + this->moveList = (ExtMove*)malloc(moveListSize); + if (this->moveList == 0) + { + printf("Error: Failed to allocate memory in heap."); + exit(1); + } + this->last = generate(pos, this->moveList); + } + + ~MoveList() + { + free(this->moveList); + } +#else + explicit MoveList(const Position& pos) : last(generate(pos, moveList)) + { + ; + } +#endif + const ExtMove* begin() const { return moveList; } const ExtMove* end() const { return last; } size_t size() const { return last - moveList; } @@ -69,7 +94,12 @@ struct MoveList { } private: - ExtMove moveList[MAX_MOVES], *last; + ExtMove* last; +#ifdef USE_HEAP_INSTEAD_OF_STACK_FOR_MOVE_LIST + ExtMove* moveList = 0; +#else + ExtMove moveList[MAX_MOVES]; +#endif }; } // namespace Stockfish diff --git a/src/types.h b/src/types.h index 5abfac80b..b049736b1 100644 --- a/src/types.h +++ b/src/types.h @@ -227,13 +227,22 @@ typedef uint64_t Bitboard; constexpr int SQUARE_BITS = 6; #endif +//When defined, move list will be stored in heap. Delete this if you want to use stack to store move list. Using stack can cause overflow (Segmentation Fault) when the search is too deep. +#define USE_HEAP_INSTEAD_OF_STACK_FOR_MOVE_LIST + #ifdef ALLVARS constexpr int MAX_MOVES = 8192; -constexpr int MAX_PLY = 60; +#ifdef USE_HEAP_INSTEAD_OF_STACK_FOR_MOVE_LIST +constexpr int MAX_PLY = 246; +#else +constexpr int MAX_PLY = 60; +#endif +/// endif USE_HEAP_INSTEAD_OF_STACK_FOR_MOVE_LIST #else constexpr int MAX_MOVES = 1024; -constexpr int MAX_PLY = 246; +constexpr int MAX_PLY = 246; #endif +/// endif ALLVARS /// A move needs 16 bits to be stored /// From 81e3ceec0b16b76a6b2de7da92d15a2dcab362c3 Mon Sep 17 00:00:00 2001 From: yjf2002ghty <47345902+yjf2002ghty@users.noreply.github.com> Date: Sat, 1 Jun 2024 11:53:19 +0800 Subject: [PATCH 4/5] Fix Mini House --- src/variants.ini | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/variants.ini b/src/variants.ini index 688cce0d3..383b7ba75 100644 --- a/src/variants.ini +++ b/src/variants.ini @@ -575,6 +575,9 @@ promotionPawnTypes = - maxRank = 6 maxFile = 6 startFen = 2bnrk/5p/6/6/P5/KRNB2 +promotionPieceTypes = nbr +promotionRegionWhite = *6 +doubleStep = false #https://www.chess.com/variants/rookmate [rookmate:chess] From a449a8be8a576bd1d5dd348ec849796a661707c0 Mon Sep 17 00:00:00 2001 From: chocolatebakery Date: Sat, 1 Jun 2024 08:57:01 +0000 Subject: [PATCH 5/5] Small contribution on a compatible anti/giveaway variant --- src/variants.ini | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/variants.ini b/src/variants.ini index 383b7ba75..7eaeafb33 100644 --- a/src/variants.ini +++ b/src/variants.ini @@ -1973,3 +1973,13 @@ flagPiece = k flagRegionWhite = *8 flagRegionBlack = *1 startFen = lhatkahl/ssssssss/8/8/8/8/PPPPPPPP/RNBQKBNR w KQ - 0 1 + +#https://www.chessvariants.com/diffobjective.dir/giveaway.html +#When stalemate, the stalemated player does not move but the opponent can if he wish to play for win go on moving and do as many moves he wants to do. +#If the stalemate then disappear, both players move again as usual. So, if white for example has a pawn on h2 and nothing more and black a pawn on h3, pawn on a7 and rooks on a8 and h8 +# black can win by moving : 1.-,Rh4 2.-, a5. 3.-, a4 4.- Ra5 5.-,a3 6.-,a2 7.-,a1=R 8.-,Rg1 9.-,Rg3 10.hxg3,h2 11.gxh4,Rg5 12.hxg5,h1=Q 13.g6,Qh7 14.gxh7 and black has won. +[andersgiveaway:giveaway] +passOnStalemate = true + +[andersanti:antichess] +passOnStalemate = true