mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 08:43:09 +00:00
Synchronize search_pv() with search take I
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
9eedc0a463
commit
0980f43ab0
1 changed files with 26 additions and 23 deletions
|
@ -1052,37 +1052,50 @@ namespace {
|
||||||
if (depth < OnePly)
|
if (depth < OnePly)
|
||||||
return qsearch(pos, ss, alpha, beta, Depth(0), ply, threadID);
|
return qsearch(pos, ss, alpha, beta, Depth(0), ply, threadID);
|
||||||
|
|
||||||
// Initialize, and make an early exit in case of an aborted search,
|
// Step 1. Initialize node and poll
|
||||||
// an instant draw, maximum ply reached, etc.
|
// Polling can abort search.
|
||||||
init_node(ss, ply, threadID);
|
init_node(ss, ply, threadID);
|
||||||
|
|
||||||
// After init_node() that calls poll()
|
// Step 2. Check for aborted search and immediate draw
|
||||||
if (AbortSearch || TM.thread_should_stop(threadID))
|
if (AbortSearch || TM.thread_should_stop(threadID))
|
||||||
return Value(0);
|
return Value(0);
|
||||||
|
|
||||||
if (pos.is_draw() || ply >= PLY_MAX - 1)
|
if (pos.is_draw() || ply >= PLY_MAX - 1)
|
||||||
return VALUE_DRAW;
|
return VALUE_DRAW;
|
||||||
|
|
||||||
// Mate distance pruning
|
// Step 3. Mate distance pruning
|
||||||
oldAlpha = alpha;
|
oldAlpha = alpha;
|
||||||
alpha = Max(value_mated_in(ply), alpha);
|
alpha = Max(value_mated_in(ply), alpha);
|
||||||
beta = Min(value_mate_in(ply+1), beta);
|
beta = Min(value_mate_in(ply+1), beta);
|
||||||
if (alpha >= beta)
|
if (alpha >= beta)
|
||||||
return alpha;
|
return alpha;
|
||||||
|
|
||||||
// Transposition table lookup. At PV nodes, we don't use the TT for
|
// Step 4. Transposition table lookup
|
||||||
// pruning, but only for move ordering. This is to avoid problems in
|
// At PV nodes, we don't use the TT for pruning, but only for move ordering.
|
||||||
// the following areas:
|
// This is to avoid problems in the following areas:
|
||||||
//
|
//
|
||||||
// * Repetition draw detection
|
// * Repetition draw detection
|
||||||
// * Fifty move rule detection
|
// * Fifty move rule detection
|
||||||
// * Searching for a mate
|
// * Searching for a mate
|
||||||
// * Printing of full PV line
|
// * Printing of full PV line
|
||||||
//
|
|
||||||
tte = TT.retrieve(pos.get_key());
|
tte = TT.retrieve(pos.get_key());
|
||||||
ttMove = (tte ? tte->move() : MOVE_NONE);
|
ttMove = (tte ? tte->move() : MOVE_NONE);
|
||||||
|
|
||||||
// Go with internal iterative deepening if we don't have a TT move
|
// Step 5. Evaluate the position statically
|
||||||
|
// At PV nodes we do this only to update gain statistics
|
||||||
|
isCheck = pos.is_check();
|
||||||
|
if (!isCheck)
|
||||||
|
{
|
||||||
|
EvalInfo ei;
|
||||||
|
ss[ply].eval = evaluate(pos, ei, threadID);
|
||||||
|
update_gains(pos, ss[ply - 1].currentMove, ss[ply - 1].eval, ss[ply].eval);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step 6. Razoring (is omitted in PV nodes)
|
||||||
|
// Step 7. Static null move pruning (is omitted in PV nodes)
|
||||||
|
// Step 8. Null move search with verification search (is omitted in PV nodes)
|
||||||
|
|
||||||
|
// Step 9. Internal iterative deepening
|
||||||
if ( UseIIDAtPVNodes
|
if ( UseIIDAtPVNodes
|
||||||
&& depth >= 5*OnePly
|
&& depth >= 5*OnePly
|
||||||
&& ttMove == MOVE_NONE)
|
&& ttMove == MOVE_NONE)
|
||||||
|
@ -1092,24 +1105,14 @@ namespace {
|
||||||
tte = TT.retrieve(pos.get_key());
|
tte = TT.retrieve(pos.get_key());
|
||||||
}
|
}
|
||||||
|
|
||||||
isCheck = pos.is_check();
|
// Step 10. Loop through moves
|
||||||
if (!isCheck)
|
// Loop through all legal moves until no moves remain or a beta cutoff occurs
|
||||||
{
|
|
||||||
// Update gain statistics of the previous move that lead
|
|
||||||
// us in this position.
|
|
||||||
EvalInfo ei;
|
|
||||||
ss[ply].eval = evaluate(pos, ei, threadID);
|
|
||||||
update_gains(pos, ss[ply - 1].currentMove, ss[ply - 1].eval, ss[ply].eval);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize a MovePicker object for the current position, and prepare
|
// Initialize a MovePicker object for the current position
|
||||||
// to search all moves
|
|
||||||
mateThreat = pos.has_mate_threat(opposite_color(pos.side_to_move()));
|
mateThreat = pos.has_mate_threat(opposite_color(pos.side_to_move()));
|
||||||
CheckInfo ci(pos);
|
|
||||||
MovePicker mp = MovePicker(pos, ttMove, depth, H, &ss[ply]);
|
MovePicker mp = MovePicker(pos, ttMove, depth, H, &ss[ply]);
|
||||||
|
CheckInfo ci(pos);
|
||||||
|
|
||||||
// Loop through all legal moves until no moves remain or a beta cutoff
|
|
||||||
// occurs.
|
|
||||||
while ( alpha < beta
|
while ( alpha < beta
|
||||||
&& (move = mp.get_next_move()) != MOVE_NONE
|
&& (move = mp.get_next_move()) != MOVE_NONE
|
||||||
&& !TM.thread_should_stop(threadID))
|
&& !TM.thread_should_stop(threadID))
|
||||||
|
|
Loading…
Add table
Reference in a new issue