diff --git a/include/board.h b/include/board.h index 9c440aa..29a5c58 100644 --- a/include/board.h +++ b/include/board.h @@ -438,6 +438,24 @@ struct board{ return turn() ? is_passed_push_(mv) : is_passed_push_(mv); } + template + size_t side_num_pieces() const { + return man_.us().pawn().count() + + man_.us().knight().count() + + man_.us().bishop().count() + + man_.us().rook().count() + + man_.us().queen().count() + + man_.us().king().count(); + } + + size_t num_pieces() const { + return side_num_pieces() + side_num_pieces(); + } + + bool is_trivially_drawn() const { + return (num_pieces() == 2) || ((num_pieces() == 3) && (man_.white.knight() | man_.white.bishop() | man_.black.knight() | man_.black.bishop()).any()); + } + template board forward_(const move& mv) const { auto cpy = *this; diff --git a/include/thread_worker.h b/include/thread_worker.h index b16b845..7fea4c7 100644 --- a/include/thread_worker.h +++ b/include/thread_worker.h @@ -78,6 +78,7 @@ struct thread_worker{ if(all_list.size() == 0 && is_check){ return mate_score; } if(all_list.size() == 0) { return draw_score; } if(ss.is_three_fold(bd.hash())){ return draw_score; } + if(bd.is_trivially_drawn()){ return draw_score; } const auto list = is_check ? all_list : all_list.loud(); auto orderer = move_orderer(move_orderer_data{move::null(), move::null(), move::null(), &bd, list, &hh_.us(bd.turn())}); @@ -131,6 +132,7 @@ struct thread_worker{ if(list.size() == 0 && is_check){ return make_result(mate_score, move::null()); } if(list.size() == 0) { return make_result(draw_score, move::null()); } if(ss.is_three_fold(bd.hash())){ return make_result(draw_score, move::null()); } + if(!is_root && bd.is_trivially_drawn()){ return make_result(draw_score, move::null()); } // don't drop into qsearch if in check if(is_check && depth <= 0){ depth = 1; } @@ -175,7 +177,7 @@ struct thread_worker{ // step 6. static null move pruning const bool snm_prune = !is_root && !is_pv && - !is_check && + !is_check && depth <= constants_ -> snmp_depth() && static_eval > beta + constants_ -> snmp_margin(improving, depth) && static_eval > mate_score;