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

Slightly change split() API

This function "returns" two values: bestValue and bestMove

Instead of returning one and passing as pointer the other
be consistent and pass as pointers both.

No functional change.
This commit is contained in:
Marco Costalba 2013-02-05 06:30:05 +01:00
parent 1a414cd9cb
commit bf706c4a4f
3 changed files with 14 additions and 16 deletions

View file

@ -1030,8 +1030,8 @@ split_point_start: // At split points actual search starts from here
{ {
assert(bestValue < beta); assert(bestValue < beta);
bestValue = thisThread->split<FakeSplit>(pos, ss, alpha, beta, bestValue, &bestMove, thisThread->split<FakeSplit>(pos, ss, alpha, beta, &bestValue, &bestMove,
depth, threatMove, moveCount, mp, NT); depth, threatMove, moveCount, &mp, NT);
if (bestValue >= beta) if (bestValue >= beta)
break; break;
} }

View file

@ -249,15 +249,14 @@ bool ThreadPool::slave_available(Thread* master) const {
// search() then split() returns. // search() then split() returns.
template <bool Fake> template <bool Fake>
Value Thread::split(Position& pos, Stack* ss, Value alpha, Value beta, void Thread::split(Position& pos, Stack* ss, Value alpha, Value beta, Value* bestValue,
Value bestValue, Move* bestMove, Depth depth, Move threatMove, Move* bestMove, Depth depth, Move threatMove, int moveCount,
int moveCount, MovePicker& mp, int nodeType) { MovePicker* movePicker, int nodeType) {
assert(pos.pos_is_ok()); assert(pos.pos_is_ok());
assert(bestValue <= alpha && alpha < beta && beta <= VALUE_INFINITE); assert(*bestValue <= alpha && alpha < beta && beta <= VALUE_INFINITE);
assert(bestValue > -VALUE_INFINITE); assert(*bestValue > -VALUE_INFINITE);
assert(depth >= Threads.minimumSplitDepth); assert(depth >= Threads.minimumSplitDepth);
assert(searching); assert(searching);
assert(splitPointsSize < MAX_SPLITPOINTS_PER_THREAD); assert(splitPointsSize < MAX_SPLITPOINTS_PER_THREAD);
@ -268,13 +267,13 @@ Value Thread::split(Position& pos, Stack* ss, Value alpha, Value beta,
sp.parentSplitPoint = activeSplitPoint; sp.parentSplitPoint = activeSplitPoint;
sp.slavesMask = 1ULL << idx; sp.slavesMask = 1ULL << idx;
sp.depth = depth; sp.depth = depth;
sp.bestValue = *bestValue;
sp.bestMove = *bestMove; sp.bestMove = *bestMove;
sp.threatMove = threatMove; sp.threatMove = threatMove;
sp.alpha = alpha; sp.alpha = alpha;
sp.beta = beta; sp.beta = beta;
sp.nodeType = nodeType; sp.nodeType = nodeType;
sp.bestValue = bestValue; sp.movePicker = movePicker;
sp.movePicker = &mp;
sp.moveCount = moveCount; sp.moveCount = moveCount;
sp.pos = &pos; sp.pos = &pos;
sp.nodes = 0; sp.nodes = 0;
@ -332,16 +331,15 @@ Value Thread::split(Position& pos, Stack* ss, Value alpha, Value beta,
activeSplitPoint = sp.parentSplitPoint; activeSplitPoint = sp.parentSplitPoint;
pos.set_nodes_searched(pos.nodes_searched() + sp.nodes); pos.set_nodes_searched(pos.nodes_searched() + sp.nodes);
*bestMove = sp.bestMove; *bestMove = sp.bestMove;
*bestValue = sp.bestValue;
sp.mutex.unlock(); sp.mutex.unlock();
Threads.mutex.unlock(); Threads.mutex.unlock();
return sp.bestValue;
} }
// Explicit template instantiations // Explicit template instantiations
template Value Thread::split<false>(Position&, Stack*, Value, Value, Value, Move*, Depth, Move, int, MovePicker&, int); template void Thread::split<false>(Position&, Stack*, Value, Value, Value*, Move*, Depth, Move, int, MovePicker*, int);
template Value Thread::split<true>(Position&, Stack*, Value, Value, Value, Move*, Depth, Move, int, MovePicker&, int); template void Thread::split< true>(Position&, Stack*, Value, Value, Value*, Move*, Depth, Move, int, MovePicker*, int);
// wait_for_think_finished() waits for main thread to go to sleep then returns // wait_for_think_finished() waits for main thread to go to sleep then returns

View file

@ -103,8 +103,8 @@ struct Thread {
void wait_for(volatile const bool& b); void wait_for(volatile const bool& b);
template <bool Fake> template <bool Fake>
Value split(Position& pos, Search::Stack* ss, Value alpha, Value beta, Value bestValue, Move* bestMove, void split(Position& pos, Search::Stack* ss, Value alpha, Value beta, Value* bestValue, Move* bestMove,
Depth depth, Move threatMove, int moveCount, MovePicker& mp, int nodeType); Depth depth, Move threatMove, int moveCount, MovePicker* movePicker, int nodeType);
SplitPoint splitPoints[MAX_SPLITPOINTS_PER_THREAD]; SplitPoint splitPoints[MAX_SPLITPOINTS_PER_THREAD];
Material::Table materialTable; Material::Table materialTable;