mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 16:53:09 +00:00
Do not null search when beta is a mate value
Also do not return unproven mates in null search. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
4c294932e7
commit
dae2f600d6
1 changed files with 21 additions and 1 deletions
|
@ -267,6 +267,7 @@ namespace {
|
||||||
void update_pv(SearchStack ss[], int ply);
|
void update_pv(SearchStack ss[], int ply);
|
||||||
void sp_update_pv(SearchStack *pss, SearchStack ss[], int ply);
|
void sp_update_pv(SearchStack *pss, SearchStack ss[], int ply);
|
||||||
bool connected_moves(const Position &pos, Move m1, Move m2);
|
bool connected_moves(const Position &pos, Move m1, Move m2);
|
||||||
|
bool value_is_mate(Value value);
|
||||||
bool move_is_killer(Move m, const SearchStack& ss);
|
bool move_is_killer(Move m, const SearchStack& ss);
|
||||||
Depth extension(const Position &pos, Move m, bool pvNode, bool check, bool singleReply, bool mateThreat, bool* dangerous);
|
Depth extension(const Position &pos, Move m, bool pvNode, bool check, bool singleReply, bool mateThreat, bool* dangerous);
|
||||||
bool ok_to_do_nullmove(const Position &pos);
|
bool ok_to_do_nullmove(const Position &pos);
|
||||||
|
@ -1176,6 +1177,7 @@ namespace {
|
||||||
if ( allowNullmove
|
if ( allowNullmove
|
||||||
&& depth > OnePly
|
&& depth > OnePly
|
||||||
&& !isCheck
|
&& !isCheck
|
||||||
|
&& !value_is_mate(beta)
|
||||||
&& ok_to_do_nullmove(pos)
|
&& ok_to_do_nullmove(pos)
|
||||||
&& approximateEval >= beta - NullMoveMargin)
|
&& approximateEval >= beta - NullMoveMargin)
|
||||||
{
|
{
|
||||||
|
@ -1201,7 +1203,11 @@ namespace {
|
||||||
|
|
||||||
pos.undo_null_move(u);
|
pos.undo_null_move(u);
|
||||||
|
|
||||||
if (nullValue >= beta)
|
if (value_is_mate(nullValue))
|
||||||
|
{
|
||||||
|
/* Do not return unproven mates */
|
||||||
|
}
|
||||||
|
else if (nullValue >= beta)
|
||||||
{
|
{
|
||||||
if (depth < 6 * OnePly)
|
if (depth < 6 * OnePly)
|
||||||
return beta;
|
return beta;
|
||||||
|
@ -1298,10 +1304,12 @@ namespace {
|
||||||
&& !moveIsCapture
|
&& !moveIsCapture
|
||||||
&& !move_promotion(move))
|
&& !move_promotion(move))
|
||||||
{
|
{
|
||||||
|
// History pruning. See ok_to_prune() definition.
|
||||||
if ( moveCount >= 2 + int(depth)
|
if ( moveCount >= 2 + int(depth)
|
||||||
&& ok_to_prune(pos, move, ss[ply].threatMove, depth))
|
&& ok_to_prune(pos, move, ss[ply].threatMove, depth))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// Value based pruning.
|
||||||
if (depth < 3 * OnePly && approximateEval < beta)
|
if (depth < 3 * OnePly && approximateEval < beta)
|
||||||
{
|
{
|
||||||
if (futilityValue == VALUE_NONE)
|
if (futilityValue == VALUE_NONE)
|
||||||
|
@ -2120,6 +2128,18 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// value_is_mate() checks if the given value is a mate one
|
||||||
|
// eventually compensated for the ply.
|
||||||
|
|
||||||
|
bool value_is_mate(Value value) {
|
||||||
|
|
||||||
|
assert(abs(value) <= VALUE_INFINITE);
|
||||||
|
|
||||||
|
return value <= value_mated_in(PLY_MAX)
|
||||||
|
|| value >= value_mate_in(PLY_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// move_is_killer() checks if the given move is among the
|
// move_is_killer() checks if the given move is among the
|
||||||
// killer moves of that ply.
|
// killer moves of that ply.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue