mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 16:53:09 +00:00
Use ply counter in Position object
And avoid a redundant one passed as argument in search calls. Also renamed gamePly in ply to better clarify this is used as search ply and is set to zero at the beginning of the search. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
ee8ccac622
commit
6716337f40
5 changed files with 54 additions and 52 deletions
|
@ -703,7 +703,7 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
|
||||||
// pointer to point to the new, ready to be updated, state.
|
// pointer to point to the new, ready to be updated, state.
|
||||||
struct ReducedStateInfo {
|
struct ReducedStateInfo {
|
||||||
Key pawnKey, materialKey;
|
Key pawnKey, materialKey;
|
||||||
int castleRights, rule50, gamePly, pliesFromNull;
|
int castleRights, rule50, ply, pliesFromNull;
|
||||||
Square epSquare;
|
Square epSquare;
|
||||||
Score value;
|
Score value;
|
||||||
Value npMaterial[2];
|
Value npMaterial[2];
|
||||||
|
@ -715,7 +715,7 @@ void Position::do_move(Move m, StateInfo& newSt, const CheckInfo& ci, bool moveI
|
||||||
|
|
||||||
// Save the current key to the history[] array, in order to be able to
|
// Save the current key to the history[] array, in order to be able to
|
||||||
// detect repetition draws.
|
// detect repetition draws.
|
||||||
history[st->gamePly++] = key;
|
history[st->ply++] = key;
|
||||||
|
|
||||||
// Update side to move
|
// Update side to move
|
||||||
key ^= zobSideToMove;
|
key ^= zobSideToMove;
|
||||||
|
@ -1243,7 +1243,7 @@ void Position::do_null_move(StateInfo& backupSt) {
|
||||||
|
|
||||||
// Save the current key to the history[] array, in order to be able to
|
// Save the current key to the history[] array, in order to be able to
|
||||||
// detect repetition draws.
|
// detect repetition draws.
|
||||||
history[st->gamePly++] = st->key;
|
history[st->ply++] = st->key;
|
||||||
|
|
||||||
// Update the necessary information
|
// Update the necessary information
|
||||||
if (st->epSquare != SQ_NONE)
|
if (st->epSquare != SQ_NONE)
|
||||||
|
@ -1278,7 +1278,7 @@ void Position::undo_null_move() {
|
||||||
// Update the necessary information
|
// Update the necessary information
|
||||||
sideToMove = opposite_color(sideToMove);
|
sideToMove = opposite_color(sideToMove);
|
||||||
st->rule50--;
|
st->rule50--;
|
||||||
st->gamePly--;
|
st->ply--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1481,15 +1481,15 @@ void Position::clear() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Position::reset_game_ply() simply sets gamePly to 0. It is used from the
|
/// Position::reset_ply() simply sets ply to 0. It is used from the
|
||||||
/// UCI interface code, whenever a non-reversible move is made in a
|
/// UCI interface code, whenever a non-reversible move is made in a
|
||||||
/// 'position fen <fen> moves m1 m2 ...' command. This makes it possible
|
/// 'position fen <fen> moves m1 m2 ...' command. This makes it possible
|
||||||
/// for the program to handle games of arbitrary length, as long as the GUI
|
/// for the program to handle games of arbitrary length, as long as the GUI
|
||||||
/// handles draws by the 50 move rule correctly.
|
/// handles draws by the 50 move rule correctly.
|
||||||
|
|
||||||
void Position::reset_game_ply() {
|
void Position::reset_ply() {
|
||||||
|
|
||||||
st->gamePly = 0;
|
st->ply = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1666,9 +1666,11 @@ bool Position::is_draw() const {
|
||||||
if (st->rule50 > 100 || (st->rule50 == 100 && !is_check()))
|
if (st->rule50 > 100 || (st->rule50 == 100 && !is_check()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
assert(st->ply >= st->rule50);
|
||||||
|
|
||||||
// Draw by repetition?
|
// Draw by repetition?
|
||||||
for (int i = 4, e = Min(Min(st->gamePly, st->rule50), st->pliesFromNull); i <= e; i += 2)
|
for (int i = 4, e = Min(st->rule50, st->pliesFromNull); i <= e; i += 2)
|
||||||
if (history[st->gamePly - i] == st->key)
|
if (history[st->ply - i] == st->key)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -100,7 +100,7 @@ enum Phase {
|
||||||
|
|
||||||
struct StateInfo {
|
struct StateInfo {
|
||||||
Key pawnKey, materialKey;
|
Key pawnKey, materialKey;
|
||||||
int castleRights, rule50, gamePly, pliesFromNull;
|
int castleRights, rule50, ply, pliesFromNull;
|
||||||
Square epSquare;
|
Square epSquare;
|
||||||
Score value;
|
Score value;
|
||||||
Value npMaterial[2];
|
Value npMaterial[2];
|
||||||
|
@ -273,7 +273,7 @@ public:
|
||||||
|
|
||||||
// Game ply information
|
// Game ply information
|
||||||
int ply() const;
|
int ply() const;
|
||||||
void reset_game_ply();
|
void reset_ply();
|
||||||
|
|
||||||
// Position consistency check, for debugging
|
// Position consistency check, for debugging
|
||||||
bool is_ok(int* failedStep = NULL) const;
|
bool is_ok(int* failedStep = NULL) const;
|
||||||
|
@ -558,7 +558,7 @@ inline PieceType Position::captured_piece() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int Position::ply() const {
|
inline int Position::ply() const {
|
||||||
return st->gamePly;
|
return st->ply;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // !defined(POSITION_H_INCLUDED)
|
#endif // !defined(POSITION_H_INCLUDED)
|
||||||
|
|
|
@ -89,7 +89,7 @@ namespace {
|
||||||
void idle_loop(int threadID, SplitPoint* sp);
|
void idle_loop(int threadID, SplitPoint* sp);
|
||||||
|
|
||||||
template <bool Fake>
|
template <bool Fake>
|
||||||
void split(const Position& pos, SearchStack* ss, int ply, Value* alpha, const Value beta, Value* bestValue,
|
void split(const Position& pos, SearchStack* ss, Value* alpha, const Value beta, Value* bestValue,
|
||||||
Depth depth, bool mateThreat, int* moveCount, MovePicker* mp, int master, bool pvNode);
|
Depth depth, bool mateThreat, int* moveCount, MovePicker* mp, int master, bool pvNode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -285,10 +285,10 @@ namespace {
|
||||||
Value root_search(Position& pos, SearchStack* ss, RootMoveList& rml, Value* alphaPtr, Value* betaPtr);
|
Value root_search(Position& pos, SearchStack* ss, RootMoveList& rml, Value* alphaPtr, Value* betaPtr);
|
||||||
|
|
||||||
template <NodeType PvNode>
|
template <NodeType PvNode>
|
||||||
Value search(Position& pos, SearchStack* ss, Value alpha, Value beta, Depth depth, int ply, bool allowNullmove, int threadID, Move excludedMove = MOVE_NONE);
|
Value search(Position& pos, SearchStack* ss, Value alpha, Value beta, Depth depth, bool allowNullmove, int threadID, Move excludedMove = MOVE_NONE);
|
||||||
|
|
||||||
template <NodeType PvNode>
|
template <NodeType PvNode>
|
||||||
Value qsearch(Position& pos, SearchStack* ss, Value alpha, Value beta, Depth depth, int ply, int threadID);
|
Value qsearch(Position& pos, SearchStack* ss, Value alpha, Value beta, Depth depth, int threadID);
|
||||||
|
|
||||||
template <NodeType PvNode>
|
template <NodeType PvNode>
|
||||||
void sp_search(SplitPoint* sp, int threadID);
|
void sp_search(SplitPoint* sp, int threadID);
|
||||||
|
@ -637,6 +637,7 @@ namespace {
|
||||||
H.clear();
|
H.clear();
|
||||||
init_ss_array(ss);
|
init_ss_array(ss);
|
||||||
ValueByIteration[1] = rml.get_move_score(0);
|
ValueByIteration[1] = rml.get_move_score(0);
|
||||||
|
p.reset_ply();
|
||||||
Iteration = 1;
|
Iteration = 1;
|
||||||
|
|
||||||
// Is one move significantly better than others after initial scoring ?
|
// Is one move significantly better than others after initial scoring ?
|
||||||
|
@ -877,7 +878,7 @@ namespace {
|
||||||
alpha = -VALUE_INFINITE;
|
alpha = -VALUE_INFINITE;
|
||||||
|
|
||||||
// Full depth PV search, done on first move or after a fail high
|
// Full depth PV search, done on first move or after a fail high
|
||||||
value = -search<PV>(pos, ss+1, -beta, -alpha, newDepth, 1, false, 0);
|
value = -search<PV>(pos, ss+1, -beta, -alpha, newDepth, false, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -894,7 +895,7 @@ namespace {
|
||||||
if (ss->reduction)
|
if (ss->reduction)
|
||||||
{
|
{
|
||||||
// Reduced depth non-pv search using alpha as upperbound
|
// Reduced depth non-pv search using alpha as upperbound
|
||||||
value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, newDepth-ss->reduction, 1, true, 0);
|
value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, newDepth-ss->reduction, true, 0);
|
||||||
doFullDepthSearch = (value > alpha);
|
doFullDepthSearch = (value > alpha);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -904,12 +905,12 @@ namespace {
|
||||||
{
|
{
|
||||||
// Full depth non-pv search using alpha as upperbound
|
// Full depth non-pv search using alpha as upperbound
|
||||||
ss->reduction = Depth(0);
|
ss->reduction = Depth(0);
|
||||||
value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, newDepth, 1, true, 0);
|
value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, newDepth, true, 0);
|
||||||
|
|
||||||
// If we are above alpha then research at same depth but as PV
|
// If we are above alpha then research at same depth but as PV
|
||||||
// to get a correct score or eventually a fail high above beta.
|
// to get a correct score or eventually a fail high above beta.
|
||||||
if (value > alpha)
|
if (value > alpha)
|
||||||
value = -search<PV>(pos, ss+1, -beta, -alpha, newDepth, 1, false, 0);
|
value = -search<PV>(pos, ss+1, -beta, -alpha, newDepth, false, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1033,12 +1034,12 @@ namespace {
|
||||||
|
|
||||||
template <NodeType PvNode>
|
template <NodeType PvNode>
|
||||||
Value search(Position& pos, SearchStack* ss, Value alpha, Value beta, Depth depth,
|
Value search(Position& pos, SearchStack* ss, Value alpha, Value beta, Depth depth,
|
||||||
int ply, bool allowNullmove, int threadID, Move excludedMove) {
|
bool allowNullmove, int threadID, Move excludedMove) {
|
||||||
|
|
||||||
assert(alpha >= -VALUE_INFINITE && alpha <= VALUE_INFINITE);
|
assert(alpha >= -VALUE_INFINITE && alpha <= VALUE_INFINITE);
|
||||||
assert(beta > alpha && beta <= VALUE_INFINITE);
|
assert(beta > alpha && beta <= VALUE_INFINITE);
|
||||||
assert(PvNode || alpha == beta - 1);
|
assert(PvNode || alpha == beta - 1);
|
||||||
assert(ply >= 0 && ply < PLY_MAX);
|
assert(pos.ply() > 0 && pos.ply() < PLY_MAX);
|
||||||
assert(threadID >= 0 && threadID < TM.active_threads());
|
assert(threadID >= 0 && threadID < TM.active_threads());
|
||||||
|
|
||||||
Move movesSearched[256];
|
Move movesSearched[256];
|
||||||
|
@ -1052,11 +1053,12 @@ namespace {
|
||||||
bool isCheck, singleEvasion, moveIsCheck, captureOrPromotion, dangerous;
|
bool isCheck, singleEvasion, moveIsCheck, captureOrPromotion, dangerous;
|
||||||
bool mateThreat = false;
|
bool mateThreat = false;
|
||||||
int moveCount = 0;
|
int moveCount = 0;
|
||||||
|
int ply = pos.ply();
|
||||||
refinedValue = bestValue = value = -VALUE_INFINITE;
|
refinedValue = bestValue = value = -VALUE_INFINITE;
|
||||||
oldAlpha = alpha;
|
oldAlpha = alpha;
|
||||||
|
|
||||||
if (depth < OnePly)
|
if (depth < OnePly)
|
||||||
return qsearch<PvNode>(pos, ss, alpha, beta, Depth(0), ply, threadID);
|
return qsearch<PvNode>(pos, ss, alpha, beta, Depth(0), threadID);
|
||||||
|
|
||||||
// Step 1. Initialize node and poll
|
// Step 1. Initialize node and poll
|
||||||
// Polling can abort search.
|
// Polling can abort search.
|
||||||
|
@ -1129,7 +1131,7 @@ namespace {
|
||||||
&& !pos.has_pawn_on_7th(pos.side_to_move()))
|
&& !pos.has_pawn_on_7th(pos.side_to_move()))
|
||||||
{
|
{
|
||||||
Value rbeta = beta - razor_margin(depth);
|
Value rbeta = beta - razor_margin(depth);
|
||||||
Value v = qsearch<NonPV>(pos, ss, rbeta-1, rbeta, Depth(0), ply, threadID);
|
Value v = qsearch<NonPV>(pos, ss, rbeta-1, rbeta, Depth(0), threadID);
|
||||||
if (v < rbeta)
|
if (v < rbeta)
|
||||||
// Logically we should return (v + razor_margin(depth)), but
|
// Logically we should return (v + razor_margin(depth)), but
|
||||||
// surprisingly this did slightly weaker in tests.
|
// surprisingly this did slightly weaker in tests.
|
||||||
|
@ -1171,7 +1173,7 @@ namespace {
|
||||||
|
|
||||||
pos.do_null_move(st);
|
pos.do_null_move(st);
|
||||||
|
|
||||||
nullValue = -search<NonPV>(pos, ss+1, -beta, -alpha, depth-R*OnePly, ply+1, false, threadID);
|
nullValue = -search<NonPV>(pos, ss+1, -beta, -alpha, depth-R*OnePly, false, threadID);
|
||||||
|
|
||||||
pos.undo_null_move();
|
pos.undo_null_move();
|
||||||
|
|
||||||
|
@ -1185,7 +1187,7 @@ namespace {
|
||||||
return nullValue;
|
return nullValue;
|
||||||
|
|
||||||
// Do zugzwang verification search
|
// Do zugzwang verification search
|
||||||
Value v = search<NonPV>(pos, ss, alpha, beta, depth-5*OnePly, ply, false, threadID);
|
Value v = search<NonPV>(pos, ss, alpha, beta, depth-5*OnePly, false, threadID);
|
||||||
if (v >= beta)
|
if (v >= beta)
|
||||||
return nullValue;
|
return nullValue;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1212,7 +1214,7 @@ namespace {
|
||||||
&& (PvNode || (!isCheck && ss->eval >= beta - IIDMargin)))
|
&& (PvNode || (!isCheck && ss->eval >= beta - IIDMargin)))
|
||||||
{
|
{
|
||||||
Depth d = (PvNode ? depth - 2 * OnePly : depth / 2);
|
Depth d = (PvNode ? depth - 2 * OnePly : depth / 2);
|
||||||
search<PvNode>(pos, ss, alpha, beta, d, ply, false, threadID);
|
search<PvNode>(pos, ss, alpha, beta, d, false, threadID);
|
||||||
ttMove = ss->pv[ply];
|
ttMove = ss->pv[ply];
|
||||||
tte = TT.retrieve(posKey);
|
tte = TT.retrieve(posKey);
|
||||||
}
|
}
|
||||||
|
@ -1259,7 +1261,7 @@ namespace {
|
||||||
if (abs(ttValue) < VALUE_KNOWN_WIN)
|
if (abs(ttValue) < VALUE_KNOWN_WIN)
|
||||||
{
|
{
|
||||||
Value b = ttValue - SingularExtensionMargin;
|
Value b = ttValue - SingularExtensionMargin;
|
||||||
Value v = search<NonPV>(pos, ss, b - 1, b, depth / 2, ply, false, threadID, move);
|
Value v = search<NonPV>(pos, ss, b - 1, b, depth / 2, false, threadID, move);
|
||||||
|
|
||||||
if (v < ttValue - SingularExtensionMargin)
|
if (v < ttValue - SingularExtensionMargin)
|
||||||
ext = OnePly;
|
ext = OnePly;
|
||||||
|
@ -1306,7 +1308,7 @@ namespace {
|
||||||
// Step extra. pv search (only in PV nodes)
|
// Step extra. pv search (only in PV nodes)
|
||||||
// The first move in list is the expected PV
|
// The first move in list is the expected PV
|
||||||
if (PvNode && moveCount == 1)
|
if (PvNode && moveCount == 1)
|
||||||
value = -search<PV>(pos, ss+1, -beta, -alpha, newDepth, ply+1, false, threadID);
|
value = -search<PV>(pos, ss+1, -beta, -alpha, newDepth, false, threadID);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Step 14. Reduced depth search
|
// Step 14. Reduced depth search
|
||||||
|
@ -1322,7 +1324,7 @@ namespace {
|
||||||
ss->reduction = reduction<PvNode>(depth, moveCount);
|
ss->reduction = reduction<PvNode>(depth, moveCount);
|
||||||
if (ss->reduction)
|
if (ss->reduction)
|
||||||
{
|
{
|
||||||
value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, newDepth-ss->reduction, ply+1, true, threadID);
|
value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, newDepth-ss->reduction, true, threadID);
|
||||||
doFullDepthSearch = (value > alpha);
|
doFullDepthSearch = (value > alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1332,7 +1334,7 @@ namespace {
|
||||||
if (doFullDepthSearch && ss->reduction > 2 * OnePly)
|
if (doFullDepthSearch && ss->reduction > 2 * OnePly)
|
||||||
{
|
{
|
||||||
ss->reduction = OnePly;
|
ss->reduction = OnePly;
|
||||||
value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, newDepth-ss->reduction, ply+1, true, threadID);
|
value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, newDepth-ss->reduction, true, threadID);
|
||||||
doFullDepthSearch = (value > alpha);
|
doFullDepthSearch = (value > alpha);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1341,13 +1343,13 @@ namespace {
|
||||||
if (doFullDepthSearch)
|
if (doFullDepthSearch)
|
||||||
{
|
{
|
||||||
ss->reduction = Depth(0);
|
ss->reduction = Depth(0);
|
||||||
value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, newDepth, ply+1, true, threadID);
|
value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, newDepth, true, threadID);
|
||||||
|
|
||||||
// Step extra. pv search (only in PV nodes)
|
// Step extra. pv search (only in PV nodes)
|
||||||
// Search only for possible new PV nodes, if instead value >= beta then
|
// Search only for possible new PV nodes, if instead value >= beta then
|
||||||
// parent node fails low with value <= alpha and tries another move.
|
// parent node fails low with value <= alpha and tries another move.
|
||||||
if (PvNode && value > alpha && value < beta)
|
if (PvNode && value > alpha && value < beta)
|
||||||
value = -search<PV>(pos, ss+1, -beta, -alpha, newDepth, ply+1, false, threadID);
|
value = -search<PV>(pos, ss+1, -beta, -alpha, newDepth, false, threadID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1380,7 +1382,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<FakeSplit>(pos, ss, ply, &alpha, beta, &bestValue, depth,
|
TM.split<FakeSplit>(pos, ss, &alpha, beta, &bestValue, depth,
|
||||||
mateThreat, &moveCount, &mp, threadID, PvNode);
|
mateThreat, &moveCount, &mp, threadID, PvNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1425,14 +1427,13 @@ namespace {
|
||||||
// less than OnePly).
|
// less than OnePly).
|
||||||
|
|
||||||
template <NodeType PvNode>
|
template <NodeType PvNode>
|
||||||
Value qsearch(Position& pos, SearchStack* ss, Value alpha, Value beta,
|
Value qsearch(Position& pos, SearchStack* ss, Value alpha, Value beta, Depth depth, int threadID) {
|
||||||
Depth depth, int ply, int threadID) {
|
|
||||||
|
|
||||||
assert(alpha >= -VALUE_INFINITE && alpha <= VALUE_INFINITE);
|
assert(alpha >= -VALUE_INFINITE && alpha <= VALUE_INFINITE);
|
||||||
assert(beta >= -VALUE_INFINITE && beta <= VALUE_INFINITE);
|
assert(beta >= -VALUE_INFINITE && beta <= VALUE_INFINITE);
|
||||||
assert(PvNode || alpha == beta - 1);
|
assert(PvNode || alpha == beta - 1);
|
||||||
assert(depth <= 0);
|
assert(depth <= 0);
|
||||||
assert(ply >= 0 && ply < PLY_MAX);
|
assert(pos.ply() > 0 && pos.ply() < PLY_MAX);
|
||||||
assert(threadID >= 0 && threadID < TM.active_threads());
|
assert(threadID >= 0 && threadID < TM.active_threads());
|
||||||
|
|
||||||
EvalInfo ei;
|
EvalInfo ei;
|
||||||
|
@ -1442,6 +1443,7 @@ namespace {
|
||||||
bool isCheck, enoughMaterial, moveIsCheck, evasionPrunable;
|
bool isCheck, enoughMaterial, moveIsCheck, evasionPrunable;
|
||||||
const TTEntry* tte = NULL;
|
const TTEntry* tte = NULL;
|
||||||
int moveCount = 0;
|
int moveCount = 0;
|
||||||
|
int ply = pos.ply();
|
||||||
Value oldAlpha = alpha;
|
Value oldAlpha = alpha;
|
||||||
|
|
||||||
// Initialize, and make an early exit in case of an aborted search,
|
// Initialize, and make an early exit in case of an aborted search,
|
||||||
|
@ -1563,7 +1565,7 @@ namespace {
|
||||||
|
|
||||||
// Make and search the move
|
// Make and search the move
|
||||||
pos.do_move(move, st, ci, moveIsCheck);
|
pos.do_move(move, st, ci, moveIsCheck);
|
||||||
value = -qsearch<PvNode>(pos, ss+1, -beta, -alpha, depth-OnePly, ply+1, threadID);
|
value = -qsearch<PvNode>(pos, ss+1, -beta, -alpha, depth-OnePly, threadID);
|
||||||
pos.undo_move(move);
|
pos.undo_move(move);
|
||||||
|
|
||||||
assert(value > -VALUE_INFINITE && value < VALUE_INFINITE);
|
assert(value > -VALUE_INFINITE && value < VALUE_INFINITE);
|
||||||
|
@ -1636,6 +1638,7 @@ namespace {
|
||||||
|
|
||||||
Position pos(*sp->pos);
|
Position pos(*sp->pos);
|
||||||
CheckInfo ci(pos);
|
CheckInfo ci(pos);
|
||||||
|
int ply = pos.ply();
|
||||||
SearchStack* ss = sp->sstack[threadID] + 1;
|
SearchStack* ss = sp->sstack[threadID] + 1;
|
||||||
isCheck = pos.is_check();
|
isCheck = pos.is_check();
|
||||||
|
|
||||||
|
@ -1709,7 +1712,7 @@ namespace {
|
||||||
if (ss->reduction)
|
if (ss->reduction)
|
||||||
{
|
{
|
||||||
Value localAlpha = sp->alpha;
|
Value localAlpha = sp->alpha;
|
||||||
value = -search<NonPV>(pos, ss+1, -(localAlpha+1), -localAlpha, newDepth-ss->reduction, sp->ply+1, true, threadID);
|
value = -search<NonPV>(pos, ss+1, -(localAlpha+1), -localAlpha, newDepth-ss->reduction, true, threadID);
|
||||||
doFullDepthSearch = (value > localAlpha);
|
doFullDepthSearch = (value > localAlpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1720,7 +1723,7 @@ namespace {
|
||||||
{
|
{
|
||||||
ss->reduction = OnePly;
|
ss->reduction = OnePly;
|
||||||
Value localAlpha = sp->alpha;
|
Value localAlpha = sp->alpha;
|
||||||
value = -search<NonPV>(pos, ss+1, -(localAlpha+1), -localAlpha, newDepth-ss->reduction, sp->ply+1, true, threadID);
|
value = -search<NonPV>(pos, ss+1, -(localAlpha+1), -localAlpha, newDepth-ss->reduction, true, threadID);
|
||||||
doFullDepthSearch = (value > localAlpha);
|
doFullDepthSearch = (value > localAlpha);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1730,10 +1733,10 @@ namespace {
|
||||||
{
|
{
|
||||||
ss->reduction = Depth(0);
|
ss->reduction = Depth(0);
|
||||||
Value localAlpha = sp->alpha;
|
Value localAlpha = sp->alpha;
|
||||||
value = -search<NonPV>(pos, ss+1, -(localAlpha+1), -localAlpha, newDepth, sp->ply+1, true, threadID);
|
value = -search<NonPV>(pos, ss+1, -(localAlpha+1), -localAlpha, newDepth, true, threadID);
|
||||||
|
|
||||||
if (PvNode && value > localAlpha && value < sp->beta)
|
if (PvNode && value > localAlpha && value < sp->beta)
|
||||||
value = -search<PV>(pos, ss+1, -sp->beta, -sp->alpha, newDepth, sp->ply+1, false, threadID);
|
value = -search<PV>(pos, ss+1, -sp->beta, -sp->alpha, newDepth, false, threadID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 16. Undo move
|
// Step 16. Undo move
|
||||||
|
@ -1756,7 +1759,7 @@ namespace {
|
||||||
if (PvNode && value < sp->beta) // This guarantees that always: sp->alpha < sp->beta
|
if (PvNode && value < sp->beta) // This guarantees that always: sp->alpha < sp->beta
|
||||||
sp->alpha = value;
|
sp->alpha = value;
|
||||||
|
|
||||||
sp_update_pv(sp->parentSstack, ss, sp->ply);
|
sp_update_pv(sp->parentSstack, ss, ply);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2622,11 +2625,10 @@ namespace {
|
||||||
// split() returns.
|
// split() returns.
|
||||||
|
|
||||||
template <bool Fake>
|
template <bool Fake>
|
||||||
void ThreadsManager::split(const Position& p, SearchStack* ss, int ply, Value* alpha,
|
void ThreadsManager::split(const Position& p, SearchStack* ss, Value* alpha, const Value beta,
|
||||||
const Value beta, Value* bestValue, Depth depth, bool mateThreat,
|
Value* bestValue, Depth depth, bool mateThreat, int* moveCount,
|
||||||
int* moveCount, MovePicker* mp, int master, bool pvNode) {
|
MovePicker* mp, int master, bool pvNode) {
|
||||||
assert(p.is_ok());
|
assert(p.is_ok());
|
||||||
assert(ply > 0 && ply < PLY_MAX);
|
|
||||||
assert(*bestValue >= -VALUE_INFINITE);
|
assert(*bestValue >= -VALUE_INFINITE);
|
||||||
assert(*bestValue <= *alpha);
|
assert(*bestValue <= *alpha);
|
||||||
assert(*alpha < beta);
|
assert(*alpha < beta);
|
||||||
|
@ -2652,7 +2654,6 @@ namespace {
|
||||||
// Initialize the split point object
|
// Initialize the split point object
|
||||||
splitPoint->parent = threads[master].splitPoint;
|
splitPoint->parent = threads[master].splitPoint;
|
||||||
splitPoint->stopRequest = false;
|
splitPoint->stopRequest = false;
|
||||||
splitPoint->ply = ply;
|
|
||||||
splitPoint->depth = depth;
|
splitPoint->depth = depth;
|
||||||
splitPoint->mateThreat = mateThreat;
|
splitPoint->mateThreat = mateThreat;
|
||||||
splitPoint->alpha = *alpha;
|
splitPoint->alpha = *alpha;
|
||||||
|
@ -2787,7 +2788,7 @@ namespace {
|
||||||
init_ss_array(ss);
|
init_ss_array(ss);
|
||||||
pos.do_move(cur->move, st);
|
pos.do_move(cur->move, st);
|
||||||
moves[count].move = cur->move;
|
moves[count].move = cur->move;
|
||||||
moves[count].score = -qsearch<PV>(pos, ss+1, -VALUE_INFINITE, VALUE_INFINITE, Depth(0), 1, 0);
|
moves[count].score = -qsearch<PV>(pos, ss+1, -VALUE_INFINITE, VALUE_INFINITE, Depth(0), 0);
|
||||||
moves[count].pv[0] = cur->move;
|
moves[count].pv[0] = cur->move;
|
||||||
moves[count].pv[1] = MOVE_NONE;
|
moves[count].pv[1] = MOVE_NONE;
|
||||||
pos.undo_move(cur->move);
|
pos.undo_move(cur->move);
|
||||||
|
|
|
@ -54,7 +54,6 @@ struct SplitPoint {
|
||||||
Depth depth;
|
Depth depth;
|
||||||
bool pvNode, mateThreat;
|
bool pvNode, mateThreat;
|
||||||
Value beta;
|
Value beta;
|
||||||
int ply;
|
|
||||||
SearchStack sstack[MAX_THREADS][PLY_MAX_PLUS_2];
|
SearchStack sstack[MAX_THREADS][PLY_MAX_PLUS_2];
|
||||||
|
|
||||||
// Const pointers to shared data
|
// Const pointers to shared data
|
||||||
|
|
|
@ -206,7 +206,7 @@ namespace {
|
||||||
move = move_from_string(RootPosition, token);
|
move = move_from_string(RootPosition, token);
|
||||||
RootPosition.do_move(move, st);
|
RootPosition.do_move(move, st);
|
||||||
if (RootPosition.rule_50_counter() == 0)
|
if (RootPosition.rule_50_counter() == 0)
|
||||||
RootPosition.reset_game_ply();
|
RootPosition.reset_ply();
|
||||||
}
|
}
|
||||||
// Our StateInfo st is about going out of scope so copy
|
// Our StateInfo st is about going out of scope so copy
|
||||||
// its content inside RootPosition before they disappear.
|
// its content inside RootPosition before they disappear.
|
||||||
|
|
Loading…
Add table
Reference in a new issue