mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 08:43:09 +00:00
Use nullMove only through MovePicker.
No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
f6d2452916
commit
a5d699d62f
2 changed files with 46 additions and 42 deletions
|
@ -44,6 +44,7 @@ namespace {
|
|||
|
||||
CACHE_LINE_ALIGNMENT
|
||||
const MovegenPhaseT MainSearchPhaseTable[] = { PH_STOP, PH_NULL_MOVE, PH_TT_MOVES, PH_GOOD_CAPTURES, PH_KILLERS, PH_NONCAPTURES, PH_BAD_CAPTURES, PH_STOP};
|
||||
const MovegenPhaseT MainSearchNoNullPhaseTable[] = { PH_STOP, PH_TT_MOVES, PH_GOOD_CAPTURES, PH_KILLERS, PH_NONCAPTURES, PH_BAD_CAPTURES, PH_STOP};
|
||||
const MovegenPhaseT EvasionsPhaseTable[] = { PH_STOP, PH_EVASIONS, PH_STOP};
|
||||
const MovegenPhaseT QsearchWithChecksPhaseTable[] = { PH_STOP, PH_TT_MOVES, PH_QCAPTURES, PH_QCHECKS, PH_STOP};
|
||||
const MovegenPhaseT QsearchWithoutChecksPhaseTable[] = { PH_STOP, PH_TT_MOVES, PH_QCAPTURES, PH_STOP};
|
||||
|
@ -79,7 +80,7 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d,
|
|||
if (p.is_check())
|
||||
phasePtr = EvasionsPhaseTable;
|
||||
else if (d > Depth(0))
|
||||
phasePtr = MainSearchPhaseTable;
|
||||
phasePtr = useNullMove ? MainSearchPhaseTable : MainSearchNoNullPhaseTable;
|
||||
else if (d == Depth(0))
|
||||
phasePtr = QsearchWithChecksPhaseTable;
|
||||
else
|
||||
|
@ -116,7 +117,7 @@ Move MovePicker::get_next_move() {
|
|||
switch (*phasePtr) {
|
||||
|
||||
case PH_NULL_MOVE:
|
||||
break;
|
||||
return MOVE_NULL;
|
||||
|
||||
case PH_TT_MOVES:
|
||||
movesPicked = 0; // This is used as index to ttMoves[]
|
||||
|
|
|
@ -1288,8 +1288,49 @@ namespace {
|
|||
&& ok_to_do_nullmove(pos)
|
||||
&& approximateEval >= beta - NullMoveMargin);
|
||||
|
||||
// Null move search not allowed, try razoring
|
||||
if ( !useNullMove
|
||||
&& !value_is_mate(beta)
|
||||
&& depth < RazorDepth
|
||||
&& approximateEval < beta - RazorApprMargins[int(depth) - 2]
|
||||
&& ss[ply - 1].currentMove != MOVE_NULL
|
||||
&& ttMove == MOVE_NONE
|
||||
&& !pos.has_pawn_on_7th(pos.side_to_move()))
|
||||
{
|
||||
Value v = qsearch(pos, ss, beta-1, beta, Depth(0), ply, threadID);
|
||||
if (v < beta - RazorMargins[int(depth) - 2])
|
||||
return v;
|
||||
}
|
||||
|
||||
// Go with internal iterative deepening if we don't have a TT move
|
||||
if (UseIIDAtNonPVNodes && ttMove == MOVE_NONE && depth >= 8*OnePly &&
|
||||
evaluate(pos, ei, threadID) >= beta - IIDMargin)
|
||||
{
|
||||
search(pos, ss, beta, Min(depth/2, depth-2*OnePly), ply, false, threadID);
|
||||
ttMove = ss[ply].pv[ply];
|
||||
}
|
||||
|
||||
// Initialize a MovePicker object for the current position, and prepare
|
||||
// to search all moves.
|
||||
MovePicker mp = MovePicker(pos, ttMove, depth, H, &ss[ply], useNullMove);
|
||||
|
||||
Move move, movesSearched[256];
|
||||
int moveCount = 0;
|
||||
Value value, bestValue = -VALUE_INFINITE;
|
||||
Bitboard dcCandidates = mp.discovered_check_candidates();
|
||||
Value futilityValue = VALUE_NONE;
|
||||
bool useFutilityPruning = depth < SelectiveDepth
|
||||
&& !isCheck;
|
||||
|
||||
// Loop through all legal moves until no moves remain or a beta cutoff
|
||||
// occurs.
|
||||
while ( bestValue < beta
|
||||
&& (move = mp.get_next_move()) != MOVE_NONE
|
||||
&& !thread_should_stop(threadID))
|
||||
{
|
||||
|
||||
// Null move search
|
||||
if (useNullMove)
|
||||
if (move == MOVE_NULL)
|
||||
{
|
||||
ss[ply].currentMove = MOVE_NULL;
|
||||
|
||||
|
@ -1326,47 +1367,9 @@ namespace {
|
|||
&& connected_moves(pos, ss[ply - 1].currentMove, ss[ply].threatMove))
|
||||
return beta - 1;
|
||||
}
|
||||
}
|
||||
// Null move search not allowed, try razoring
|
||||
if ( !useNullMove
|
||||
&& !value_is_mate(beta)
|
||||
&& depth < RazorDepth
|
||||
&& approximateEval < beta - RazorApprMargins[int(depth) - 2]
|
||||
&& ss[ply - 1].currentMove != MOVE_NULL
|
||||
&& ttMove == MOVE_NONE
|
||||
&& !pos.has_pawn_on_7th(pos.side_to_move()))
|
||||
{
|
||||
Value v = qsearch(pos, ss, beta-1, beta, Depth(0), ply, threadID);
|
||||
if (v < beta - RazorMargins[int(depth) - 2])
|
||||
return v;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Go with internal iterative deepening if we don't have a TT move
|
||||
if (UseIIDAtNonPVNodes && ttMove == MOVE_NONE && depth >= 8*OnePly &&
|
||||
evaluate(pos, ei, threadID) >= beta - IIDMargin)
|
||||
{
|
||||
search(pos, ss, beta, Min(depth/2, depth-2*OnePly), ply, false, threadID);
|
||||
ttMove = ss[ply].pv[ply];
|
||||
}
|
||||
|
||||
// Initialize a MovePicker object for the current position, and prepare
|
||||
// to search all moves.
|
||||
MovePicker mp = MovePicker(pos, ttMove, depth, H, &ss[ply]);
|
||||
|
||||
Move move, movesSearched[256];
|
||||
int moveCount = 0;
|
||||
Value value, bestValue = -VALUE_INFINITE;
|
||||
Bitboard dcCandidates = mp.discovered_check_candidates();
|
||||
Value futilityValue = VALUE_NONE;
|
||||
bool useFutilityPruning = depth < SelectiveDepth
|
||||
&& !isCheck;
|
||||
|
||||
// Loop through all legal moves until no moves remain or a beta cutoff
|
||||
// occurs.
|
||||
while ( bestValue < beta
|
||||
&& (move = mp.get_next_move()) != MOVE_NONE
|
||||
&& !thread_should_stop(threadID))
|
||||
{
|
||||
assert(move_is_ok(move));
|
||||
|
||||
bool singleReply = (isCheck && mp.number_of_moves() == 1);
|
||||
|
|
Loading…
Add table
Reference in a new issue