From 4c74671e9d2cc4c5de6f3069fe66b310ab506eda Mon Sep 17 00:00:00 2001 From: Vincent Ollivier Date: Fri, 6 Apr 2012 07:48:07 +0200 Subject: [PATCH] Add Game::is_dangerous() for Futility Pruning --- src/game.h | 1 + src/search.cpp | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/game.h b/src/game.h index 8336017..72e106b 100644 --- a/src/game.h +++ b/src/game.h @@ -67,6 +67,7 @@ class Game void make_move(Move m); void undo_move(Move m); bool is_legal(Move m); + bool is_dangerous(Move m); // Search unsigned long long int perft(unsigned int depth); diff --git a/src/search.cpp b/src/search.cpp index 8283d3d..3f37a10 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -24,6 +24,26 @@ #include "search.h" #include "eval.h" +inline bool Game::is_dangerous(Move m) +{ + // current_position() is used assuming + // that the move as already been made. + + /* + if (board.get_piece(m.get_dest()).get_type() == PAWN) { + const Color c = !current_position().get_turn_color(); + if (m.get_dest_rank() + RANK_6 * c == RANK_7) return true; + } + if (m.is_capture()) { + const Piece capture = current_position().get_capture(); + if (capture.get_type() != PAWN) return true; + } + return m.is_promotion(); + */ + + return m.is_capture() || m.is_promotion(); +} + unsigned long long int Game::perft(unsigned int depth) { if (depth == 0) return 1; @@ -231,8 +251,7 @@ int Game::search(int alpha, int beta, int depth, const int ply) !is_in_check && !is_giving_check && !is_killer_move(depth, move) && - !move.is_capture() && - !move.is_promotion(); + !is_dangerous(move); if (fp_allowed && depth <= FUTILITY_DEPTH) { // Using an array of margins is an idea from Crafty -- 2.11.4.GIT