Skip to content

Commit

Permalink
Avoid expensive crazyhouse null-move searches (resolves official-stoc…
Browse files Browse the repository at this point in the history
  • Loading branch information
ddugovic committed Dec 31, 2016
1 parent 29959a4 commit a408dc2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/position.h
Original file line number Diff line number Diff line change
Expand Up @@ -634,10 +634,12 @@ inline int Position::count_in_hand(Color c, PieceType pt) const {

inline void Position::add_to_hand(Color c, PieceType pt) {
pieceCountInHand[c][pt]++;
pieceCountInHand[c][ALL_PIECES]++;
}

inline void Position::remove_from_hand(Color c, PieceType pt) {
pieceCountInHand[c][pt]--;
pieceCountInHand[c][ALL_PIECES]--;
}

inline bool Position::is_promoted(Square s) const {
Expand Down Expand Up @@ -807,13 +809,13 @@ inline void Position::move_piece(Piece pc, Square from, Square to) {
inline void Position::drop_piece(Piece pc, Square s) {
assert(pieceCountInHand[color_of(pc)][type_of(pc)]);
put_piece(pc, s);
pieceCountInHand[color_of(pc)][type_of(pc)]--;
remove_from_hand(color_of(pc), type_of(pc));
}

inline void Position::undrop_piece(Piece pc, Square s) {
remove_piece(pc, s);
board[s] = NO_PIECE;
pieceCountInHand[color_of(pc)][type_of(pc)]++;
add_to_hand(color_of(pc), type_of(pc));
assert(pieceCountInHand[color_of(pc)][type_of(pc)]);
}
#endif
Expand Down
7 changes: 7 additions & 0 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,14 @@ namespace {
if ( !PvNode
&& eval >= beta
&& (ss->staticEval >= beta - 35 * (depth / ONE_PLY - 6) || depth >= 13 * ONE_PLY)
#ifdef CRAZYHOUSE
// Do not bother with null-move search if opponent can drop pieces
&& (pos.is_house() ? (eval < 2 * VALUE_KNOWN_WIN
&& !(depth > 4 * ONE_PLY && pos.count_in_hand(~pos.side_to_move(), ALL_PIECES))) :
pos.non_pawn_material(pos.side_to_move())))
#else
&& pos.non_pawn_material(pos.side_to_move()))
#endif
{
ss->currentMove = MOVE_NULL;
ss->counterMoves = nullptr;
Expand Down

0 comments on commit a408dc2

Please sign in to comment.