mirror of
https://github.com/sockspls/badfish
synced 2025-05-02 01:29:36 +00:00
Synchronize sp_search() with search() part I
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
c3b3dcc31a
commit
9d4abbc6eb
1 changed files with 19 additions and 17 deletions
|
@ -85,7 +85,7 @@ namespace {
|
||||||
void put_threads_to_sleep();
|
void put_threads_to_sleep();
|
||||||
void idle_loop(int threadID, SplitPoint* waitSp);
|
void idle_loop(int threadID, SplitPoint* waitSp);
|
||||||
bool split(const Position& pos, SearchStack* ss, int ply, Value* alpha, const Value beta, Value* bestValue,
|
bool split(const Position& pos, SearchStack* ss, int ply, Value* alpha, const Value beta, Value* bestValue,
|
||||||
const Value futilityValue, Depth depth, int* moves, MovePicker* mp, int master, bool pvNode);
|
Depth depth, int* moves, MovePicker* mp, int master, bool pvNode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend void poll();
|
friend void poll();
|
||||||
|
@ -1219,7 +1219,7 @@ namespace {
|
||||||
&& TM.available_thread_exists(threadID)
|
&& TM.available_thread_exists(threadID)
|
||||||
&& !AbortSearch
|
&& !AbortSearch
|
||||||
&& !TM.thread_should_stop(threadID)
|
&& !TM.thread_should_stop(threadID)
|
||||||
&& TM.split(pos, ss, ply, &alpha, beta, &bestValue, VALUE_NONE,
|
&& TM.split(pos, ss, ply, &alpha, beta, &bestValue,
|
||||||
depth, &moveCount, &mp, threadID, true))
|
depth, &moveCount, &mp, threadID, true))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1272,11 +1272,11 @@ namespace {
|
||||||
const TTEntry* tte;
|
const TTEntry* tte;
|
||||||
Move ttMove, move;
|
Move ttMove, move;
|
||||||
Depth ext, newDepth;
|
Depth ext, newDepth;
|
||||||
Value bestValue, refinedValue, nullValue, value, futilityValue, futilityValueScaled;
|
Value bestValue, refinedValue, nullValue, value, futilityValueScaled;
|
||||||
bool isCheck, singleEvasion, moveIsCheck, captureOrPromotion, dangerous;
|
bool isCheck, singleEvasion, moveIsCheck, captureOrPromotion, dangerous;
|
||||||
bool mateThreat = false;
|
bool mateThreat = false;
|
||||||
int moveCount = 0;
|
int moveCount = 0;
|
||||||
futilityValue = refinedValue = bestValue = value = -VALUE_INFINITE;
|
refinedValue = bestValue = value = -VALUE_INFINITE;
|
||||||
|
|
||||||
if (depth < OnePly)
|
if (depth < OnePly)
|
||||||
return qsearch(pos, ss, beta-1, beta, Depth(0), ply, threadID);
|
return qsearch(pos, ss, beta-1, beta, Depth(0), ply, threadID);
|
||||||
|
@ -1324,7 +1324,6 @@ namespace {
|
||||||
else
|
else
|
||||||
ss[ply].eval = evaluate(pos, ei, threadID);
|
ss[ply].eval = evaluate(pos, ei, threadID);
|
||||||
|
|
||||||
futilityValue = ss[ply].eval + futility_margin(depth, 0); //FIXME: Remove me, only for split
|
|
||||||
refinedValue = refine_eval(tte, ss[ply].eval, ply); // Enhance accuracy with TT value if possible
|
refinedValue = refine_eval(tte, ss[ply].eval, ply); // Enhance accuracy with TT value if possible
|
||||||
update_gains(pos, ss[ply - 1].currentMove, ss[ply - 1].eval, ss[ply].eval);
|
update_gains(pos, ss[ply - 1].currentMove, ss[ply - 1].eval, ss[ply].eval);
|
||||||
}
|
}
|
||||||
|
@ -1543,7 +1542,7 @@ namespace {
|
||||||
&& TM.available_thread_exists(threadID)
|
&& TM.available_thread_exists(threadID)
|
||||||
&& !AbortSearch
|
&& !AbortSearch
|
||||||
&& !TM.thread_should_stop(threadID)
|
&& !TM.thread_should_stop(threadID)
|
||||||
&& TM.split(pos, ss, ply, NULL, beta, &bestValue, futilityValue, //FIXME: SMP & futilityValue
|
&& TM.split(pos, ss, ply, NULL, beta, &bestValue,
|
||||||
depth, &moveCount, &mp, threadID, false))
|
depth, &moveCount, &mp, threadID, false))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1794,9 +1793,9 @@ namespace {
|
||||||
Move move;
|
Move move;
|
||||||
int moveCount;
|
int moveCount;
|
||||||
bool isCheck = pos.is_check();
|
bool isCheck = pos.is_check();
|
||||||
bool useFutilityPruning = sp->depth < 7 * OnePly //FIXME: sync with search
|
|
||||||
&& !isCheck;
|
|
||||||
|
|
||||||
|
// Step 10. Loop through moves
|
||||||
|
// Loop through all legal moves until no moves remain or a beta cutoff occurs
|
||||||
lock_grab(&(sp->lock));
|
lock_grab(&(sp->lock));
|
||||||
|
|
||||||
while ( sp->bestValue < sp->beta
|
while ( sp->bestValue < sp->beta
|
||||||
|
@ -1811,17 +1810,19 @@ namespace {
|
||||||
bool moveIsCheck = pos.move_is_check(move, ci);
|
bool moveIsCheck = pos.move_is_check(move, ci);
|
||||||
bool captureOrPromotion = pos.move_is_capture_or_promotion(move);
|
bool captureOrPromotion = pos.move_is_capture_or_promotion(move);
|
||||||
|
|
||||||
ss[sp->ply].currentMove = move;
|
// Step 11. Decide the new search depth
|
||||||
|
|
||||||
// Decide the new search depth
|
|
||||||
bool dangerous;
|
bool dangerous;
|
||||||
Depth ext = extension(pos, move, false, captureOrPromotion, moveIsCheck, false, false, &dangerous);
|
Depth ext = extension(pos, move, false, captureOrPromotion, moveIsCheck, false, false, &dangerous);
|
||||||
Depth newDepth = sp->depth - OnePly + ext;
|
Depth newDepth = sp->depth - OnePly + ext;
|
||||||
|
|
||||||
// Prune?
|
// Update current move
|
||||||
if ( useFutilityPruning
|
ss[sp->ply].currentMove = move;
|
||||||
|
|
||||||
|
// Step 12. Futility pruning
|
||||||
|
if ( !isCheck
|
||||||
&& !dangerous
|
&& !dangerous
|
||||||
&& !captureOrPromotion)
|
&& !captureOrPromotion
|
||||||
|
&& !move_is_castle(move))
|
||||||
{
|
{
|
||||||
// Move count based pruning
|
// Move count based pruning
|
||||||
if ( moveCount >= futility_move_count(sp->depth)
|
if ( moveCount >= futility_move_count(sp->depth)
|
||||||
|
@ -1833,7 +1834,9 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Value based pruning
|
// Value based pruning
|
||||||
Value futilityValueScaled = sp->futilityValue - moveCount * 8; //FIXME: sync with search
|
Depth predictedDepth = newDepth - nonpv_reduction(sp->depth, moveCount);
|
||||||
|
Value futilityValueScaled = ss[sp->ply].eval + futility_margin(predictedDepth, moveCount)
|
||||||
|
+ H.gain(pos.piece_on(move_from(move)), move_to(move)) + 45;
|
||||||
|
|
||||||
if (futilityValueScaled < sp->beta)
|
if (futilityValueScaled < sp->beta)
|
||||||
{
|
{
|
||||||
|
@ -2845,7 +2848,7 @@ namespace {
|
||||||
// splitPoint->cpus becomes 0), split() returns true.
|
// splitPoint->cpus becomes 0), split() returns true.
|
||||||
|
|
||||||
bool ThreadsManager::split(const Position& p, SearchStack* sstck, int ply,
|
bool ThreadsManager::split(const Position& p, SearchStack* sstck, int ply,
|
||||||
Value* alpha, const Value beta, Value* bestValue, const Value futilityValue,
|
Value* alpha, const Value beta, Value* bestValue,
|
||||||
Depth depth, int* moves, MovePicker* mp, int master, bool pvNode) {
|
Depth depth, int* moves, MovePicker* mp, int master, bool pvNode) {
|
||||||
|
|
||||||
assert(p.is_ok());
|
assert(p.is_ok());
|
||||||
|
@ -2885,7 +2888,6 @@ namespace {
|
||||||
splitPoint->beta = beta;
|
splitPoint->beta = beta;
|
||||||
splitPoint->pvNode = pvNode;
|
splitPoint->pvNode = pvNode;
|
||||||
splitPoint->bestValue = *bestValue;
|
splitPoint->bestValue = *bestValue;
|
||||||
splitPoint->futilityValue = futilityValue;
|
|
||||||
splitPoint->master = master;
|
splitPoint->master = master;
|
||||||
splitPoint->mp = mp;
|
splitPoint->mp = mp;
|
||||||
splitPoint->moves = *moves;
|
splitPoint->moves = *moves;
|
||||||
|
|
Loading…
Add table
Reference in a new issue