1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-29 16:23:09 +00:00

Space inflate sp_search

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2008-09-09 11:15:58 +02:00
parent a10c9632a5
commit eacb42092b

View file

@ -935,7 +935,7 @@ namespace {
else else
value = alpha + 1; // Just to trigger next condition value = alpha + 1; // Just to trigger next condition
if (value > alpha) // Go with full depth non-pv search if (value > alpha) // Go with full depth pv search
{ {
ss[ply].reduction = Depth(0); ss[ply].reduction = Depth(0);
value = -search(pos, ss, -alpha, newDepth, ply+1, true, threadID); value = -search(pos, ss, -alpha, newDepth, ply+1, true, threadID);
@ -1417,6 +1417,7 @@ namespace {
// care of after we return from the split point. // care of after we return from the split point.
void sp_search(SplitPoint *sp, int threadID) { void sp_search(SplitPoint *sp, int threadID) {
assert(threadID >= 0 && threadID < ActiveThreads); assert(threadID >= 0 && threadID < ActiveThreads);
assert(ActiveThreads > 1); assert(ActiveThreads > 1);
@ -1424,55 +1425,66 @@ namespace {
SearchStack *ss = sp->sstack[threadID]; SearchStack *ss = sp->sstack[threadID];
Value value; Value value;
Move move; Move move;
int moveCount = sp->moves;
bool isCheck = pos.is_check(); bool isCheck = pos.is_check();
bool useFutilityPruning = bool useFutilityPruning = UseFutilityPruning
UseFutilityPruning && sp->depth < SelectiveDepth && !isCheck; && sp->depth < SelectiveDepth
&& !isCheck;
while ( sp->bestValue < sp->beta
&& !thread_should_stop(threadID)
&& (move = sp->mp->get_next_move(sp->lock)) != MOVE_NONE)
{
assert(move_is_ok(move));
while(sp->bestValue < sp->beta && !thread_should_stop(threadID)
&& (move = sp->mp->get_next_move(sp->lock)) != MOVE_NONE) {
UndoInfo u;
Depth ext, newDepth;
bool moveIsCheck = pos.move_is_check(move, sp->dcCandidates); bool moveIsCheck = pos.move_is_check(move, sp->dcCandidates);
bool moveIsCapture = pos.move_is_capture(move); bool moveIsCapture = pos.move_is_capture(move);
bool moveIsPassedPawnPush = pos.move_is_passed_pawn_push(move); bool moveIsPassedPawnPush = pos.move_is_passed_pawn_push(move);
assert(move_is_ok(move));
lock_grab(&(sp->lock)); lock_grab(&(sp->lock));
sp->moves++; int moveCount = ++sp->moves;
moveCount = sp->moves;
lock_release(&(sp->lock)); lock_release(&(sp->lock));
ss[sp->ply].currentMove = move; ss[sp->ply].currentMove = move;
// Decide the new search depth. // Decide the new search depth.
ext = extension(pos, move, false, moveIsCheck, false, false); Depth ext = extension(pos, move, false, moveIsCheck, false, false);
newDepth = sp->depth - OnePly + ext; Depth newDepth = sp->depth - OnePly + ext;
// Prune? // Prune?
if(useFutilityPruning && ext == Depth(0) && !moveIsCapture if ( useFutilityPruning
&& !moveIsPassedPawnPush && !move_promotion(move) && ext == Depth(0)
&& !moveIsCapture
&& !moveIsPassedPawnPush
&& !move_promotion(move)
&& moveCount >= 2 + int(sp->depth) && moveCount >= 2 + int(sp->depth)
&& ok_to_prune(pos, move, ss[sp->ply].threatMove, sp->depth)) && ok_to_prune(pos, move, ss[sp->ply].threatMove, sp->depth))
continue; continue;
// Make and search the move. // Make and search the move.
UndoInfo u;
pos.do_move(move, u, sp->dcCandidates); pos.do_move(move, u, sp->dcCandidates);
if(ext == Depth(0) && moveCount >= LMRNonPVMoves
&& !moveIsCapture && !move_promotion(move) && !moveIsPassedPawnPush // Try to reduce non-pv search depth by one ply if move seems not problematic,
// if the move fails high will be re-searched at full depth.
if ( ext == Depth(0)
&& moveCount >= LMRNonPVMoves
&& !moveIsCapture
&& !moveIsPassedPawnPush
&& !move_promotion(move)
&& !move_is_castle(move) && !move_is_castle(move)
&& move != ss[sp->ply].killer1 && move != ss[sp->ply].killer2) { && move != ss[sp->ply].killer1
&& move != ss[sp->ply].killer2)
{
ss[sp->ply].reduction = OnePly; ss[sp->ply].reduction = OnePly;
value = -search(pos, ss, -(sp->beta-1), newDepth - OnePly, sp->ply+1, value = -search(pos, ss, -(sp->beta-1), newDepth - OnePly, sp->ply+1, true, threadID);
true, threadID);
} }
else else
value = sp->beta; value = sp->beta; // Just to trigger next condition
if(value >= sp->beta) {
if (value >= sp->beta) // Go with full depth non-pv search
{
ss[sp->ply].reduction = Depth(0); ss[sp->ply].reduction = Depth(0);
value = -search(pos, ss, -(sp->beta - 1), newDepth, sp->ply+1, true, value = -search(pos, ss, -(sp->beta - 1), newDepth, sp->ply+1, true, threadID);
threadID);
} }
pos.undo_move(move, u); pos.undo_move(move, u);
@ -1483,13 +1495,16 @@ namespace {
// New best move? // New best move?
lock_grab(&(sp->lock)); lock_grab(&(sp->lock));
if(value > sp->bestValue && !thread_should_stop(threadID)) { if (value > sp->bestValue && !thread_should_stop(threadID))
{
sp->bestValue = value; sp->bestValue = value;
if(sp->bestValue >= sp->beta) { if (sp->bestValue >= sp->beta)
{
sp_update_pv(sp->parentSstack, ss, sp->ply); sp_update_pv(sp->parentSstack, ss, sp->ply);
for (int i = 0; i < ActiveThreads; i++) for (int i = 0; i < ActiveThreads; i++)
if (i != threadID && (i == sp->master || sp->slaves[i])) if (i != threadID && (i == sp->master || sp->slaves[i]))
Threads[i].stop = true; Threads[i].stop = true;
sp->finished = true; sp->finished = true;
} }
} }