2008-08-31 23:59:13 -06:00
|
|
|
/*
|
2008-10-19 10:56:28 -06:00
|
|
|
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
|
|
|
Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
|
2015-01-10 03:43:28 -07:00
|
|
|
Copyright (C) 2008-2015 Marco Costalba, Joona Kiiski, Tord Romstad
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2008-10-19 10:56:28 -06:00
|
|
|
Stockfish is free software: you can redistribute it and/or modify
|
2008-08-31 23:59:13 -06:00
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
2008-09-03 15:33:49 -06:00
|
|
|
|
2008-10-19 10:56:28 -06:00
|
|
|
Stockfish is distributed in the hope that it will be useful,
|
2008-08-31 23:59:13 -06:00
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2008-09-03 15:33:49 -06:00
|
|
|
|
2008-08-31 23:59:13 -06:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2011-12-12 09:55:20 -07:00
|
|
|
#include <algorithm>
|
2008-08-31 23:59:13 -06:00
|
|
|
#include <cassert>
|
2010-01-19 03:48:22 -07:00
|
|
|
#include <cmath>
|
2014-12-30 02:31:50 -07:00
|
|
|
#include <cstring> // For std::memset
|
2011-12-25 01:04:28 -07:00
|
|
|
#include <iostream>
|
2008-08-31 23:59:13 -06:00
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
#include "evaluate.h"
|
2014-12-08 00:23:09 -07:00
|
|
|
#include "misc.h"
|
2009-06-11 07:11:08 -06:00
|
|
|
#include "movegen.h"
|
2008-08-31 23:59:13 -06:00
|
|
|
#include "movepick.h"
|
|
|
|
#include "search.h"
|
2010-07-11 10:23:50 -06:00
|
|
|
#include "timeman.h"
|
2008-08-31 23:59:13 -06:00
|
|
|
#include "thread.h"
|
|
|
|
#include "tt.h"
|
2014-10-26 00:09:19 -06:00
|
|
|
#include "uci.h"
|
2015-01-18 00:05:05 -07:00
|
|
|
#include "syzygy/tbprobe.h"
|
2014-11-25 16:45:28 -07:00
|
|
|
|
2011-11-26 04:07:35 -07:00
|
|
|
namespace Search {
|
|
|
|
|
|
|
|
volatile SignalsType Signals;
|
|
|
|
LimitsType Limits;
|
2012-08-27 06:39:59 -06:00
|
|
|
StateStackPtr SetupStates;
|
2014-11-30 04:14:14 -07:00
|
|
|
}
|
|
|
|
|
2015-01-18 00:05:05 -07:00
|
|
|
namespace Tablebases {
|
|
|
|
|
|
|
|
int Cardinality;
|
|
|
|
uint64_t Hits;
|
|
|
|
bool RootInTB;
|
|
|
|
bool UseRule50;
|
|
|
|
Depth ProbeDepth;
|
|
|
|
Value Score;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace TB = Tablebases;
|
|
|
|
|
2011-12-04 03:46:31 -07:00
|
|
|
using std::string;
|
2012-03-06 02:09:37 -07:00
|
|
|
using Eval::evaluate;
|
2011-12-04 03:46:31 -07:00
|
|
|
using namespace Search;
|
|
|
|
|
2008-08-31 23:59:13 -06:00
|
|
|
namespace {
|
|
|
|
|
2011-04-25 06:14:23 -06:00
|
|
|
// Different node types, used as template parameter
|
2014-05-04 05:11:32 -06:00
|
|
|
enum NodeType { Root, PV, NonPV };
|
2010-11-08 01:44:28 -07:00
|
|
|
|
2015-01-31 02:43:47 -07:00
|
|
|
// Razoring and futility margin based on depth
|
2015-10-20 20:46:06 -06:00
|
|
|
int razor_margin[4] = {483, 570, 603, 554};
|
Retire FORCE_INLINE
No speed regression on my machine (i7-3770k, gcc 4.9.1, linux 3.16):
stat test master diff
mean 2,482,415 2,474,987 7,906
stdev 4,603 5,644 2,497
speedup 0.32%
P(speedup>0) 100.0%
Fishtest 9+0.03:
ELO: 0.26 +-1.8 (95%) LOS: 61.2%
Total: 60000 W: 12437 L: 12392 D: 35171
No functional change.
Resolves #334
2015-04-15 14:21:45 -06:00
|
|
|
Value futility_margin(Depth d) { return Value(200 * d); }
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2015-01-31 02:43:47 -07:00
|
|
|
// Futility and reductions lookup tables, initialized at startup
|
|
|
|
int FutilityMoveCounts[2][16]; // [improving][depth]
|
|
|
|
Depth Reductions[2][2][64][64]; // [pv][improving][depth][moveNumber]
|
2010-02-25 09:27:27 -07:00
|
|
|
|
Retire FORCE_INLINE
No speed regression on my machine (i7-3770k, gcc 4.9.1, linux 3.16):
stat test master diff
mean 2,482,415 2,474,987 7,906
stdev 4,603 5,644 2,497
speedup 0.32%
P(speedup>0) 100.0%
Fishtest 9+0.03:
ELO: 0.26 +-1.8 (95%) LOS: 61.2%
Total: 60000 W: 12437 L: 12392 D: 35171
No functional change.
Resolves #334
2015-04-15 14:21:45 -06:00
|
|
|
template <bool PvNode> Depth reduction(bool i, Depth d, int mn) {
|
2015-01-31 02:43:47 -07:00
|
|
|
return Reductions[PvNode][i][std::min(d, 63 * ONE_PLY)][std::min(mn, 63)];
|
2011-04-24 01:31:47 -06:00
|
|
|
}
|
|
|
|
|
2015-01-31 02:43:47 -07:00
|
|
|
// Skill struct is used to implement strength limiting
|
|
|
|
struct Skill {
|
|
|
|
Skill(int l) : level(l) {}
|
|
|
|
bool enabled() const { return level < 20; }
|
|
|
|
bool time_to_pick(Depth depth) const { return depth / ONE_PLY == 1 + level; }
|
|
|
|
Move best_move(size_t multiPV) { return best ? best : pick_best(multiPV); }
|
|
|
|
Move pick_best(size_t multiPV);
|
2010-02-07 01:53:15 -07:00
|
|
|
|
2015-01-31 02:43:47 -07:00
|
|
|
int level;
|
|
|
|
Move best = MOVE_NONE;
|
|
|
|
};
|
2010-02-07 01:53:15 -07:00
|
|
|
|
2015-03-18 01:12:59 -06:00
|
|
|
// EasyMoveManager struct is used to detect a so called 'easy move'; when PV is
|
|
|
|
// stable across multiple search iterations we can fast return the best move.
|
|
|
|
struct EasyMoveManager {
|
2015-03-12 13:49:30 -06:00
|
|
|
|
2015-03-18 01:12:59 -06:00
|
|
|
void clear() {
|
2015-03-12 13:49:30 -06:00
|
|
|
stableCnt = 0;
|
2015-03-18 01:12:59 -06:00
|
|
|
expectedPosKey = 0;
|
|
|
|
pv[0] = pv[1] = pv[2] = MOVE_NONE;
|
2015-03-12 13:49:30 -06:00
|
|
|
}
|
|
|
|
|
2015-03-18 01:12:59 -06:00
|
|
|
Move get(Key key) const {
|
|
|
|
return expectedPosKey == key ? pv[2] : MOVE_NONE;
|
|
|
|
}
|
2015-03-12 13:49:30 -06:00
|
|
|
|
2015-03-18 01:12:59 -06:00
|
|
|
void update(Position& pos, const std::vector<Move>& newPv) {
|
|
|
|
|
|
|
|
assert(newPv.size() >= 3);
|
|
|
|
|
|
|
|
// Keep track of how many times in a row 3rd ply remains stable
|
|
|
|
stableCnt = (newPv[2] == pv[2]) ? stableCnt + 1 : 0;
|
|
|
|
|
|
|
|
if (!std::equal(newPv.begin(), newPv.begin() + 3, pv))
|
|
|
|
{
|
|
|
|
std::copy(newPv.begin(), newPv.begin() + 3, pv);
|
|
|
|
|
|
|
|
StateInfo st[2];
|
|
|
|
pos.do_move(newPv[0], st[0], pos.gives_check(newPv[0], CheckInfo(pos)));
|
|
|
|
pos.do_move(newPv[1], st[1], pos.gives_check(newPv[1], CheckInfo(pos)));
|
|
|
|
expectedPosKey = pos.key();
|
|
|
|
pos.undo_move(newPv[1]);
|
|
|
|
pos.undo_move(newPv[0]);
|
2015-03-12 13:49:30 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int stableCnt;
|
2015-03-18 01:12:59 -06:00
|
|
|
Key expectedPosKey;
|
|
|
|
Move pv[3];
|
|
|
|
};
|
2015-03-12 13:49:30 -06:00
|
|
|
|
2015-03-18 01:12:59 -06:00
|
|
|
EasyMoveManager EasyMove;
|
2013-10-02 22:05:58 -06:00
|
|
|
double BestMoveChanges;
|
2012-10-21 02:41:23 -06:00
|
|
|
Value DrawValue[COLOR_NB];
|
2015-03-12 01:29:57 -06:00
|
|
|
CounterMovesHistoryStats CounterMovesHistory;
|
2009-07-01 18:54:17 -06:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
template <NodeType NT>
|
2013-06-09 01:43:04 -06:00
|
|
|
Value search(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth, bool cutNode);
|
2010-05-08 02:54:51 -06:00
|
|
|
|
2012-11-01 07:49:54 -06:00
|
|
|
template <NodeType NT, bool InCheck>
|
2011-12-04 03:46:31 -07:00
|
|
|
Value qsearch(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth);
|
2010-10-16 03:01:45 -06:00
|
|
|
|
2010-07-15 03:00:20 -06:00
|
|
|
Value value_to_tt(Value v, int ply);
|
|
|
|
Value value_from_tt(Value v, int ply);
|
2014-11-21 01:10:52 -07:00
|
|
|
void update_pv(Move* pv, Move move, Move* childPv);
|
2014-05-08 14:18:19 -06:00
|
|
|
void update_stats(const Position& pos, Stack* ss, Move move, Depth depth, Move* quiets, int quietsCnt);
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2011-01-16 15:40:06 -07:00
|
|
|
} // namespace
|
2008-08-31 23:59:13 -06:00
|
|
|
|
|
|
|
|
2011-12-14 04:12:28 -07:00
|
|
|
/// Search::init() is called during startup to initialize various lookup tables
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2011-11-26 04:07:35 -07:00
|
|
|
void Search::init() {
|
2010-06-01 14:28:45 -06:00
|
|
|
|
2015-10-20 20:46:06 -06:00
|
|
|
const double K[][2] = {{ 0.799, 2.281 }, { 0.484, 3.023 }};
|
2014-09-30 01:05:20 -06:00
|
|
|
|
2015-01-31 02:43:47 -07:00
|
|
|
for (int pv = 0; pv <= 1; ++pv)
|
|
|
|
for (int imp = 0; imp <= 1; ++imp)
|
|
|
|
for (int d = 1; d < 64; ++d)
|
|
|
|
for (int mc = 1; mc < 64; ++mc)
|
|
|
|
{
|
|
|
|
double r = K[pv][0] + log(d) * log(mc) / K[pv][1];
|
2013-08-08 02:28:48 -06:00
|
|
|
|
2015-01-31 02:43:47 -07:00
|
|
|
if (r >= 1.5)
|
|
|
|
Reductions[pv][imp][d][mc] = int(r) * ONE_PLY;
|
2013-08-08 02:28:48 -06:00
|
|
|
|
2015-01-31 02:43:47 -07:00
|
|
|
// Increase reduction when eval is not improving
|
|
|
|
if (!pv && !imp && Reductions[pv][imp][d][mc] >= 2 * ONE_PLY)
|
|
|
|
Reductions[pv][imp][d][mc] += ONE_PLY;
|
|
|
|
}
|
2010-06-01 14:28:45 -06:00
|
|
|
|
2014-11-08 17:45:27 -07:00
|
|
|
for (int d = 0; d < 16; ++d)
|
Increase pruning if evaluation is not improving
Add an additional set of margins to movecount pruning
to be used when static evaluation is getting worse
than previous move.
Here are the margins table with changing
depth (fm0 not improving, fm1 improving):
d: 0, fm0: 3, fm1: 3
d: 1, fm0: 4, fm1: 4
d: 2, fm0: 6, fm1: 6
d: 3, fm0: 7, fm1: 10
d: 4, fm0: 11, fm1: 15
d: 5, fm0: 15, fm1: 21
d: 6, fm0: 21, fm1: 29
d: 7, fm0: 27, fm1: 37
d: 8, fm0: 35, fm1: 47
d: 9, fm0: 42, fm1: 57
d: 10, fm0: 51, fm1: 68
d: 11, fm0: 60, fm1: 81
d: 12, fm0: 70, fm1: 94
d: 13, fm0: 81, fm1: 108
d: 14, fm0: 92, fm1: 123
d: 15, fm0: 104, fm1: 139
Good at both short TC
LLR: 2.97 (-2.94,2.94)
Total: 11502 W: 2503 L: 2361 D: 6638
And long TC
LLR: 2.98 (-2.94,2.94)
Total: 7189 W: 1421 L: 1277 D: 4491
bench: 4364793
2013-07-28 17:16:25 -06:00
|
|
|
{
|
2014-10-05 05:49:18 -06:00
|
|
|
FutilityMoveCounts[0][d] = int(2.4 + 0.773 * pow(d + 0.00, 1.8));
|
|
|
|
FutilityMoveCounts[1][d] = int(2.9 + 1.045 * pow(d + 0.49, 1.8));
|
Increase pruning if evaluation is not improving
Add an additional set of margins to movecount pruning
to be used when static evaluation is getting worse
than previous move.
Here are the margins table with changing
depth (fm0 not improving, fm1 improving):
d: 0, fm0: 3, fm1: 3
d: 1, fm0: 4, fm1: 4
d: 2, fm0: 6, fm1: 6
d: 3, fm0: 7, fm1: 10
d: 4, fm0: 11, fm1: 15
d: 5, fm0: 15, fm1: 21
d: 6, fm0: 21, fm1: 29
d: 7, fm0: 27, fm1: 37
d: 8, fm0: 35, fm1: 47
d: 9, fm0: 42, fm1: 57
d: 10, fm0: 51, fm1: 68
d: 11, fm0: 60, fm1: 81
d: 12, fm0: 70, fm1: 94
d: 13, fm0: 81, fm1: 108
d: 14, fm0: 92, fm1: 123
d: 15, fm0: 104, fm1: 139
Good at both short TC
LLR: 2.97 (-2.94,2.94)
Total: 11502 W: 2503 L: 2361 D: 6638
And long TC
LLR: 2.98 (-2.94,2.94)
Total: 7189 W: 1421 L: 1277 D: 4491
bench: 4364793
2013-07-28 17:16:25 -06:00
|
|
|
}
|
2010-06-01 14:28:45 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-09 03:09:06 -06:00
|
|
|
/// Search::reset() clears all search memory, to obtain reproducible search results
|
2015-05-06 05:24:00 -06:00
|
|
|
|
|
|
|
void Search::reset () {
|
|
|
|
|
2015-05-09 03:09:06 -06:00
|
|
|
TT.clear();
|
|
|
|
CounterMovesHistory.clear();
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
|
|
|
|
for (Thread* th : Threads)
|
|
|
|
{
|
|
|
|
th->History.clear();
|
|
|
|
th->Countermoves.clear();
|
|
|
|
}
|
2015-05-06 05:24:00 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-14 04:12:28 -07:00
|
|
|
/// Search::perft() is our utility to verify move generation. All the leaf nodes
|
|
|
|
/// up to the given depth are generated and counted and the sum returned.
|
2014-08-08 02:59:28 -06:00
|
|
|
template<bool Root>
|
|
|
|
uint64_t Search::perft(Position& pos, Depth depth) {
|
2009-11-04 03:11:04 -07:00
|
|
|
|
2012-08-19 03:20:15 -06:00
|
|
|
StateInfo st;
|
2014-08-08 02:59:28 -06:00
|
|
|
uint64_t cnt, nodes = 0;
|
2011-04-03 02:19:08 -06:00
|
|
|
CheckInfo ci(pos);
|
2014-09-29 06:08:56 -06:00
|
|
|
const bool leaf = (depth == 2 * ONE_PLY);
|
2012-08-19 03:20:15 -06:00
|
|
|
|
2015-01-31 10:39:51 -07:00
|
|
|
for (const auto& m : MoveList<LEGAL>(pos))
|
2011-04-03 02:19:08 -06:00
|
|
|
{
|
2014-08-08 02:59:28 -06:00
|
|
|
if (Root && depth <= ONE_PLY)
|
2014-08-09 03:33:02 -06:00
|
|
|
cnt = 1, nodes++;
|
2014-08-08 02:59:28 -06:00
|
|
|
else
|
|
|
|
{
|
Compute checkers from scratch
This micro-optimization only complicates the code and provides no benefit.
Removing it is even a speedup on my machine (i7-3770k, linux, gcc 4.9.1):
stat test master diff
mean 2,403,118 2,390,904 12,214
stdev 12,043 10,620 3,677
speedup 0.51%
P(speedup>0) 100.0%
No functional change.
2015-02-15 00:49:20 -07:00
|
|
|
pos.do_move(m, st, pos.gives_check(m, ci));
|
2014-08-08 02:59:28 -06:00
|
|
|
cnt = leaf ? MoveList<LEGAL>(pos).size() : perft<false>(pos, depth - ONE_PLY);
|
|
|
|
nodes += cnt;
|
2015-01-31 10:39:51 -07:00
|
|
|
pos.undo_move(m);
|
2014-08-08 02:59:28 -06:00
|
|
|
}
|
|
|
|
if (Root)
|
2015-01-31 10:39:51 -07:00
|
|
|
sync_cout << UCI::move(m, pos.is_chess960()) << ": " << cnt << sync_endl;
|
2011-04-03 02:19:08 -06:00
|
|
|
}
|
2014-08-08 02:59:28 -06:00
|
|
|
return nodes;
|
2009-10-01 22:09:24 -06:00
|
|
|
}
|
|
|
|
|
2014-08-08 02:59:28 -06:00
|
|
|
template uint64_t Search::perft<true>(Position& pos, Depth depth);
|
|
|
|
|
2009-10-01 22:09:24 -06:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
/// MainThread::think() is called by the main thread when the program receives
|
|
|
|
/// the UCI 'go' command. It searches from root position and at the end prints
|
|
|
|
/// the "bestmove" to output.
|
2008-08-31 23:59:13 -06:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
void MainThread::think() {
|
2008-08-31 23:59:13 -06:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
Color us = rootPos.side_to_move();
|
|
|
|
Time.init(Limits, us, rootPos.game_ply());
|
2011-11-06 05:13:54 -07:00
|
|
|
|
2014-12-07 16:53:33 -07:00
|
|
|
int contempt = Options["Contempt"] * PawnValueEg / 100; // From centipawns
|
Add support for playing in 'nodes as time' mode
When running more games in parallel, or simply when running a game
with a background process, due to how OS scheduling works, there is no
guarantee that the CPU resources allocated evenly between the two
players. This introduces noise in the result that leads to unreliable
result and in the worst cases can even invalidate the result. For
instance in SF test framework we avoid running from clouds virtual
machines because are a known source of very unstable CPU speed.
To overcome this issue, without requiring changes to the GUI, the idea
is to use searched nodes instead of time, and to convert time to
available nodes upfront, at the beginning of the game.
When nodestime UCI option is set at a given nodes per milliseconds
(npmsec), at the beginning of the game (and only once), the engine
reads the available time to think, sent by the GUI with 'go wtime x'
UCI command. Then it translates time in available nodes (nodes =
npmsec * x), then feeds available nodes instead of time to the time
management logic and starts the search. During the search the engine
checks the searched nodes against the available ones in such a way
that all the time management logic still fully applies, and the game
mimics a real one played on real time. When the search finishes,
before returning best move, the total available nodes are updated,
subtracting the real searched nodes. After the first move, the time
information sent by the GUI is ignored, and the engine fully relies on
the updated total available nodes to feed time management.
To avoid time losses, the speed of the engine (npms) must be set to a
value lower than real speed so that if the real TC is for instance 30
secs, and npms is half of the real speed, the game will last on
average 15 secs, so much less than the TC limit, providing for a
safety 'time buffer'.
There are 2 main limitations with this mode.
1. Engine speed should be the same for both players, and this limits
the approach to mainly parameter tuning patches.
2. Because npms is fixed while, in real engines, the speed increases
toward endgame, this introduces an artifact that is equivalent to an
altered time management. Namely it is like the time management gives
less available time than what should be in standard case.
May be the second limitation could be mitigated in a future with a
smarter 'dynamic npms' approach.
Tests shows that the standard deviation of the results with 'nodestime'
is lower than in standard TC, as is expected because now all the introduced
noise due the random speed variability of the engines during the game is
fully removed.
Original NIT idea by Michael Hoffman that shows how to play in NIT mode
without requiring changes to the GUI. This implementation goes a bit
further, the key difference is that we read TC from GUI only once upfront
instead of re-reading after every move as in Michael's implementation.
No functional change.
2015-03-22 14:15:44 -06:00
|
|
|
DrawValue[ us] = VALUE_DRAW - Value(contempt);
|
|
|
|
DrawValue[~us] = VALUE_DRAW + Value(contempt);
|
2014-03-01 04:10:42 -07:00
|
|
|
|
2015-01-18 00:05:05 -07:00
|
|
|
TB::Hits = 0;
|
|
|
|
TB::RootInTB = false;
|
|
|
|
TB::UseRule50 = Options["Syzygy50MoveRule"];
|
|
|
|
TB::ProbeDepth = Options["SyzygyProbeDepth"] * ONE_PLY;
|
|
|
|
TB::Cardinality = Options["SyzygyProbeLimit"];
|
|
|
|
|
|
|
|
// Skip TB probing when no TB found: !TBLargest -> !TB::Cardinality
|
|
|
|
if (TB::Cardinality > TB::MaxCardinality)
|
|
|
|
{
|
|
|
|
TB::Cardinality = TB::MaxCardinality;
|
|
|
|
TB::ProbeDepth = DEPTH_ZERO;
|
|
|
|
}
|
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
if (rootMoves.empty())
|
2008-10-30 04:35:44 -06:00
|
|
|
{
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
rootMoves.push_back(RootMove(MOVE_NONE));
|
2012-08-29 05:28:59 -06:00
|
|
|
sync_cout << "info depth 0 score "
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
<< UCI::value(rootPos.checkers() ? -VALUE_MATE : VALUE_DRAW)
|
2012-10-24 06:37:52 -06:00
|
|
|
<< sync_endl;
|
2012-01-14 03:45:54 -07:00
|
|
|
}
|
2014-11-10 06:46:05 -07:00
|
|
|
else
|
|
|
|
{
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
if (TB::Cardinality >= rootPos.count<ALL_PIECES>(WHITE)
|
|
|
|
+ rootPos.count<ALL_PIECES>(BLACK))
|
2015-01-18 00:05:05 -07:00
|
|
|
{
|
|
|
|
// If the current root position is in the tablebases then RootMoves
|
|
|
|
// contains only moves that preserve the draw or win.
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
TB::RootInTB = Tablebases::root_probe(rootPos, rootMoves, TB::Score);
|
2015-01-18 00:05:05 -07:00
|
|
|
|
|
|
|
if (TB::RootInTB)
|
|
|
|
TB::Cardinality = 0; // Do not probe tablebases during the search
|
|
|
|
|
|
|
|
else // If DTZ tables are missing, use WDL tables as a fallback
|
|
|
|
{
|
|
|
|
// Filter out moves that do not preserve a draw or win
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
TB::RootInTB = Tablebases::root_probe_wdl(rootPos, rootMoves, TB::Score);
|
2015-01-18 00:05:05 -07:00
|
|
|
|
|
|
|
// Only probe during search if winning
|
|
|
|
if (TB::Score <= VALUE_DRAW)
|
|
|
|
TB::Cardinality = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TB::RootInTB)
|
|
|
|
{
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
TB::Hits = rootMoves.size();
|
2015-01-18 00:05:05 -07:00
|
|
|
|
|
|
|
if (!TB::UseRule50)
|
|
|
|
TB::Score = TB::Score > VALUE_DRAW ? VALUE_MATE - MAX_PLY - 1
|
|
|
|
: TB::Score < VALUE_DRAW ? -VALUE_MATE + MAX_PLY + 1
|
|
|
|
: VALUE_DRAW;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-18 00:00:50 -07:00
|
|
|
for (Thread* th : Threads)
|
2015-03-18 01:01:50 -06:00
|
|
|
{
|
2015-01-18 00:00:50 -07:00
|
|
|
th->maxPly = 0;
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
th->depth = DEPTH_ZERO;
|
|
|
|
th->searching = true;
|
|
|
|
if (th != this)
|
|
|
|
{
|
|
|
|
th->rootPos = Position(rootPos, th);
|
|
|
|
th->rootMoves = rootMoves;
|
|
|
|
th->notify_one(); // Wake up the thread and start searching
|
|
|
|
}
|
2015-03-18 01:01:50 -06:00
|
|
|
}
|
2012-01-14 03:45:54 -07:00
|
|
|
|
2014-11-10 06:46:05 -07:00
|
|
|
Threads.timer->run = true;
|
2015-03-18 01:01:50 -06:00
|
|
|
Threads.timer->notify_one(); // Start the recurring timer
|
2011-11-06 05:13:54 -07:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
search(true); // Let's start searching!
|
2011-12-14 23:25:45 -07:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
// Stop the threads and the timer
|
|
|
|
Signals.stop = true;
|
2014-11-10 06:46:05 -07:00
|
|
|
Threads.timer->run = false;
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
|
|
|
|
// Wait until all threads have finished
|
|
|
|
for (Thread* th : Threads)
|
|
|
|
if (th != this)
|
|
|
|
th->wait_while(th->searching);
|
2014-11-10 06:46:05 -07:00
|
|
|
}
|
2013-05-03 02:25:25 -06:00
|
|
|
|
Add support for playing in 'nodes as time' mode
When running more games in parallel, or simply when running a game
with a background process, due to how OS scheduling works, there is no
guarantee that the CPU resources allocated evenly between the two
players. This introduces noise in the result that leads to unreliable
result and in the worst cases can even invalidate the result. For
instance in SF test framework we avoid running from clouds virtual
machines because are a known source of very unstable CPU speed.
To overcome this issue, without requiring changes to the GUI, the idea
is to use searched nodes instead of time, and to convert time to
available nodes upfront, at the beginning of the game.
When nodestime UCI option is set at a given nodes per milliseconds
(npmsec), at the beginning of the game (and only once), the engine
reads the available time to think, sent by the GUI with 'go wtime x'
UCI command. Then it translates time in available nodes (nodes =
npmsec * x), then feeds available nodes instead of time to the time
management logic and starts the search. During the search the engine
checks the searched nodes against the available ones in such a way
that all the time management logic still fully applies, and the game
mimics a real one played on real time. When the search finishes,
before returning best move, the total available nodes are updated,
subtracting the real searched nodes. After the first move, the time
information sent by the GUI is ignored, and the engine fully relies on
the updated total available nodes to feed time management.
To avoid time losses, the speed of the engine (npms) must be set to a
value lower than real speed so that if the real TC is for instance 30
secs, and npms is half of the real speed, the game will last on
average 15 secs, so much less than the TC limit, providing for a
safety 'time buffer'.
There are 2 main limitations with this mode.
1. Engine speed should be the same for both players, and this limits
the approach to mainly parameter tuning patches.
2. Because npms is fixed while, in real engines, the speed increases
toward endgame, this introduces an artifact that is equivalent to an
altered time management. Namely it is like the time management gives
less available time than what should be in standard case.
May be the second limitation could be mitigated in a future with a
smarter 'dynamic npms' approach.
Tests shows that the standard deviation of the results with 'nodestime'
is lower than in standard TC, as is expected because now all the introduced
noise due the random speed variability of the engines during the game is
fully removed.
Original NIT idea by Michael Hoffman that shows how to play in NIT mode
without requiring changes to the GUI. This implementation goes a bit
further, the key difference is that we read TC from GUI only once upfront
instead of re-reading after every move as in Michael's implementation.
No functional change.
2015-03-22 14:15:44 -06:00
|
|
|
// When playing in 'nodes as time' mode, subtract the searched nodes from
|
|
|
|
// the available ones before to exit.
|
|
|
|
if (Limits.npmsec)
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
Time.availableNodes += Limits.inc[us] - Threads.nodes_searched();
|
Add support for playing in 'nodes as time' mode
When running more games in parallel, or simply when running a game
with a background process, due to how OS scheduling works, there is no
guarantee that the CPU resources allocated evenly between the two
players. This introduces noise in the result that leads to unreliable
result and in the worst cases can even invalidate the result. For
instance in SF test framework we avoid running from clouds virtual
machines because are a known source of very unstable CPU speed.
To overcome this issue, without requiring changes to the GUI, the idea
is to use searched nodes instead of time, and to convert time to
available nodes upfront, at the beginning of the game.
When nodestime UCI option is set at a given nodes per milliseconds
(npmsec), at the beginning of the game (and only once), the engine
reads the available time to think, sent by the GUI with 'go wtime x'
UCI command. Then it translates time in available nodes (nodes =
npmsec * x), then feeds available nodes instead of time to the time
management logic and starts the search. During the search the engine
checks the searched nodes against the available ones in such a way
that all the time management logic still fully applies, and the game
mimics a real one played on real time. When the search finishes,
before returning best move, the total available nodes are updated,
subtracting the real searched nodes. After the first move, the time
information sent by the GUI is ignored, and the engine fully relies on
the updated total available nodes to feed time management.
To avoid time losses, the speed of the engine (npms) must be set to a
value lower than real speed so that if the real TC is for instance 30
secs, and npms is half of the real speed, the game will last on
average 15 secs, so much less than the TC limit, providing for a
safety 'time buffer'.
There are 2 main limitations with this mode.
1. Engine speed should be the same for both players, and this limits
the approach to mainly parameter tuning patches.
2. Because npms is fixed while, in real engines, the speed increases
toward endgame, this introduces an artifact that is equivalent to an
altered time management. Namely it is like the time management gives
less available time than what should be in standard case.
May be the second limitation could be mitigated in a future with a
smarter 'dynamic npms' approach.
Tests shows that the standard deviation of the results with 'nodestime'
is lower than in standard TC, as is expected because now all the introduced
noise due the random speed variability of the engines during the game is
fully removed.
Original NIT idea by Michael Hoffman that shows how to play in NIT mode
without requiring changes to the GUI. This implementation goes a bit
further, the key difference is that we read TC from GUI only once upfront
instead of re-reading after every move as in Michael's implementation.
No functional change.
2015-03-22 14:15:44 -06:00
|
|
|
|
2013-12-02 11:04:09 -07:00
|
|
|
// When we reach the maximum depth, we can arrive here without a raise of
|
|
|
|
// Signals.stop. However, if we are pondering or in an infinite search,
|
|
|
|
// the UCI protocol states that we shouldn't print the best move before the
|
|
|
|
// GUI sends a "stop" or "ponderhit" command. We therefore simply wait here
|
|
|
|
// until the GUI sends one of those commands (which also raises Signals.stop).
|
2011-11-26 04:07:35 -07:00
|
|
|
if (!Signals.stop && (Limits.ponder || Limits.infinite))
|
2013-01-13 06:15:19 -07:00
|
|
|
{
|
|
|
|
Signals.stopOnPonderhit = true;
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
wait(Signals.stop);
|
2013-01-13 06:15:19 -07:00
|
|
|
}
|
2010-12-30 08:18:22 -07:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
sync_cout << "bestmove " << UCI::move(rootMoves[0].pv[0], rootPos.is_chess960());
|
2014-11-23 17:53:00 -07:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
if (rootMoves[0].pv.size() > 1 || rootMoves[0].extract_ponder_from_tt(rootPos))
|
|
|
|
std::cout << " ponder " << UCI::move(rootMoves[0].pv[1], rootPos.is_chess960());
|
2014-11-23 17:53:00 -07:00
|
|
|
|
|
|
|
std::cout << sync_endl;
|
2008-08-31 23:59:13 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
// Thread::search() is the main iterative deepening loop. It calls search()
|
|
|
|
// repeatedly with increasing depth until the allocated thinking time has been
|
|
|
|
// consumed, user stops the search, or the maximum search depth is reached.
|
2008-08-31 23:59:13 -06:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
void Thread::search(bool isMainThread) {
|
2008-08-31 23:59:13 -06:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
Stack* ss = stack + 2; // To allow referencing (ss-2) and (ss+2)
|
|
|
|
Value bestValue, alpha, beta, delta;
|
|
|
|
Move easyMove = MOVE_NONE;
|
2008-10-30 04:35:44 -06:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
std::memset(ss-2, 0, 5 * sizeof(Stack));
|
2011-01-17 02:44:00 -07:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
bestValue = delta = alpha = -VALUE_INFINITE;
|
|
|
|
beta = VALUE_INFINITE;
|
2015-03-12 13:49:30 -06:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
if (isMainThread)
|
|
|
|
{
|
|
|
|
easyMove = EasyMove.get(rootPos.key());
|
|
|
|
EasyMove.clear();
|
|
|
|
BestMoveChanges = 0;
|
|
|
|
TT.new_search();
|
|
|
|
}
|
2013-07-03 10:58:49 -06:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
size_t multiPV = Options["MultiPV"];
|
|
|
|
Skill skill(Options["Skill Level"]);
|
2013-07-03 10:58:49 -06:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
// When playing with strength handicap enable MultiPV search that we will
|
|
|
|
// use behind the scenes to retrieve a set of possible moves.
|
|
|
|
if (skill.enabled())
|
|
|
|
multiPV = std::max(multiPV, (size_t)4);
|
2015-03-29 01:24:17 -06:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
multiPV = std::min(multiPV, rootMoves.size());
|
2012-10-24 04:05:20 -06:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
// Iterative deepening loop until requested to stop or target depth reached
|
|
|
|
while (++depth < DEPTH_MAX && !Signals.stop && (!Limits.depth || depth <= Limits.depth))
|
|
|
|
{
|
|
|
|
// Set up the new depth for the helper threads
|
|
|
|
if (!isMainThread)
|
|
|
|
depth = Threads.main()->depth + Depth(int(3 * log(1 + this->idx)));
|
2015-01-25 03:07:43 -07:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
// Age out PV variability metric
|
|
|
|
if (isMainThread)
|
|
|
|
BestMoveChanges *= 0.5;
|
2012-10-24 04:05:20 -06:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
// Save the last iteration's scores before first PV line is searched and
|
|
|
|
// all the move scores except the (new) PV are set to -VALUE_INFINITE.
|
|
|
|
for (RootMove& rm : rootMoves)
|
|
|
|
rm.previousScore = rm.score;
|
2013-08-24 10:29:44 -06:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
// MultiPV loop. We perform a full root search for each PV line
|
|
|
|
for (PVIdx = 0; PVIdx < multiPV && !Signals.stop; ++PVIdx)
|
|
|
|
{
|
|
|
|
// Reset aspiration window starting size
|
|
|
|
if (depth >= 5 * ONE_PLY)
|
|
|
|
{
|
2015-10-20 20:46:06 -06:00
|
|
|
delta = Value(18);
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
alpha = std::max(rootMoves[PVIdx].previousScore - delta,-VALUE_INFINITE);
|
|
|
|
beta = std::min(rootMoves[PVIdx].previousScore + delta, VALUE_INFINITE);
|
|
|
|
}
|
2009-04-11 07:46:35 -06:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
// Start with a small aspiration window and, in the case of a fail
|
|
|
|
// high/low, re-search with a bigger window until we're not failing
|
|
|
|
// high/low anymore.
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
bestValue = ::search<Root>(rootPos, ss, alpha, beta, depth, false);
|
|
|
|
|
|
|
|
// Bring the best move to the front. It is critical that sorting
|
|
|
|
// is done with a stable algorithm because all the values but the
|
|
|
|
// first and eventually the new best one are set to -VALUE_INFINITE
|
|
|
|
// and we want to keep the same order for all the moves except the
|
|
|
|
// new PV that goes to the front. Note that in case of MultiPV
|
|
|
|
// search the already searched PV lines are preserved.
|
|
|
|
std::stable_sort(rootMoves.begin() + PVIdx, rootMoves.end());
|
|
|
|
|
|
|
|
// Write PV back to transposition table in case the relevant
|
|
|
|
// entries have been overwritten during the search.
|
|
|
|
for (size_t i = 0; i <= PVIdx; ++i)
|
|
|
|
rootMoves[i].insert_pv_in_tt(rootPos);
|
|
|
|
|
|
|
|
// If search has been stopped break immediately. Sorting and
|
|
|
|
// writing PV back to TT is safe because RootMoves is still
|
|
|
|
// valid, although it refers to previous iteration.
|
|
|
|
if (Signals.stop)
|
|
|
|
break;
|
2011-02-28 12:17:57 -07:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
// When failing high/low give some update (without cluttering
|
|
|
|
// the UI) before a re-search.
|
|
|
|
if ( isMainThread
|
|
|
|
&& multiPV == 1
|
|
|
|
&& (bestValue <= alpha || bestValue >= beta)
|
|
|
|
&& Time.elapsed() > 3000)
|
|
|
|
sync_cout << UCI::pv(rootPos, depth, alpha, beta) << sync_endl;
|
|
|
|
|
|
|
|
// In case of failing low/high increase aspiration window and
|
|
|
|
// re-search, otherwise exit the loop.
|
|
|
|
if (bestValue <= alpha)
|
|
|
|
{
|
|
|
|
beta = (alpha + beta) / 2;
|
|
|
|
alpha = std::max(bestValue - delta, -VALUE_INFINITE);
|
2012-10-24 04:05:20 -06:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
if (isMainThread)
|
|
|
|
{
|
|
|
|
Signals.failedLowAtRoot = true;
|
|
|
|
Signals.stopOnPonderhit = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (bestValue >= beta)
|
|
|
|
{
|
|
|
|
alpha = (alpha + beta) / 2;
|
|
|
|
beta = std::min(bestValue + delta, VALUE_INFINITE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
2013-02-03 03:14:21 -07:00
|
|
|
|
2015-10-20 20:46:06 -06:00
|
|
|
delta += delta / 4 + 5;
|
2014-11-10 06:46:05 -07:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
assert(alpha >= -VALUE_INFINITE && beta <= VALUE_INFINITE);
|
|
|
|
}
|
2009-04-11 07:46:35 -06:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
// Sort the PV lines searched so far and update the GUI
|
|
|
|
std::stable_sort(rootMoves.begin(), rootMoves.begin() + PVIdx + 1);
|
2011-04-02 02:05:53 -06:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
if (!isMainThread)
|
|
|
|
break;
|
2012-12-30 03:40:20 -07:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
if (Signals.stop)
|
|
|
|
sync_cout << "info nodes " << Threads.nodes_searched()
|
|
|
|
<< " time " << Time.elapsed() << sync_endl;
|
2015-03-12 13:49:30 -06:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
else if (PVIdx + 1 == multiPV || Time.elapsed() > 3000)
|
|
|
|
sync_cout << UCI::pv(rootPos, depth, alpha, beta) << sync_endl;
|
|
|
|
}
|
2015-01-25 03:07:43 -07:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
if (!isMainThread)
|
|
|
|
continue;
|
2015-03-12 13:49:30 -06:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
// If skill level is enabled and time is up, pick a sub-optimal best move
|
|
|
|
if (skill.enabled() && skill.time_to_pick(depth))
|
|
|
|
skill.pick_best(multiPV);
|
|
|
|
|
|
|
|
// Have we found a "mate in x"?
|
|
|
|
if ( Limits.mate
|
|
|
|
&& bestValue >= VALUE_MATE_IN_MAX_PLY
|
|
|
|
&& VALUE_MATE - bestValue <= 2 * Limits.mate)
|
|
|
|
Signals.stop = true;
|
|
|
|
|
|
|
|
// Do we have time for the next iteration? Can we stop searching now?
|
|
|
|
if (Limits.use_time_management())
|
|
|
|
{
|
|
|
|
if (!Signals.stop && !Signals.stopOnPonderhit)
|
|
|
|
{
|
|
|
|
// Take some extra time if the best move has changed
|
|
|
|
if (depth > 4 * ONE_PLY && multiPV == 1)
|
|
|
|
Time.pv_instability(BestMoveChanges);
|
|
|
|
|
|
|
|
// Stop the search if only one legal move is available or all
|
|
|
|
// of the available time has been used or we matched an easyMove
|
|
|
|
// from the previous search and just did a fast verification.
|
|
|
|
if ( rootMoves.size() == 1
|
|
|
|
|| Time.elapsed() > Time.available()
|
|
|
|
|| ( rootMoves[0].pv[0] == easyMove
|
|
|
|
&& BestMoveChanges < 0.03
|
|
|
|
&& Time.elapsed() > Time.available() / 10))
|
|
|
|
{
|
|
|
|
// If we are allowed to ponder do not stop the search now but
|
|
|
|
// keep pondering until the GUI sends "ponderhit" or "stop".
|
|
|
|
if (Limits.ponder)
|
|
|
|
Signals.stopOnPonderhit = true;
|
|
|
|
else
|
|
|
|
Signals.stop = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rootMoves[0].pv.size() >= 3)
|
|
|
|
EasyMove.update(rootPos, rootMoves[0].pv);
|
|
|
|
else
|
|
|
|
EasyMove.clear();
|
|
|
|
}
|
2008-08-31 23:59:13 -06:00
|
|
|
}
|
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
searching = false;
|
|
|
|
notify_one(); // Wake up main thread if is sleeping waiting for us
|
|
|
|
|
|
|
|
if (!isMainThread)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Clear any candidate easy move that wasn't stable for the last search
|
|
|
|
// iterations; the second condition prevents consecutive fast moves.
|
|
|
|
if (EasyMove.stableCnt < 6 || Time.elapsed() < Time.available())
|
|
|
|
EasyMove.clear();
|
|
|
|
|
|
|
|
// If skill level is enabled, swap best PV line with the sub-optimal one
|
|
|
|
if (skill.enabled())
|
|
|
|
std::swap(rootMoves[0], *std::find(rootMoves.begin(),
|
|
|
|
rootMoves.end(), skill.best_move(multiPV)));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
namespace {
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2010-10-16 05:09:49 -06:00
|
|
|
// search<>() is the main search function for both PV and non-PV nodes and for
|
|
|
|
// normal and SplitPoint nodes. When called just after a split point the search
|
|
|
|
// is simpler because we have already probed the hash table, done a null move
|
2013-12-02 11:04:09 -07:00
|
|
|
// search, and searched the first move before splitting, so we don't have to
|
|
|
|
// repeat all this work again. We also don't need to store anything to the hash
|
|
|
|
// table here: This is taken care of after we return from the split point.
|
2008-08-31 23:59:13 -06:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
template <NodeType NT>
|
2013-06-09 01:43:04 -06:00
|
|
|
Value search(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth, bool cutNode) {
|
2010-05-08 02:54:51 -06:00
|
|
|
|
2014-05-04 05:11:32 -06:00
|
|
|
const bool RootNode = NT == Root;
|
|
|
|
const bool PvNode = NT == PV || NT == Root;
|
2011-05-28 05:13:42 -06:00
|
|
|
|
2014-02-15 01:20:27 -07:00
|
|
|
assert(-VALUE_INFINITE <= alpha && alpha < beta && beta <= VALUE_INFINITE);
|
2012-09-29 10:26:17 -06:00
|
|
|
assert(PvNode || (alpha == beta - 1));
|
2011-12-26 17:00:44 -07:00
|
|
|
assert(depth > DEPTH_ZERO);
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2014-11-18 03:57:57 -07:00
|
|
|
Move pv[MAX_PLY+1], quietsSearched[64];
|
2009-11-05 03:11:02 -07:00
|
|
|
StateInfo st;
|
2014-12-13 00:16:35 -07:00
|
|
|
TTEntry* tte;
|
2010-06-02 06:22:48 -06:00
|
|
|
Key posKey;
|
2013-12-14 04:27:29 -07:00
|
|
|
Move ttMove, move, excludedMove, bestMove;
|
2014-12-07 16:53:33 -07:00
|
|
|
Depth extension, newDepth, predictedDepth;
|
2013-11-10 07:53:23 -07:00
|
|
|
Value bestValue, value, ttValue, eval, nullValue, futilityValue;
|
2014-12-13 01:27:39 -07:00
|
|
|
bool ttHit, inCheck, givesCheck, singularExtensionNode, improving;
|
2015-08-18 04:53:16 -06:00
|
|
|
bool captureOrPromotion, doFullDepthSearch;
|
2013-11-17 15:47:18 -07:00
|
|
|
int moveCount, quietCount;
|
2011-01-16 04:02:32 -07:00
|
|
|
|
2012-10-01 01:33:13 -06:00
|
|
|
// Step 1. Initialize node
|
2012-09-29 10:26:17 -06:00
|
|
|
Thread* thisThread = pos.this_thread();
|
2012-12-25 09:59:35 -07:00
|
|
|
inCheck = pos.checkers();
|
2015-07-29 10:50:45 -06:00
|
|
|
moveCount = quietCount = ss->moveCount = 0;
|
2012-10-01 01:33:13 -06:00
|
|
|
bestValue = -VALUE_INFINITE;
|
|
|
|
ss->ply = (ss-1)->ply + 1;
|
|
|
|
|
|
|
|
// Used to send selDepth info to GUI
|
|
|
|
if (PvNode && thisThread->maxPly < ss->ply)
|
|
|
|
thisThread->maxPly = ss->ply;
|
2009-11-05 03:11:02 -07:00
|
|
|
|
2011-06-18 10:10:29 -06:00
|
|
|
if (!RootNode)
|
|
|
|
{
|
2012-09-29 10:26:17 -06:00
|
|
|
// Step 2. Check for aborted search and immediate draw
|
Cleanup MAX_PLY
This area has become obscure and tricky over the course of incremental
changes that did not respect the original's consistency and clarity. Now,
it's not clear why we use MAX_PLY = 120, or why we use MAX_PLY+6, among
other things.
This patch does the following:
* ID loop: depth ranges from 1 to MAX_PLY-1, and due to TT constraint (depth
must fit into an int8_t), MAX_PLY should be 128.
* stack[]: plies now range from 0 to MAX_PLY-1, hence stack[MAX_PLY+4],
because of the extra 2+2 padding elements (for ss-2 and ss+2). Document this
better, while we're at it.
* Enforce 0 <= ply < MAX_PLY:
- stop condition is now ss->ply >= MAX_PLY and not ss->ply > MAX_PLY.
- assert(ss->ply < MAX_PLY), before using ss+1 and ss+2.
- as a result, we don't need the artificial MAX_PLY+6 range. Instead we
can use MAX_PLY+4 and it's clear why (for ss-2 and ss+2).
* fix: extract_pv_from_tt() and insert_pv_in_tt() had no reason to use
MAX_PLY_PLUS_6, because the array is indexed by plies, so the range of
available plies applies (0..MAX_PLY before, and now 0..MAX_PLY-1).
Tested with debug compile, using MAX_PLY=16, and running bench at depth 17,
using 1 and 7 threads. No assert() fired. Feel free to submit to more severe
crash-tests, if you can think of any.
No functional change.
2014-11-03 08:36:24 -07:00
|
|
|
if (Signals.stop || pos.is_draw() || ss->ply >= MAX_PLY)
|
|
|
|
return ss->ply >= MAX_PLY && !inCheck ? evaluate(pos) : DrawValue[pos.side_to_move()];
|
2012-09-29 10:26:17 -06:00
|
|
|
|
|
|
|
// Step 3. Mate distance pruning. Even if we mate at the next move our score
|
|
|
|
// would be at best mate_in(ss->ply+1), but if alpha is already bigger because
|
|
|
|
// a shorter mate was found upward in the tree then there is no need to search
|
2013-12-02 11:04:09 -07:00
|
|
|
// because we will never beat the current alpha. Same logic but with reversed
|
|
|
|
// signs applies also in the opposite condition of being mated instead of giving
|
|
|
|
// mate. In this case return a fail-high score.
|
2011-12-27 08:01:33 -07:00
|
|
|
alpha = std::max(mated_in(ss->ply), alpha);
|
|
|
|
beta = std::min(mate_in(ss->ply+1), beta);
|
2011-06-18 10:10:29 -06:00
|
|
|
if (alpha >= beta)
|
|
|
|
return alpha;
|
|
|
|
}
|
2010-02-24 03:19:47 -07:00
|
|
|
|
Cleanup MAX_PLY
This area has become obscure and tricky over the course of incremental
changes that did not respect the original's consistency and clarity. Now,
it's not clear why we use MAX_PLY = 120, or why we use MAX_PLY+6, among
other things.
This patch does the following:
* ID loop: depth ranges from 1 to MAX_PLY-1, and due to TT constraint (depth
must fit into an int8_t), MAX_PLY should be 128.
* stack[]: plies now range from 0 to MAX_PLY-1, hence stack[MAX_PLY+4],
because of the extra 2+2 padding elements (for ss-2 and ss+2). Document this
better, while we're at it.
* Enforce 0 <= ply < MAX_PLY:
- stop condition is now ss->ply >= MAX_PLY and not ss->ply > MAX_PLY.
- assert(ss->ply < MAX_PLY), before using ss+1 and ss+2.
- as a result, we don't need the artificial MAX_PLY+6 range. Instead we
can use MAX_PLY+4 and it's clear why (for ss-2 and ss+2).
* fix: extract_pv_from_tt() and insert_pv_in_tt() had no reason to use
MAX_PLY_PLUS_6, because the array is indexed by plies, so the range of
available plies applies (0..MAX_PLY before, and now 0..MAX_PLY-1).
Tested with debug compile, using MAX_PLY=16, and running bench at depth 17,
using 1 and 7 threads. No assert() fired. Feel free to submit to more severe
crash-tests, if you can think of any.
No functional change.
2014-11-03 08:36:24 -07:00
|
|
|
assert(0 <= ss->ply && ss->ply < MAX_PLY);
|
|
|
|
|
|
|
|
ss->currentMove = ss->ttMove = (ss+1)->excludedMove = bestMove = MOVE_NONE;
|
2014-12-08 01:46:21 -07:00
|
|
|
(ss+1)->skipEarlyPruning = false; (ss+1)->reduction = DEPTH_ZERO;
|
Cleanup MAX_PLY
This area has become obscure and tricky over the course of incremental
changes that did not respect the original's consistency and clarity. Now,
it's not clear why we use MAX_PLY = 120, or why we use MAX_PLY+6, among
other things.
This patch does the following:
* ID loop: depth ranges from 1 to MAX_PLY-1, and due to TT constraint (depth
must fit into an int8_t), MAX_PLY should be 128.
* stack[]: plies now range from 0 to MAX_PLY-1, hence stack[MAX_PLY+4],
because of the extra 2+2 padding elements (for ss-2 and ss+2). Document this
better, while we're at it.
* Enforce 0 <= ply < MAX_PLY:
- stop condition is now ss->ply >= MAX_PLY and not ss->ply > MAX_PLY.
- assert(ss->ply < MAX_PLY), before using ss+1 and ss+2.
- as a result, we don't need the artificial MAX_PLY+6 range. Instead we
can use MAX_PLY+4 and it's clear why (for ss-2 and ss+2).
* fix: extract_pv_from_tt() and insert_pv_in_tt() had no reason to use
MAX_PLY_PLUS_6, because the array is indexed by plies, so the range of
available plies applies (0..MAX_PLY before, and now 0..MAX_PLY-1).
Tested with debug compile, using MAX_PLY=16, and running bench at depth 17,
using 1 and 7 threads. No assert() fired. Feel free to submit to more severe
crash-tests, if you can think of any.
No functional change.
2014-11-03 08:36:24 -07:00
|
|
|
(ss+2)->killers[0] = (ss+2)->killers[1] = MOVE_NONE;
|
|
|
|
|
2011-01-23 00:36:12 -07:00
|
|
|
// Step 4. Transposition table lookup
|
2009-11-23 04:40:18 -07:00
|
|
|
// We don't want the score of a partial search to overwrite a previous full search
|
2011-02-12 11:04:27 -07:00
|
|
|
// TT value, so we use a different position key in case of an excluded move.
|
2013-11-18 23:19:28 -07:00
|
|
|
excludedMove = ss->excludedMove;
|
2011-12-25 03:50:59 -07:00
|
|
|
posKey = excludedMove ? pos.exclusion_key() : pos.key();
|
2014-12-13 00:16:35 -07:00
|
|
|
tte = TT.probe(posKey, ttHit);
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
ss->ttMove = ttMove = RootNode ? thisThread->rootMoves[thisThread->PVIdx].pv[0] : ttHit ? tte->move() : MOVE_NONE;
|
2014-12-13 00:16:35 -07:00
|
|
|
ttValue = ttHit ? value_from_tt(tte->value(), ss->ply) : VALUE_NONE;
|
2008-09-06 07:53:43 -06:00
|
|
|
|
2015-03-18 08:10:13 -06:00
|
|
|
// At non-PV nodes we check for a fail high/low. We don't prune at PV nodes
|
2014-11-18 03:57:57 -07:00
|
|
|
if ( !PvNode
|
2014-12-13 00:16:35 -07:00
|
|
|
&& ttHit
|
2012-12-15 03:11:38 -07:00
|
|
|
&& tte->depth() >= depth
|
|
|
|
&& ttValue != VALUE_NONE // Only in case of TT access race
|
2014-11-12 14:13:55 -07:00
|
|
|
&& (ttValue >= beta ? (tte->bound() & BOUND_LOWER)
|
|
|
|
: (tte->bound() & BOUND_UPPER)))
|
2008-09-06 07:53:43 -06:00
|
|
|
{
|
2012-12-15 03:11:38 -07:00
|
|
|
ss->currentMove = ttMove; // Can be MOVE_NONE
|
2011-09-18 12:50:42 -06:00
|
|
|
|
2015-03-28 16:09:48 -06:00
|
|
|
// If ttMove is quiet, update killers, history, counter move on TT hit
|
2015-04-05 12:36:11 -06:00
|
|
|
if (ttValue >= beta && ttMove && !pos.capture_or_promotion(ttMove))
|
2015-01-18 00:00:50 -07:00
|
|
|
update_stats(pos, ss, ttMove, depth, nullptr, 0);
|
2013-12-09 03:14:14 -07:00
|
|
|
|
2012-12-15 03:11:38 -07:00
|
|
|
return ttValue;
|
2008-08-31 23:59:13 -06:00
|
|
|
}
|
|
|
|
|
2015-01-18 00:05:05 -07:00
|
|
|
// Step 4a. Tablebase probe
|
|
|
|
if (!RootNode && TB::Cardinality)
|
|
|
|
{
|
|
|
|
int piecesCnt = pos.count<ALL_PIECES>(WHITE) + pos.count<ALL_PIECES>(BLACK);
|
|
|
|
|
|
|
|
if ( piecesCnt <= TB::Cardinality
|
|
|
|
&& (piecesCnt < TB::Cardinality || depth >= TB::ProbeDepth)
|
|
|
|
&& pos.rule50_count() == 0)
|
|
|
|
{
|
|
|
|
int found, v = Tablebases::probe_wdl(pos, &found);
|
|
|
|
|
|
|
|
if (found)
|
|
|
|
{
|
|
|
|
TB::Hits++;
|
|
|
|
|
|
|
|
int drawScore = TB::UseRule50 ? 1 : 0;
|
|
|
|
|
|
|
|
value = v < -drawScore ? -VALUE_MATE + MAX_PLY + ss->ply
|
|
|
|
: v > drawScore ? VALUE_MATE - MAX_PLY - ss->ply
|
|
|
|
: VALUE_DRAW + 2 * v * drawScore;
|
|
|
|
|
|
|
|
tte->save(posKey, value_to_tt(value, ss->ply), BOUND_EXACT,
|
|
|
|
std::min(DEPTH_MAX - ONE_PLY, depth + 6 * ONE_PLY),
|
|
|
|
MOVE_NONE, VALUE_NONE, TT.generation());
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-18 14:58:13 -06:00
|
|
|
// Step 5. Evaluate the position statically
|
2011-04-29 08:26:48 -06:00
|
|
|
if (inCheck)
|
2013-07-07 05:27:31 -06:00
|
|
|
{
|
2013-11-08 03:42:22 -07:00
|
|
|
ss->staticEval = eval = VALUE_NONE;
|
2013-07-07 05:45:46 -06:00
|
|
|
goto moves_loop;
|
2013-07-07 05:27:31 -06:00
|
|
|
}
|
2012-12-27 04:13:31 -07:00
|
|
|
|
2014-12-13 00:16:35 -07:00
|
|
|
else if (ttHit)
|
2010-01-17 04:55:10 -07:00
|
|
|
{
|
2012-12-31 08:28:40 -07:00
|
|
|
// Never assume anything on values stored in TT
|
2015-01-09 04:35:44 -07:00
|
|
|
if ((ss->staticEval = eval = tte->eval()) == VALUE_NONE)
|
2014-06-06 01:35:34 -06:00
|
|
|
eval = ss->staticEval = evaluate(pos);
|
2012-10-26 04:33:58 -06:00
|
|
|
|
2012-10-22 01:50:00 -06:00
|
|
|
// Can ttValue be used as a better position evaluation?
|
2012-12-27 04:13:31 -07:00
|
|
|
if (ttValue != VALUE_NONE)
|
2013-09-25 05:04:38 -06:00
|
|
|
if (tte->bound() & (ttValue > eval ? BOUND_LOWER : BOUND_UPPER))
|
2012-10-26 04:33:58 -06:00
|
|
|
eval = ttValue;
|
2012-12-27 04:13:31 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-06-06 03:12:05 -06:00
|
|
|
eval = ss->staticEval =
|
|
|
|
(ss-1)->currentMove != MOVE_NULL ? evaluate(pos) : -(ss-1)->staticEval + 2 * Eval::Tempo;
|
|
|
|
|
2014-12-13 01:27:39 -07:00
|
|
|
tte->save(posKey, VALUE_NONE, BOUND_NONE, DEPTH_NONE, MOVE_NONE, ss->staticEval, TT.generation());
|
2011-10-31 01:28:59 -06:00
|
|
|
}
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2014-12-08 01:46:21 -07:00
|
|
|
if (ss->skipEarlyPruning)
|
|
|
|
goto moves_loop;
|
|
|
|
|
2013-07-19 01:37:31 -06:00
|
|
|
// Step 6. Razoring (skipped when in check)
|
2010-05-08 02:54:51 -06:00
|
|
|
if ( !PvNode
|
2012-10-03 02:08:10 -06:00
|
|
|
&& depth < 4 * ONE_PLY
|
2015-10-20 20:46:06 -06:00
|
|
|
&& eval + razor_margin[depth] <= alpha
|
2015-06-30 05:50:59 -06:00
|
|
|
&& ttMove == MOVE_NONE)
|
2010-02-24 03:26:36 -07:00
|
|
|
{
|
2014-05-13 14:33:41 -06:00
|
|
|
if ( depth <= ONE_PLY
|
2015-10-20 20:46:06 -06:00
|
|
|
&& eval + razor_margin[3 * ONE_PLY] <= alpha)
|
2014-05-13 14:33:41 -06:00
|
|
|
return qsearch<NonPV, false>(pos, ss, alpha, beta, DEPTH_ZERO);
|
|
|
|
|
2015-10-20 20:46:06 -06:00
|
|
|
Value ralpha = alpha - razor_margin[depth];
|
Better document razoring
Use ralpha instead of rbeta
* rbeta is confusing people. It took THREE attempts to code razoring
at PV nodes correctly in a recent test, because of the rbeta trick.
Unnecessary tricks should be avoided.
* The more correct and self-documenting way of doing this, is to say
that we use a zero window around alpha-margin, not beta-margin.
The fact that, because we only do it at PV nodes, alpha happens to be
beta-1 and that the current stuff with rbeta works, may be correct,
but is confusing.
Remove the misleading and partially erroneous comment about returning
v + margin:
* comments should explain what the code does, not what it could have done.
* this comment is partially wrong in saying that v+margin is "logical",
and that it is "surprising" that is doesn't work.
From a theoretical perspective, at least 3 ways of doing this are equally
defendable:
1/ fail hard: return alpha: The most conservative. We bet that the search
will fail low, but we don't know by how much and don't want to take risks.
2/ aggressive fail soft: return v (what the current code does). This
corresponds to normal fail soft, with the added assumption that we don't
care about the reduction effect (see below point 3/)
3/ conservative fail soft: return v + margin. If the reduced search (qsearch)
gives us a score <= v, we bet that the non reduced search will give us a
score <= v + margin.
* Saying that 2/ is "logical" implies that 1/ and 3/ are not, which is
arguably wrong. Besides, experimental results tell us that 2/ beats 3/,
and that's not something we can argue against: experimental results are
the only trusted metric.
* Also, with the benefit of hindsight, I don't think the fact that 2/ is
better than 3/ is surprising at all. The point is that it is YOUR turn to
move, and you are assuming that by NOT playing (and letting the opponent
capture your hanging pieces in QS) you cannot generally GAIN razor_margin(depth).
No functional change.
2014-02-02 18:41:32 -07:00
|
|
|
Value v = qsearch<NonPV, false>(pos, ss, ralpha, ralpha+1, DEPTH_ZERO);
|
|
|
|
if (v <= ralpha)
|
2010-03-03 23:52:35 -07:00
|
|
|
return v;
|
2010-02-24 03:26:36 -07:00
|
|
|
}
|
|
|
|
|
2013-11-08 03:42:22 -07:00
|
|
|
// Step 7. Futility pruning: child node (skipped when in check)
|
2015-01-14 13:11:33 -07:00
|
|
|
if ( !RootNode
|
2013-11-08 03:42:22 -07:00
|
|
|
&& depth < 7 * ONE_PLY
|
|
|
|
&& eval - futility_margin(depth) >= beta
|
2014-09-28 10:45:49 -06:00
|
|
|
&& eval < VALUE_KNOWN_WIN // Do not return unproven wins
|
2010-06-01 12:49:46 -06:00
|
|
|
&& pos.non_pawn_material(pos.side_to_move()))
|
2013-11-08 03:42:22 -07:00
|
|
|
return eval - futility_margin(depth);
|
2010-01-21 10:03:06 -07:00
|
|
|
|
2010-05-08 02:54:51 -06:00
|
|
|
// Step 8. Null move search with verification search (is omitted in PV nodes)
|
|
|
|
if ( !PvNode
|
2013-08-20 16:26:16 -06:00
|
|
|
&& depth >= 2 * ONE_PLY
|
2012-10-22 01:50:00 -06:00
|
|
|
&& eval >= beta
|
2010-06-01 12:49:46 -06:00
|
|
|
&& pos.non_pawn_material(pos.side_to_move()))
|
2009-08-29 13:19:09 -06:00
|
|
|
{
|
2010-05-30 01:56:38 -06:00
|
|
|
ss->currentMove = MOVE_NULL;
|
2009-08-29 13:19:09 -06:00
|
|
|
|
2014-01-24 13:52:56 -07:00
|
|
|
assert(eval - beta >= 0);
|
2009-11-13 03:25:34 -07:00
|
|
|
|
2014-01-24 13:52:56 -07:00
|
|
|
// Null move dynamic reduction based on depth and value
|
2015-01-05 15:09:12 -07:00
|
|
|
Depth R = ((823 + 67 * depth) / 256 + std::min((eval - beta) / PawnValueMg, 3)) * ONE_PLY;
|
2009-08-29 13:19:09 -06:00
|
|
|
|
2013-01-27 03:45:01 -07:00
|
|
|
pos.do_null_move(st);
|
2014-12-08 01:46:21 -07:00
|
|
|
(ss+1)->skipEarlyPruning = true;
|
Better document null search window
Hopefully this patch makes the code more:
* Self-documenting: Null search is always a zero window search,
because it is testing for a fail high. It should never be done
on a full window! The current code only works because we don't
do it at PV nodes, and therefore (alpha, beta) = (beta-1, beta):
that's the kind of "clever" trick we should avoid.
* Idiot-proof: If we want to enable null search at PV nodes, all we
need to do now is comment out the !PvNode condition. It's that simple!
In theory, null search should not be done at PV nodes, because PV nodes
should never fail high. But in practice, they DO fail high, because of
aspiration windows, and search inconsistencies, for example. So it makes
sense to keep that flexibility in the code.
No functional change.
2014-02-04 00:18:19 -07:00
|
|
|
nullValue = depth-R < ONE_PLY ? -qsearch<NonPV, false>(pos, ss+1, -beta, -beta+1, DEPTH_ZERO)
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
: - search<NonPV>(pos, ss+1, -beta, -beta+1, depth-R, !cutNode);
|
2014-12-08 01:46:21 -07:00
|
|
|
(ss+1)->skipEarlyPruning = false;
|
2013-01-27 03:45:01 -07:00
|
|
|
pos.undo_null_move();
|
2009-08-24 08:46:03 -06:00
|
|
|
|
2014-02-12 06:16:21 -07:00
|
|
|
if (nullValue >= beta)
|
|
|
|
{
|
|
|
|
// Do not return unproven mate scores
|
|
|
|
if (nullValue >= VALUE_MATE_IN_MAX_PLY)
|
|
|
|
nullValue = beta;
|
|
|
|
|
2014-06-16 13:46:42 -06:00
|
|
|
if (depth < 12 * ONE_PLY && abs(beta) < VALUE_KNOWN_WIN)
|
2014-02-12 06:16:21 -07:00
|
|
|
return nullValue;
|
|
|
|
|
|
|
|
// Do verification search at high depths
|
2014-12-08 01:46:21 -07:00
|
|
|
ss->skipEarlyPruning = true;
|
2014-02-12 06:16:21 -07:00
|
|
|
Value v = depth-R < ONE_PLY ? qsearch<NonPV, false>(pos, ss, beta-1, beta, DEPTH_ZERO)
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
: search<NonPV>(pos, ss, beta-1, beta, depth-R, false);
|
2014-12-08 01:46:21 -07:00
|
|
|
ss->skipEarlyPruning = false;
|
2014-02-12 06:16:21 -07:00
|
|
|
|
|
|
|
if (v >= beta)
|
|
|
|
return nullValue;
|
|
|
|
}
|
2009-08-29 13:19:09 -06:00
|
|
|
}
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2014-02-15 14:17:58 -07:00
|
|
|
// Step 9. ProbCut (skipped when in check)
|
2011-06-09 14:57:42 -06:00
|
|
|
// If we have a very good capture (i.e. SEE > seeValues[captured_piece_type])
|
|
|
|
// and a reduced search returns a value much above beta, we can (almost) safely
|
|
|
|
// prune the previous move.
|
2011-05-21 10:17:11 -06:00
|
|
|
if ( !PvNode
|
2012-10-03 02:08:10 -06:00
|
|
|
&& depth >= 5 * ONE_PLY
|
2011-12-30 09:08:07 -07:00
|
|
|
&& abs(beta) < VALUE_MATE_IN_MAX_PLY)
|
2011-05-21 10:17:11 -06:00
|
|
|
{
|
2014-02-22 02:34:48 -07:00
|
|
|
Value rbeta = std::min(beta + 200, VALUE_INFINITE);
|
2014-03-03 00:07:57 -07:00
|
|
|
Depth rdepth = depth - 4 * ONE_PLY;
|
2011-05-21 10:17:11 -06:00
|
|
|
|
|
|
|
assert(rdepth >= ONE_PLY);
|
2012-01-21 15:30:56 -07:00
|
|
|
assert((ss-1)->currentMove != MOVE_NONE);
|
2012-02-20 06:21:25 -07:00
|
|
|
assert((ss-1)->currentMove != MOVE_NULL);
|
2011-05-21 10:17:11 -06:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
MovePicker mp(pos, ttMove, thisThread->History, CounterMovesHistory, PieceValue[MG][pos.captured_piece_type()]);
|
2011-06-20 01:46:31 -06:00
|
|
|
CheckInfo ci(pos);
|
2011-05-21 10:17:11 -06:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
while ((move = mp.next_move()) != MOVE_NONE)
|
2013-09-28 06:43:50 -06:00
|
|
|
if (pos.legal(move, ci.pinned))
|
2011-05-21 10:17:11 -06:00
|
|
|
{
|
2012-01-21 15:30:56 -07:00
|
|
|
ss->currentMove = move;
|
Compute checkers from scratch
This micro-optimization only complicates the code and provides no benefit.
Removing it is even a speedup on my machine (i7-3770k, linux, gcc 4.9.1):
stat test master diff
mean 2,403,118 2,390,904 12,214
stdev 12,043 10,620 3,677
speedup 0.51%
P(speedup>0) 100.0%
No functional change.
2015-02-15 00:49:20 -07:00
|
|
|
pos.do_move(move, st, pos.gives_check(move, ci));
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
value = -search<NonPV>(pos, ss+1, -rbeta, -rbeta+1, rdepth, !cutNode);
|
2011-05-21 10:17:11 -06:00
|
|
|
pos.undo_move(move);
|
|
|
|
if (value >= rbeta)
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-19 01:37:31 -06:00
|
|
|
// Step 10. Internal iterative deepening (skipped when in check)
|
2014-02-15 01:20:27 -07:00
|
|
|
if ( depth >= (PvNode ? 5 * ONE_PLY : 8 * ONE_PLY)
|
|
|
|
&& !ttMove
|
2014-04-27 02:13:59 -06:00
|
|
|
&& (PvNode || ss->staticEval + 256 >= beta))
|
2008-09-06 10:25:58 -06:00
|
|
|
{
|
2015-07-28 04:53:13 -06:00
|
|
|
Depth d = depth - 2 * ONE_PLY - (PvNode ? DEPTH_ZERO : depth / 4);
|
2014-12-08 01:46:21 -07:00
|
|
|
ss->skipEarlyPruning = true;
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
search<PvNode ? PV : NonPV>(pos, ss, alpha, beta, d, true);
|
2014-12-08 01:46:21 -07:00
|
|
|
ss->skipEarlyPruning = false;
|
2010-06-02 06:32:31 -06:00
|
|
|
|
2014-12-13 00:16:35 -07:00
|
|
|
tte = TT.probe(posKey, ttHit);
|
|
|
|
ttMove = ttHit ? tte->move() : MOVE_NONE;
|
2008-08-31 23:59:13 -06:00
|
|
|
}
|
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
moves_loop: // When in check search starts from here
|
2010-10-16 03:01:45 -06:00
|
|
|
|
2013-05-19 13:32:52 -06:00
|
|
|
Square prevMoveSq = to_sq((ss-1)->currentMove);
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
Move countermove = thisThread->Countermoves[pos.piece_on(prevMoveSq)][prevMoveSq];
|
2013-05-19 13:32:52 -06:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
MovePicker mp(pos, ttMove, depth, thisThread->History, CounterMovesHistory, countermove, ss);
|
2009-11-09 12:54:45 -07:00
|
|
|
CheckInfo ci(pos);
|
2012-09-29 10:26:17 -06:00
|
|
|
value = bestValue; // Workaround a bogus 'uninitialized' warning under gcc
|
2013-08-09 00:21:55 -06:00
|
|
|
improving = ss->staticEval >= (ss-2)->staticEval
|
|
|
|
|| ss->staticEval == VALUE_NONE
|
|
|
|
||(ss-2)->staticEval == VALUE_NONE;
|
|
|
|
|
2011-05-28 05:13:42 -06:00
|
|
|
singularExtensionNode = !RootNode
|
2013-09-07 01:32:01 -06:00
|
|
|
&& depth >= 8 * ONE_PLY
|
2012-04-28 04:08:10 -06:00
|
|
|
&& ttMove != MOVE_NONE
|
Fix Singular extension condition to handle mate scores
With Eelco's patch "Don't special case for abs(beta) >= VALUE_MATE_IN_MAX_PLY" condition "abs(ttValue) < VALUE_KNOWN_WIN" has been removed from singular extension search, and condition "abs(beta) < VALUE_KNOWN_WIN" was added to the SingularExtensionNode definition.
This might lead to problems, especially in positions, where a mate is due.
For example, this position 5rk1/4K1pp/8/5PPP/8/8/8/1R6 w - - 12 1 triggers an assert.
stockfish: search.cpp:434: Value {anonymous}::search(Position&, Search::Stack*, Value, Value, Depth, bool) [with {anonymous}::NodeType NT = (<unnamed>::NodeType)2u; bool SpNode = false]: Assertion `-VALUE_INFINITE <= alpha && alpha < beta && beta <= VALUE_INFINITE' failed.
So let's re-insert the removed condition.
First spotted by Uri Blass, fix by me.
Bench: 8759675
2014-06-29 13:17:40 -06:00
|
|
|
/* && ttValue != VALUE_NONE Already implicit in the next condition */
|
|
|
|
&& abs(ttValue) < VALUE_KNOWN_WIN
|
2011-12-10 11:14:13 -07:00
|
|
|
&& !excludedMove // Recursive singular search is not allowed
|
2013-06-29 02:23:43 -06:00
|
|
|
&& (tte->bound() & BOUND_LOWER)
|
2012-04-28 04:08:10 -06:00
|
|
|
&& tte->depth() >= depth - 3 * ONE_PLY;
|
2010-10-16 03:01:45 -06:00
|
|
|
|
2011-05-21 10:17:11 -06:00
|
|
|
// Step 11. Loop through moves
|
2011-05-28 05:57:36 -06:00
|
|
|
// Loop through all pseudo-legal moves until no moves remain or a beta cutoff occurs
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
while ((move = mp.next_move()) != MOVE_NONE)
|
2008-09-06 10:25:58 -06:00
|
|
|
{
|
2011-10-03 02:56:49 -06:00
|
|
|
assert(is_ok(move));
|
2011-01-16 15:40:06 -07:00
|
|
|
|
2011-05-28 03:35:52 -06:00
|
|
|
if (move == excludedMove)
|
|
|
|
continue;
|
|
|
|
|
2011-10-08 03:51:39 -06:00
|
|
|
// At root obey the "searchmoves" option and skip moves not listed in Root
|
2013-12-04 23:18:12 -07:00
|
|
|
// Move List. As a consequence any illegal move is also skipped. In MultiPV
|
2011-10-08 03:51:39 -06:00
|
|
|
// mode we also skip PV moves which have been already searched.
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
if (RootNode && !std::count(thisThread->rootMoves.begin() + thisThread->PVIdx, thisThread->rootMoves.end(), move))
|
2011-07-31 06:18:52 -06:00
|
|
|
continue;
|
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
ss->moveCount = ++moveCount;
|
2012-09-29 09:41:53 -06:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
if (RootNode && thisThread == Threads.main())
|
2011-01-16 15:40:06 -07:00
|
|
|
{
|
2011-11-26 04:07:35 -07:00
|
|
|
Signals.firstRootMove = (moveCount == 1);
|
2011-01-16 04:02:32 -07:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
if (Time.elapsed() > 3000)
|
2014-11-25 16:53:40 -07:00
|
|
|
sync_cout << "info depth " << depth / ONE_PLY
|
2014-12-14 01:31:13 -07:00
|
|
|
<< " currmove " << UCI::move(move, pos.is_chess960())
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
<< " currmovenumber " << moveCount + thisThread->PVIdx << sync_endl;
|
2011-01-16 04:02:32 -07:00
|
|
|
}
|
|
|
|
|
2014-11-12 14:13:55 -07:00
|
|
|
if (PvNode)
|
2015-01-18 00:00:50 -07:00
|
|
|
(ss+1)->pv = nullptr;
|
2014-11-12 14:13:55 -07:00
|
|
|
|
2014-12-07 16:53:33 -07:00
|
|
|
extension = DEPTH_ZERO;
|
2013-09-28 06:43:50 -06:00
|
|
|
captureOrPromotion = pos.capture_or_promotion(move);
|
2014-02-08 05:21:50 -07:00
|
|
|
|
|
|
|
givesCheck = type_of(move) == NORMAL && !ci.dcCandidates
|
2015-05-09 03:09:06 -06:00
|
|
|
? ci.checkSquares[type_of(pos.piece_on(from_sq(move)))] & to_sq(move)
|
2014-02-08 05:21:50 -07:00
|
|
|
: pos.gives_check(move, ci);
|
|
|
|
|
2013-09-26 04:25:27 -06:00
|
|
|
// Step 12. Extend checks
|
2014-02-16 05:06:31 -07:00
|
|
|
if (givesCheck && pos.see_sign(move) >= VALUE_ZERO)
|
2014-12-07 16:53:33 -07:00
|
|
|
extension = ONE_PLY;
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2011-04-03 02:19:08 -06:00
|
|
|
// Singular extension search. If all moves but one fail low on a search of
|
|
|
|
// (alpha-s, beta-s), and just one fails high on (alpha, beta), then that move
|
|
|
|
// is singular and should be extended. To verify this we do a reduced search
|
2013-12-02 11:04:09 -07:00
|
|
|
// on all the other moves but the ttMove and if the result is lower than
|
|
|
|
// ttValue minus a margin then we extend the ttMove.
|
2012-04-28 04:08:10 -06:00
|
|
|
if ( singularExtensionNode
|
|
|
|
&& move == ttMove
|
2014-12-07 16:53:33 -07:00
|
|
|
&& !extension
|
2014-06-16 13:46:42 -06:00
|
|
|
&& pos.legal(move, ci.pinned))
|
2009-11-21 06:22:52 -07:00
|
|
|
{
|
2014-11-25 16:53:40 -07:00
|
|
|
Value rBeta = ttValue - 2 * depth / ONE_PLY;
|
2012-07-14 05:18:14 -06:00
|
|
|
ss->excludedMove = move;
|
2014-12-08 01:46:21 -07:00
|
|
|
ss->skipEarlyPruning = true;
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
value = search<NonPV>(pos, ss, rBeta - 1, rBeta, depth / 2, cutNode);
|
2014-12-08 01:46:21 -07:00
|
|
|
ss->skipEarlyPruning = false;
|
2012-07-14 05:18:14 -06:00
|
|
|
ss->excludedMove = MOVE_NONE;
|
|
|
|
|
|
|
|
if (value < rBeta)
|
2014-12-07 16:53:33 -07:00
|
|
|
extension = ONE_PLY;
|
2009-11-21 06:22:52 -07:00
|
|
|
}
|
|
|
|
|
2013-12-02 11:04:09 -07:00
|
|
|
// Update the current move (this must be done after singular extension search)
|
2014-12-07 16:53:33 -07:00
|
|
|
newDepth = depth - ONE_PLY + extension;
|
2009-11-21 08:05:18 -07:00
|
|
|
|
2015-01-14 13:11:33 -07:00
|
|
|
// Step 13. Pruning at shallow depth
|
2015-01-24 14:05:06 -07:00
|
|
|
if ( !RootNode
|
|
|
|
&& !captureOrPromotion
|
2011-04-29 08:26:48 -06:00
|
|
|
&& !inCheck
|
2015-08-18 04:53:16 -06:00
|
|
|
&& !givesCheck
|
|
|
|
&& !pos.advanced_pawn_push(move)
|
2013-03-22 01:54:03 -06:00
|
|
|
&& bestValue > VALUE_MATED_IN_MAX_PLY)
|
2008-09-06 10:25:58 -06:00
|
|
|
{
|
2009-12-09 06:40:38 -07:00
|
|
|
// Move count based pruning
|
2013-03-04 01:38:58 -07:00
|
|
|
if ( depth < 16 * ONE_PLY
|
2014-09-29 06:08:56 -06:00
|
|
|
&& moveCount >= FutilityMoveCounts[improving][depth])
|
2008-09-06 10:25:58 -06:00
|
|
|
continue;
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2015-10-21 16:21:23 -06:00
|
|
|
// History Score Pruning
|
|
|
|
if ( depth <= 3 * ONE_PLY
|
|
|
|
&& thisThread->History[pos.moved_piece(move)][to_sq(move)] < VALUE_ZERO
|
|
|
|
&& CounterMovesHistory[pos.piece_on(prevMoveSq)][prevMoveSq]
|
|
|
|
[pos.moved_piece(move)][to_sq(move)] < VALUE_ZERO)
|
|
|
|
continue;
|
|
|
|
|
2013-11-10 07:53:23 -07:00
|
|
|
predictedDepth = newDepth - reduction<PvNode>(improving, depth, moveCount);
|
2013-11-07 14:29:07 -07:00
|
|
|
|
2013-11-08 03:42:22 -07:00
|
|
|
// Futility pruning: parent node
|
|
|
|
if (predictedDepth < 7 * ONE_PLY)
|
2013-11-07 14:29:07 -07:00
|
|
|
{
|
2015-06-24 21:15:09 -06:00
|
|
|
futilityValue = ss->staticEval + futility_margin(predictedDepth) + 256;
|
2013-11-07 14:29:07 -07:00
|
|
|
|
2013-11-08 03:42:22 -07:00
|
|
|
if (futilityValue <= alpha)
|
2013-11-07 14:29:07 -07:00
|
|
|
{
|
2013-11-08 03:42:22 -07:00
|
|
|
bestValue = std::max(bestValue, futilityValue);
|
|
|
|
continue;
|
2013-11-07 14:29:07 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-24 07:25:11 -07:00
|
|
|
// Prune moves with negative SEE at low depths
|
2014-02-16 05:06:31 -07:00
|
|
|
if (predictedDepth < 4 * ONE_PLY && pos.see_sign(move) < VALUE_ZERO)
|
2010-11-30 05:46:41 -07:00
|
|
|
continue;
|
2008-08-31 23:59:13 -06:00
|
|
|
}
|
|
|
|
|
2014-10-03 22:07:55 -06:00
|
|
|
// Speculative prefetch as early as possible
|
2015-02-07 11:13:41 -07:00
|
|
|
prefetch(TT.first_entry(pos.key_after(move)));
|
2014-10-02 15:19:14 -06:00
|
|
|
|
2013-12-02 11:04:09 -07:00
|
|
|
// Check for legality just before making the move
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
if (!RootNode && !pos.legal(move, ci.pinned))
|
2011-05-28 03:35:52 -06:00
|
|
|
{
|
2015-07-28 04:53:13 -06:00
|
|
|
ss->moveCount = --moveCount;
|
2011-05-23 07:14:47 -06:00
|
|
|
continue;
|
2011-05-28 03:35:52 -06:00
|
|
|
}
|
2011-05-23 07:14:47 -06:00
|
|
|
|
|
|
|
ss->currentMove = move;
|
|
|
|
|
2011-05-21 10:17:11 -06:00
|
|
|
// Step 14. Make the move
|
Compute checkers from scratch
This micro-optimization only complicates the code and provides no benefit.
Removing it is even a speedup on my machine (i7-3770k, linux, gcc 4.9.1):
stat test master diff
mean 2,403,118 2,390,904 12,214
stdev 12,043 10,620 3,677
speedup 0.51%
P(speedup>0) 100.0%
No functional change.
2015-02-15 00:49:20 -07:00
|
|
|
pos.do_move(move, st, givesCheck);
|
2008-09-03 15:33:49 -06:00
|
|
|
|
2013-12-04 23:18:12 -07:00
|
|
|
// Step 15. Reduced depth search (LMR). If the move fails high it will be
|
2011-11-19 05:55:26 -07:00
|
|
|
// re-searched at full depth.
|
2013-09-07 01:20:22 -06:00
|
|
|
if ( depth >= 3 * ONE_PLY
|
2014-11-07 14:40:24 -07:00
|
|
|
&& moveCount > 1
|
2011-11-19 05:55:26 -07:00
|
|
|
&& !captureOrPromotion
|
2013-02-03 03:14:21 -07:00
|
|
|
&& move != ss->killers[0]
|
|
|
|
&& move != ss->killers[1])
|
2008-09-06 10:25:58 -06:00
|
|
|
{
|
2013-08-08 02:28:48 -06:00
|
|
|
ss->reduction = reduction<PvNode>(improving, depth, moveCount);
|
2013-06-13 11:50:32 -06:00
|
|
|
|
2014-09-25 12:22:39 -06:00
|
|
|
if ( (!PvNode && cutNode)
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
|| ( thisThread->History[pos.piece_on(to_sq(move))][to_sq(move)] < VALUE_ZERO
|
2015-05-01 18:36:39 -06:00
|
|
|
&& CounterMovesHistory[pos.piece_on(prevMoveSq)][prevMoveSq]
|
|
|
|
[pos.piece_on(to_sq(move))][to_sq(move)] <= VALUE_ZERO))
|
2013-06-13 11:50:32 -06:00
|
|
|
ss->reduction += ONE_PLY;
|
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
if ( thisThread->History[pos.piece_on(to_sq(move))][to_sq(move)] > VALUE_ZERO
|
2015-07-16 00:17:40 -06:00
|
|
|
&& CounterMovesHistory[pos.piece_on(prevMoveSq)][prevMoveSq]
|
|
|
|
[pos.piece_on(to_sq(move))][to_sq(move)] > VALUE_ZERO)
|
2013-09-23 00:03:12 -06:00
|
|
|
ss->reduction = std::max(DEPTH_ZERO, ss->reduction - ONE_PLY);
|
2013-05-19 13:32:52 -06:00
|
|
|
|
2014-06-03 03:32:45 -06:00
|
|
|
// Decrease reduction for moves that escape a capture
|
|
|
|
if ( ss->reduction
|
2014-06-03 04:38:58 -06:00
|
|
|
&& type_of(move) == NORMAL
|
2014-06-03 03:32:45 -06:00
|
|
|
&& type_of(pos.piece_on(to_sq(move))) != PAWN
|
2015-01-13 14:07:18 -07:00
|
|
|
&& pos.see(make_move(to_sq(move), from_sq(move))) < VALUE_ZERO)
|
2014-06-03 03:32:45 -06:00
|
|
|
ss->reduction = std::max(DEPTH_ZERO, ss->reduction - ONE_PLY);
|
|
|
|
|
2012-01-15 01:54:27 -07:00
|
|
|
Depth d = std::max(newDepth - ss->reduction, ONE_PLY);
|
2011-06-25 07:31:57 -06:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, d, true);
|
2011-06-25 07:31:57 -06:00
|
|
|
|
2011-11-19 05:55:26 -07:00
|
|
|
doFullDepthSearch = (value > alpha && ss->reduction != DEPTH_ZERO);
|
|
|
|
ss->reduction = DEPTH_ZERO;
|
|
|
|
}
|
|
|
|
else
|
2014-11-08 03:39:38 -07:00
|
|
|
doFullDepthSearch = !PvNode || moveCount > 1;
|
2010-05-08 02:54:51 -06:00
|
|
|
|
2011-11-19 05:55:26 -07:00
|
|
|
// Step 16. Full depth search, when LMR is skipped or fails high
|
|
|
|
if (doFullDepthSearch)
|
2014-09-29 06:08:56 -06:00
|
|
|
value = newDepth < ONE_PLY ?
|
|
|
|
givesCheck ? -qsearch<NonPV, true>(pos, ss+1, -(alpha+1), -alpha, DEPTH_ZERO)
|
|
|
|
: -qsearch<NonPV, false>(pos, ss+1, -(alpha+1), -alpha, DEPTH_ZERO)
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
: - search<NonPV>(pos, ss+1, -(alpha+1), -alpha, newDepth, !cutNode);
|
2010-02-24 03:55:58 -07:00
|
|
|
|
2013-12-02 11:04:09 -07:00
|
|
|
// For PV nodes only, do a full PV search on the first move or after a fail
|
|
|
|
// high (in the latter case search only if value < beta), otherwise let the
|
2013-12-02 10:39:26 -07:00
|
|
|
// parent node fail low with value <= alpha and to try another move.
|
2014-11-18 03:57:57 -07:00
|
|
|
if (PvNode && (moveCount == 1 || (value > alpha && (RootNode || value < beta))))
|
|
|
|
{
|
|
|
|
(ss+1)->pv = pv;
|
2014-11-21 01:10:52 -07:00
|
|
|
(ss+1)->pv[0] = MOVE_NONE;
|
|
|
|
|
2014-09-29 06:08:56 -06:00
|
|
|
value = newDepth < ONE_PLY ?
|
|
|
|
givesCheck ? -qsearch<PV, true>(pos, ss+1, -beta, -alpha, DEPTH_ZERO)
|
|
|
|
: -qsearch<PV, false>(pos, ss+1, -beta, -alpha, DEPTH_ZERO)
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
: - search<PV>(pos, ss+1, -beta, -alpha, newDepth, false);
|
2014-11-12 14:13:55 -07:00
|
|
|
}
|
2014-11-18 03:57:57 -07:00
|
|
|
|
2011-05-21 10:17:11 -06:00
|
|
|
// Step 17. Undo move
|
2009-02-22 09:49:52 -07:00
|
|
|
pos.undo_move(move);
|
2008-08-31 23:59:13 -06:00
|
|
|
|
|
|
|
assert(value > -VALUE_INFINITE && value < VALUE_INFINITE);
|
2008-09-03 15:33:49 -06:00
|
|
|
|
2011-05-21 10:17:11 -06:00
|
|
|
// Step 18. Check for new best move
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
// Finished searching the move. If a stop occurred, the return value of
|
|
|
|
// the search cannot be trusted, and we return immediately without
|
2014-05-01 00:28:49 -06:00
|
|
|
// updating best move, PV and TT.
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
if (Signals.stop)
|
2014-05-01 08:25:17 -06:00
|
|
|
return VALUE_ZERO;
|
2013-08-15 01:36:26 -06:00
|
|
|
|
2012-10-03 06:11:20 -06:00
|
|
|
if (RootNode)
|
2011-01-16 04:02:32 -07:00
|
|
|
{
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
RootMove& rm = *std::find(thisThread->rootMoves.begin(), thisThread->rootMoves.end(), move);
|
2011-01-16 04:02:32 -07:00
|
|
|
|
2011-02-17 01:24:55 -07:00
|
|
|
// PV move or new best move ?
|
2014-11-08 03:39:38 -07:00
|
|
|
if (moveCount == 1 || value > alpha)
|
2011-01-16 04:02:32 -07:00
|
|
|
{
|
2011-12-12 09:55:20 -07:00
|
|
|
rm.score = value;
|
2014-11-12 14:13:55 -07:00
|
|
|
rm.pv.resize(1);
|
2014-11-21 01:10:52 -07:00
|
|
|
|
|
|
|
assert((ss+1)->pv);
|
|
|
|
|
|
|
|
for (Move* m = (ss+1)->pv; *m != MOVE_NONE; ++m)
|
|
|
|
rm.pv.push_back(*m);
|
2011-01-16 04:02:32 -07:00
|
|
|
|
|
|
|
// We record how often the best move has been changed in each
|
2011-02-12 11:04:27 -07:00
|
|
|
// iteration. This information is used for time management: When
|
2011-01-16 04:02:32 -07:00
|
|
|
// the best move changes frequently, we allocate some more time.
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
if (moveCount > 1 && thisThread == Threads.main())
|
2013-10-02 22:01:38 -06:00
|
|
|
++BestMoveChanges;
|
2011-02-17 01:24:55 -07:00
|
|
|
}
|
|
|
|
else
|
2013-12-02 11:04:09 -07:00
|
|
|
// All other moves but the PV are set to the lowest value: this is
|
|
|
|
// not a problem when sorting because the sort is stable and the
|
|
|
|
// move position in the list is preserved - just the PV is pushed up.
|
2011-12-12 09:55:20 -07:00
|
|
|
rm.score = -VALUE_INFINITE;
|
2011-12-10 11:14:13 -07:00
|
|
|
}
|
2011-01-16 04:02:32 -07:00
|
|
|
|
2011-08-06 02:15:46 -06:00
|
|
|
if (value > bestValue)
|
|
|
|
{
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
bestValue = value;
|
2011-08-06 02:15:46 -06:00
|
|
|
|
2012-10-03 06:11:20 -06:00
|
|
|
if (value > alpha)
|
2012-10-01 01:33:13 -06:00
|
|
|
{
|
2015-03-18 01:12:59 -06:00
|
|
|
// If there is an easy move for this position, clear it if unstable
|
|
|
|
if ( PvNode
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
&& thisThread == Threads.main()
|
2015-03-18 01:12:59 -06:00
|
|
|
&& EasyMove.get(pos.key())
|
|
|
|
&& (move != EasyMove.get(pos.key()) || moveCount > 1))
|
|
|
|
EasyMove.clear();
|
2015-03-12 13:49:30 -06:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
bestMove = move;
|
2012-10-03 06:11:20 -06:00
|
|
|
|
2014-11-21 01:10:52 -07:00
|
|
|
if (PvNode && !RootNode) // Update pv even in fail-high case
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
update_pv(ss->pv, move, (ss+1)->pv);
|
2014-11-12 14:13:55 -07:00
|
|
|
|
2013-01-13 04:34:31 -07:00
|
|
|
if (PvNode && value < beta) // Update alpha! Always alpha < beta
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
alpha = value;
|
2012-11-17 04:44:19 -07:00
|
|
|
else
|
2012-10-05 07:00:35 -06:00
|
|
|
{
|
2012-11-17 04:44:19 -07:00
|
|
|
assert(value >= beta); // Fail high
|
2012-10-05 07:00:35 -06:00
|
|
|
break;
|
|
|
|
}
|
2011-08-06 02:15:46 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
if (!captureOrPromotion && move != bestMove && quietCount < 64)
|
2015-04-10 13:32:39 -06:00
|
|
|
quietsSearched[quietCount++] = move;
|
2008-08-31 23:59:13 -06:00
|
|
|
}
|
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
// Following condition would detect a stop only after move loop has been
|
|
|
|
// completed. But in this case bestValue is valid because we have fully
|
|
|
|
// searched our subtree, and we can anyhow save the result in TT.
|
2014-05-01 00:28:49 -06:00
|
|
|
/*
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
if (Signals.stop)
|
2014-05-01 00:28:49 -06:00
|
|
|
return VALUE_DRAW;
|
|
|
|
*/
|
|
|
|
|
2011-05-21 10:17:11 -06:00
|
|
|
// Step 20. Check for mate and stalemate
|
2011-10-18 04:24:47 -06:00
|
|
|
// All legal moves have been searched and if there are no legal moves, it
|
2014-05-01 00:28:49 -06:00
|
|
|
// must be mate or stalemate. If we are in a singular extension search then
|
|
|
|
// return a fail low score.
|
2012-10-03 06:11:20 -06:00
|
|
|
if (!moveCount)
|
2014-05-11 02:56:25 -06:00
|
|
|
bestValue = excludedMove ? alpha
|
|
|
|
: inCheck ? mated_in(ss->ply) : DrawValue[pos.side_to_move()];
|
|
|
|
|
2015-03-28 16:09:48 -06:00
|
|
|
// Quiet best move: update killers, history and countermoves
|
2015-04-11 15:21:52 -06:00
|
|
|
else if (bestMove && !pos.capture_or_promotion(bestMove))
|
2015-04-10 13:32:39 -06:00
|
|
|
update_stats(pos, ss, bestMove, depth, quietsSearched, quietCount);
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2015-10-12 15:00:54 -06:00
|
|
|
// Bonus for prior countermove that caused the fail low
|
|
|
|
else if (!bestMove)
|
|
|
|
{
|
|
|
|
if (is_ok((ss - 2)->currentMove) && is_ok((ss - 1)->currentMove) && !pos.captured_piece_type() && !inCheck && depth>=3*ONE_PLY)
|
|
|
|
{
|
|
|
|
Value bonus = Value((depth / ONE_PLY) * (depth / ONE_PLY));
|
|
|
|
Square prevSq = to_sq((ss - 1)->currentMove);
|
|
|
|
Square prevPrevSq = to_sq((ss - 2)->currentMove);
|
|
|
|
HistoryStats& flMoveCmh = CounterMovesHistory[pos.piece_on(prevPrevSq)][prevPrevSq];
|
|
|
|
flMoveCmh.updateCMH(pos.piece_on(prevSq), prevSq, bonus);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-13 00:16:35 -07:00
|
|
|
tte->save(posKey, value_to_tt(bestValue, ss->ply),
|
|
|
|
bestValue >= beta ? BOUND_LOWER :
|
|
|
|
PvNode && bestMove ? BOUND_EXACT : BOUND_UPPER,
|
2014-12-13 01:27:39 -07:00
|
|
|
depth, bestMove, ss->staticEval, TT.generation());
|
2010-05-08 02:54:51 -06:00
|
|
|
|
2009-03-22 07:49:18 -06:00
|
|
|
assert(bestValue > -VALUE_INFINITE && bestValue < VALUE_INFINITE);
|
|
|
|
|
2008-08-31 23:59:13 -06:00
|
|
|
return bestValue;
|
|
|
|
}
|
2008-09-03 15:33:49 -06:00
|
|
|
|
2011-12-10 11:14:13 -07:00
|
|
|
|
2008-08-31 23:59:13 -06:00
|
|
|
// qsearch() is the quiescence search function, which is called by the main
|
|
|
|
// search function when the remaining depth is zero (or, to be more precise,
|
2010-08-18 07:23:19 -06:00
|
|
|
// less than ONE_PLY).
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2012-11-01 07:49:54 -06:00
|
|
|
template <NodeType NT, bool InCheck>
|
2011-12-04 03:46:31 -07:00
|
|
|
Value qsearch(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth) {
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2014-05-04 05:11:32 -06:00
|
|
|
const bool PvNode = NT == PV;
|
2011-05-28 05:13:42 -06:00
|
|
|
|
|
|
|
assert(NT == PV || NT == NonPV);
|
2012-12-25 09:59:35 -07:00
|
|
|
assert(InCheck == !!pos.checkers());
|
2011-12-26 17:00:44 -07:00
|
|
|
assert(alpha >= -VALUE_INFINITE && alpha < beta && beta <= VALUE_INFINITE);
|
2012-10-07 01:34:04 -06:00
|
|
|
assert(PvNode || (alpha == beta - 1));
|
2011-12-26 17:00:44 -07:00
|
|
|
assert(depth <= DEPTH_ZERO);
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2014-11-18 03:57:57 -07:00
|
|
|
Move pv[MAX_PLY+1];
|
2009-11-05 03:11:02 -07:00
|
|
|
StateInfo st;
|
2014-12-13 00:16:35 -07:00
|
|
|
TTEntry* tte;
|
2012-10-07 01:34:04 -06:00
|
|
|
Key posKey;
|
|
|
|
Move ttMove, move, bestMove;
|
2012-12-15 03:11:38 -07:00
|
|
|
Value bestValue, value, ttValue, futilityValue, futilityBase, oldAlpha;
|
2014-12-13 01:27:39 -07:00
|
|
|
bool ttHit, givesCheck, evasionPrunable;
|
2010-12-18 02:27:24 -07:00
|
|
|
Depth ttDepth;
|
2009-11-05 03:11:02 -07:00
|
|
|
|
2014-11-18 03:57:57 -07:00
|
|
|
if (PvNode)
|
|
|
|
{
|
|
|
|
oldAlpha = alpha; // To flag BOUND_EXACT when eval above alpha and no available moves
|
|
|
|
(ss+1)->pv = pv;
|
|
|
|
ss->pv[0] = MOVE_NONE;
|
2014-11-12 14:13:55 -07:00
|
|
|
}
|
|
|
|
|
2012-02-20 06:21:25 -07:00
|
|
|
ss->currentMove = bestMove = MOVE_NONE;
|
2011-04-16 07:41:53 -06:00
|
|
|
ss->ply = (ss-1)->ply + 1;
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2013-12-02 11:04:09 -07:00
|
|
|
// Check for an instant draw or if the maximum ply has been reached
|
Cleanup MAX_PLY
This area has become obscure and tricky over the course of incremental
changes that did not respect the original's consistency and clarity. Now,
it's not clear why we use MAX_PLY = 120, or why we use MAX_PLY+6, among
other things.
This patch does the following:
* ID loop: depth ranges from 1 to MAX_PLY-1, and due to TT constraint (depth
must fit into an int8_t), MAX_PLY should be 128.
* stack[]: plies now range from 0 to MAX_PLY-1, hence stack[MAX_PLY+4],
because of the extra 2+2 padding elements (for ss-2 and ss+2). Document this
better, while we're at it.
* Enforce 0 <= ply < MAX_PLY:
- stop condition is now ss->ply >= MAX_PLY and not ss->ply > MAX_PLY.
- assert(ss->ply < MAX_PLY), before using ss+1 and ss+2.
- as a result, we don't need the artificial MAX_PLY+6 range. Instead we
can use MAX_PLY+4 and it's clear why (for ss-2 and ss+2).
* fix: extract_pv_from_tt() and insert_pv_in_tt() had no reason to use
MAX_PLY_PLUS_6, because the array is indexed by plies, so the range of
available plies applies (0..MAX_PLY before, and now 0..MAX_PLY-1).
Tested with debug compile, using MAX_PLY=16, and running bench at depth 17,
using 1 and 7 threads. No assert() fired. Feel free to submit to more severe
crash-tests, if you can think of any.
No functional change.
2014-11-03 08:36:24 -07:00
|
|
|
if (pos.is_draw() || ss->ply >= MAX_PLY)
|
|
|
|
return ss->ply >= MAX_PLY && !InCheck ? evaluate(pos) : DrawValue[pos.side_to_move()];
|
|
|
|
|
|
|
|
assert(0 <= ss->ply && ss->ply < MAX_PLY);
|
2011-07-19 20:31:50 -06:00
|
|
|
|
2013-12-02 11:04:09 -07:00
|
|
|
// Decide whether or not to include checks: this fixes also the type of
|
2013-03-11 08:18:15 -06:00
|
|
|
// TT entry depth that we are going to use. Note that in qsearch we use
|
|
|
|
// only two types of depth in TT: DEPTH_QS_CHECKS or DEPTH_QS_NO_CHECKS.
|
|
|
|
ttDepth = InCheck || depth >= DEPTH_QS_CHECKS ? DEPTH_QS_CHECKS
|
|
|
|
: DEPTH_QS_NO_CHECKS;
|
|
|
|
|
2013-06-30 05:12:04 -06:00
|
|
|
// Transposition table lookup
|
2012-10-07 01:34:04 -06:00
|
|
|
posKey = pos.key();
|
2014-12-13 00:16:35 -07:00
|
|
|
tte = TT.probe(posKey, ttHit);
|
|
|
|
ttMove = ttHit ? tte->move() : MOVE_NONE;
|
|
|
|
ttValue = ttHit ? value_from_tt(tte->value(), ss->ply) : VALUE_NONE;
|
2012-10-07 01:34:04 -06:00
|
|
|
|
2014-11-18 03:57:57 -07:00
|
|
|
if ( !PvNode
|
2014-12-13 00:16:35 -07:00
|
|
|
&& ttHit
|
2012-12-15 03:11:38 -07:00
|
|
|
&& tte->depth() >= ttDepth
|
|
|
|
&& ttValue != VALUE_NONE // Only in case of TT access race
|
2014-11-12 14:13:55 -07:00
|
|
|
&& (ttValue >= beta ? (tte->bound() & BOUND_LOWER)
|
|
|
|
: (tte->bound() & BOUND_UPPER)))
|
2009-03-21 07:51:31 -06:00
|
|
|
{
|
2012-12-15 03:11:38 -07:00
|
|
|
ss->currentMove = ttMove; // Can be MOVE_NONE
|
|
|
|
return ttValue;
|
2009-03-21 07:51:31 -06:00
|
|
|
}
|
2008-09-08 23:37:46 -06:00
|
|
|
|
2009-11-28 03:52:13 -07:00
|
|
|
// Evaluate the position statically
|
2012-11-01 07:49:54 -06:00
|
|
|
if (InCheck)
|
2010-05-22 02:56:46 -06:00
|
|
|
{
|
2013-11-08 03:42:22 -07:00
|
|
|
ss->staticEval = VALUE_NONE;
|
2010-06-03 11:29:48 -06:00
|
|
|
bestValue = futilityBase = -VALUE_INFINITE;
|
2010-05-22 02:56:46 -06:00
|
|
|
}
|
2009-03-24 08:48:14 -06:00
|
|
|
else
|
2010-01-21 08:58:00 -07:00
|
|
|
{
|
2014-12-13 00:16:35 -07:00
|
|
|
if (ttHit)
|
2012-12-27 04:13:31 -07:00
|
|
|
{
|
2012-12-31 08:28:40 -07:00
|
|
|
// Never assume anything on values stored in TT
|
2015-01-09 04:35:44 -07:00
|
|
|
if ((ss->staticEval = bestValue = tte->eval()) == VALUE_NONE)
|
2014-06-06 01:35:34 -06:00
|
|
|
ss->staticEval = bestValue = evaluate(pos);
|
2013-10-07 01:10:48 -06:00
|
|
|
|
|
|
|
// Can ttValue be used as a better position evaluation?
|
|
|
|
if (ttValue != VALUE_NONE)
|
|
|
|
if (tte->bound() & (ttValue > bestValue ? BOUND_LOWER : BOUND_UPPER))
|
|
|
|
bestValue = ttValue;
|
2012-12-27 04:13:31 -07:00
|
|
|
}
|
2012-12-01 10:06:29 -07:00
|
|
|
else
|
2014-06-06 03:12:05 -06:00
|
|
|
ss->staticEval = bestValue =
|
|
|
|
(ss-1)->currentMove != MOVE_NULL ? evaluate(pos) : -(ss-1)->staticEval + 2 * Eval::Tempo;
|
2010-01-21 08:58:00 -07:00
|
|
|
|
2010-06-03 11:29:48 -06:00
|
|
|
// Stand pat. Return immediately if static value is at least beta
|
|
|
|
if (bestValue >= beta)
|
|
|
|
{
|
2014-12-13 00:16:35 -07:00
|
|
|
if (!ttHit)
|
|
|
|
tte->save(pos.key(), value_to_tt(bestValue, ss->ply), BOUND_LOWER,
|
2014-12-13 01:27:39 -07:00
|
|
|
DEPTH_NONE, MOVE_NONE, ss->staticEval, TT.generation());
|
2010-06-04 01:46:38 -06:00
|
|
|
|
2010-06-03 11:29:48 -06:00
|
|
|
return bestValue;
|
|
|
|
}
|
2009-03-27 08:30:45 -06:00
|
|
|
|
2010-06-03 11:29:48 -06:00
|
|
|
if (PvNode && bestValue > alpha)
|
|
|
|
alpha = bestValue;
|
2008-09-07 00:31:30 -06:00
|
|
|
|
2014-04-27 02:13:59 -06:00
|
|
|
futilityBase = bestValue + 128;
|
2010-06-03 11:29:48 -06:00
|
|
|
}
|
2010-01-19 07:24:26 -07:00
|
|
|
|
2008-08-31 23:59:13 -06:00
|
|
|
// Initialize a MovePicker object for the current position, and prepare
|
2010-01-19 07:24:26 -07:00
|
|
|
// to search the moves. Because the depth is <= 0 here, only captures,
|
2010-12-18 02:27:24 -07:00
|
|
|
// queen promotions and checks (only if depth >= DEPTH_QS_CHECKS) will
|
|
|
|
// be generated.
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
MovePicker mp(pos, ttMove, depth, pos.this_thread()->History, CounterMovesHistory, to_sq((ss-1)->currentMove));
|
2009-11-09 12:54:45 -07:00
|
|
|
CheckInfo ci(pos);
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2010-03-24 03:15:00 -06:00
|
|
|
// Loop through the moves until no moves remain or a beta cutoff occurs
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
while ((move = mp.next_move()) != MOVE_NONE)
|
2008-09-07 00:31:30 -06:00
|
|
|
{
|
2011-10-03 02:56:49 -06:00
|
|
|
assert(is_ok(move));
|
2008-09-07 00:31:30 -06:00
|
|
|
|
2014-02-08 05:21:50 -07:00
|
|
|
givesCheck = type_of(move) == NORMAL && !ci.dcCandidates
|
2015-05-09 03:09:06 -06:00
|
|
|
? ci.checkSquares[type_of(pos.piece_on(from_sq(move)))] & to_sq(move)
|
2014-02-08 05:21:50 -07:00
|
|
|
: pos.gives_check(move, ci);
|
2010-01-08 03:45:46 -07:00
|
|
|
|
2008-08-31 23:59:13 -06:00
|
|
|
// Futility pruning
|
2015-01-14 13:18:41 -07:00
|
|
|
if ( !InCheck
|
2011-04-29 08:26:48 -06:00
|
|
|
&& !givesCheck
|
2013-08-24 02:05:48 -06:00
|
|
|
&& futilityBase > -VALUE_KNOWN_WIN
|
2013-12-03 14:58:39 -07:00
|
|
|
&& !pos.advanced_pawn_push(move))
|
2008-09-07 00:31:30 -06:00
|
|
|
{
|
2013-12-04 08:49:01 -07:00
|
|
|
assert(type_of(move) != ENPASSANT); // Due to !pos.advanced_pawn_push
|
|
|
|
|
|
|
|
futilityValue = futilityBase + PieceValue[EG][pos.piece_on(to_sq(move))];
|
2008-09-07 00:31:30 -06:00
|
|
|
|
2015-01-14 13:18:41 -07:00
|
|
|
if (futilityValue <= alpha)
|
2008-09-07 00:31:30 -06:00
|
|
|
{
|
2012-11-26 08:13:36 -07:00
|
|
|
bestValue = std::max(bestValue, futilityValue);
|
2008-09-07 00:31:30 -06:00
|
|
|
continue;
|
|
|
|
}
|
2011-02-22 15:23:45 -07:00
|
|
|
|
2015-01-14 13:18:41 -07:00
|
|
|
if (futilityBase <= alpha && pos.see(move) <= VALUE_ZERO)
|
2012-11-26 08:13:36 -07:00
|
|
|
{
|
|
|
|
bestValue = std::max(bestValue, futilityBase);
|
2011-02-22 15:23:45 -07:00
|
|
|
continue;
|
2012-11-26 08:13:36 -07:00
|
|
|
}
|
2008-08-31 23:59:13 -06:00
|
|
|
}
|
|
|
|
|
2013-12-02 11:04:09 -07:00
|
|
|
// Detect non-capture evasions that are candidates to be pruned
|
2013-07-13 05:27:22 -06:00
|
|
|
evasionPrunable = InCheck
|
2012-04-28 04:08:10 -06:00
|
|
|
&& bestValue > VALUE_MATED_IN_MAX_PLY
|
2015-04-03 18:00:15 -06:00
|
|
|
&& !pos.capture(move);
|
2010-01-20 03:40:33 -07:00
|
|
|
|
|
|
|
// Don't search moves with negative SEE values
|
2015-01-14 13:18:41 -07:00
|
|
|
if ( (!InCheck || evasionPrunable)
|
2012-06-24 03:08:16 -06:00
|
|
|
&& type_of(move) != PROMOTION
|
2014-02-16 05:06:31 -07:00
|
|
|
&& pos.see_sign(move) < VALUE_ZERO)
|
2008-09-07 00:31:30 -06:00
|
|
|
continue;
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2014-10-03 22:07:55 -06:00
|
|
|
// Speculative prefetch as early as possible
|
2015-02-07 11:13:41 -07:00
|
|
|
prefetch(TT.first_entry(pos.key_after(move)));
|
2014-10-02 15:19:14 -06:00
|
|
|
|
2013-12-02 11:04:09 -07:00
|
|
|
// Check for legality just before making the move
|
2013-09-28 06:43:50 -06:00
|
|
|
if (!pos.legal(move, ci.pinned))
|
2011-05-23 07:14:47 -06:00
|
|
|
continue;
|
|
|
|
|
2010-06-03 11:29:48 -06:00
|
|
|
ss->currentMove = move;
|
|
|
|
|
2009-11-05 03:11:02 -07:00
|
|
|
// Make and search the move
|
Compute checkers from scratch
This micro-optimization only complicates the code and provides no benefit.
Removing it is even a speedup on my machine (i7-3770k, linux, gcc 4.9.1):
stat test master diff
mean 2,403,118 2,390,904 12,214
stdev 12,043 10,620 3,677
speedup 0.51%
P(speedup>0) 100.0%
No functional change.
2015-02-15 00:49:20 -07:00
|
|
|
pos.do_move(move, st, givesCheck);
|
2012-11-01 07:49:54 -06:00
|
|
|
value = givesCheck ? -qsearch<NT, true>(pos, ss+1, -beta, -alpha, depth - ONE_PLY)
|
|
|
|
: -qsearch<NT, false>(pos, ss+1, -beta, -alpha, depth - ONE_PLY);
|
2009-02-22 09:49:52 -07:00
|
|
|
pos.undo_move(move);
|
2008-08-31 23:59:13 -06:00
|
|
|
|
|
|
|
assert(value > -VALUE_INFINITE && value < VALUE_INFINITE);
|
|
|
|
|
2012-10-07 01:34:04 -06:00
|
|
|
// Check for new best move
|
2008-09-07 00:31:30 -06:00
|
|
|
if (value > bestValue)
|
|
|
|
{
|
|
|
|
bestValue = value;
|
2011-08-07 03:29:47 -06:00
|
|
|
|
2012-10-07 01:34:04 -06:00
|
|
|
if (value > alpha)
|
|
|
|
{
|
2014-11-21 01:10:52 -07:00
|
|
|
if (PvNode) // Update pv even in fail-high case
|
2014-11-18 03:57:57 -07:00
|
|
|
update_pv(ss->pv, move, (ss+1)->pv);
|
2014-11-12 14:13:55 -07:00
|
|
|
|
2012-10-07 01:34:04 -06:00
|
|
|
if (PvNode && value < beta) // Update alpha here! Always alpha < beta
|
|
|
|
{
|
|
|
|
alpha = value;
|
|
|
|
bestMove = move;
|
|
|
|
}
|
|
|
|
else // Fail high
|
|
|
|
{
|
2014-12-13 00:16:35 -07:00
|
|
|
tte->save(posKey, value_to_tt(value, ss->ply), BOUND_LOWER,
|
2014-12-13 01:27:39 -07:00
|
|
|
ttDepth, move, ss->staticEval, TT.generation());
|
2012-12-27 04:13:31 -07:00
|
|
|
|
2012-10-07 01:34:04 -06:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
}
|
2008-09-07 00:31:30 -06:00
|
|
|
}
|
2008-08-31 23:59:13 -06:00
|
|
|
}
|
|
|
|
|
2010-01-08 03:45:46 -07:00
|
|
|
// All legal moves have been searched. A special case: If we're in check
|
2009-06-11 07:57:42 -06:00
|
|
|
// and no legal moves were found, it is checkmate.
|
2012-11-01 07:49:54 -06:00
|
|
|
if (InCheck && bestValue == -VALUE_INFINITE)
|
2011-12-28 05:22:09 -07:00
|
|
|
return mated_in(ss->ply); // Plies to mate from the root
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2014-12-13 00:16:35 -07:00
|
|
|
tte->save(posKey, value_to_tt(bestValue, ss->ply),
|
|
|
|
PvNode && bestValue > oldAlpha ? BOUND_EXACT : BOUND_UPPER,
|
2014-12-13 01:27:39 -07:00
|
|
|
ttDepth, bestMove, ss->staticEval, TT.generation());
|
2009-09-18 02:32:57 -06:00
|
|
|
|
2010-01-08 03:45:46 -07:00
|
|
|
assert(bestValue > -VALUE_INFINITE && bestValue < VALUE_INFINITE);
|
2009-04-18 07:03:33 -06:00
|
|
|
|
2008-08-31 23:59:13 -06:00
|
|
|
return bestValue;
|
|
|
|
}
|
|
|
|
|
2010-12-14 06:49:06 -07:00
|
|
|
|
2012-10-27 06:25:31 -06:00
|
|
|
// value_to_tt() adjusts a mate score from "plies to mate from the root" to
|
|
|
|
// "plies to mate from the current position". Non-mate scores are unchanged.
|
2013-12-02 11:04:09 -07:00
|
|
|
// The function is called before storing a value in the transposition table.
|
2012-10-27 06:25:31 -06:00
|
|
|
|
|
|
|
Value value_to_tt(Value v, int ply) {
|
|
|
|
|
|
|
|
assert(v != VALUE_NONE);
|
|
|
|
|
|
|
|
return v >= VALUE_MATE_IN_MAX_PLY ? v + ply
|
|
|
|
: v <= VALUE_MATED_IN_MAX_PLY ? v - ply : v;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// value_from_tt() is the inverse of value_to_tt(): It adjusts a mate score
|
2013-12-02 11:04:09 -07:00
|
|
|
// from the transposition table (which refers to the plies to mate/be mated
|
2012-10-27 06:25:31 -06:00
|
|
|
// from current position) to "plies to mate/be mated from the root".
|
|
|
|
|
|
|
|
Value value_from_tt(Value v, int ply) {
|
|
|
|
|
|
|
|
return v == VALUE_NONE ? VALUE_NONE
|
|
|
|
: v >= VALUE_MATE_IN_MAX_PLY ? v - ply
|
|
|
|
: v <= VALUE_MATED_IN_MAX_PLY ? v + ply : v;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-11-21 01:10:52 -07:00
|
|
|
// update_pv() adds current move and appends child pv[]
|
2014-11-18 03:57:57 -07:00
|
|
|
|
2014-11-21 01:10:52 -07:00
|
|
|
void update_pv(Move* pv, Move move, Move* childPv) {
|
2014-11-18 03:57:57 -07:00
|
|
|
|
2014-11-21 01:10:52 -07:00
|
|
|
for (*pv++ = move; childPv && *childPv != MOVE_NONE; )
|
|
|
|
*pv++ = *childPv++;
|
2014-11-18 03:57:57 -07:00
|
|
|
*pv = MOVE_NONE;
|
|
|
|
}
|
|
|
|
|
2014-01-05 06:08:26 -07:00
|
|
|
|
2015-04-11 15:21:52 -06:00
|
|
|
// update_stats() updates killers, history, countermove history and
|
|
|
|
// countermoves stats for a quiet best move.
|
|
|
|
|
|
|
|
void update_stats(const Position& pos, Stack* ss, Move move,
|
|
|
|
Depth depth, Move* quiets, int quietsCnt) {
|
2014-01-05 06:08:26 -07:00
|
|
|
|
|
|
|
if (ss->killers[0] != move)
|
|
|
|
{
|
|
|
|
ss->killers[1] = ss->killers[0];
|
|
|
|
ss->killers[0] = move;
|
|
|
|
}
|
|
|
|
|
2014-11-25 16:53:40 -07:00
|
|
|
Value bonus = Value((depth / ONE_PLY) * (depth / ONE_PLY));
|
2015-03-15 03:05:57 -06:00
|
|
|
|
|
|
|
Square prevSq = to_sq((ss-1)->currentMove);
|
|
|
|
HistoryStats& cmh = CounterMovesHistory[pos.piece_on(prevSq)][prevSq];
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
Thread* thisThread = pos.this_thread();
|
2015-03-15 03:05:57 -06:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
thisThread->History.updateH(pos.moved_piece(move), to_sq(move), bonus);
|
2015-01-31 02:43:47 -07:00
|
|
|
|
2015-03-15 03:05:57 -06:00
|
|
|
if (is_ok((ss-1)->currentMove))
|
2014-01-05 06:08:26 -07:00
|
|
|
{
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
thisThread->Countermoves.update(pos.piece_on(prevSq), prevSq, move);
|
2015-10-12 15:00:54 -06:00
|
|
|
cmh.updateCMH(pos.moved_piece(move), to_sq(move), bonus);
|
2014-01-05 06:08:26 -07:00
|
|
|
}
|
|
|
|
|
2015-03-15 03:05:57 -06:00
|
|
|
// Decrease all the other played quiet moves
|
|
|
|
for (int i = 0; i < quietsCnt; ++i)
|
2014-01-05 06:08:26 -07:00
|
|
|
{
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
thisThread->History.updateH(pos.moved_piece(quiets[i]), to_sq(quiets[i]), -bonus);
|
2015-03-12 01:29:57 -06:00
|
|
|
|
2015-03-15 03:05:57 -06:00
|
|
|
if (is_ok((ss-1)->currentMove))
|
2015-10-12 15:00:54 -06:00
|
|
|
cmh.updateCMH(pos.moved_piece(quiets[i]), to_sq(quiets[i]), -bonus);
|
2014-01-05 06:08:26 -07:00
|
|
|
}
|
2014-01-12 14:42:16 -07:00
|
|
|
|
2015-07-29 10:50:45 -06:00
|
|
|
// Extra penalty for PV move in previous ply when it gets refuted
|
2015-07-28 04:53:13 -06:00
|
|
|
if (is_ok((ss-2)->currentMove) && (ss-1)->moveCount == 1 && !pos.captured_piece_type())
|
2014-01-12 14:42:16 -07:00
|
|
|
{
|
2015-03-15 03:05:57 -06:00
|
|
|
Square prevPrevSq = to_sq((ss-2)->currentMove);
|
2015-03-24 23:47:40 -06:00
|
|
|
HistoryStats& ttMoveCmh = CounterMovesHistory[pos.piece_on(prevPrevSq)][prevPrevSq];
|
2015-10-12 15:00:54 -06:00
|
|
|
ttMoveCmh.updateCMH(pos.piece_on(prevSq), prevSq, -bonus - 2 * depth / ONE_PLY - 1);
|
2014-01-12 14:42:16 -07:00
|
|
|
}
|
2014-01-05 06:08:26 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-25 03:07:43 -07:00
|
|
|
// When playing with strength handicap, choose best move among a set of RootMoves
|
|
|
|
// using a statistical rule dependent on 'level'. Idea by Heinz van Saanen.
|
2010-07-15 03:00:20 -06:00
|
|
|
|
2015-01-25 03:07:43 -07:00
|
|
|
Move Skill::pick_best(size_t multiPV) {
|
2010-07-15 03:00:20 -06:00
|
|
|
|
Simpler PRNG and faster magics search
This patch replaces RKISS by a simpler and faster PRNG, xorshift64* proposed
by S. Vigna (2014). It is extremely simple, has a large enough period for
Stockfish's needs (2^64), requires no warming-up (allowing such code to be
removed), and offers slightly better randomness than MT19937.
Paper: http://xorshift.di.unimi.it/
Reference source code (public domain):
http://xorshift.di.unimi.it/xorshift64star.c
The patch also simplifies how init_magics() searches for magics:
- Old logic: seed the PRNG always with the same seed,
then use optimized bit rotations to tailor the RNG sequence per rank.
- New logic: seed the PRNG with an optimized seed per rank.
This has two advantages:
1. Less code and less computation to perform during magics search (not ROTL).
2. More choices for random sequence tuning. The old logic only let us choose
from 4096 bit rotation pairs. With the new one, we can look for the best seeds
among 2^64 values. Indeed, the set of seeds[][] provided in the patch reduces
the effort needed to find the magics:
64-bit SF:
Old logic -> 5,783,789 rand64() calls needed to find the magics
New logic -> 4,420,086 calls
32-bit SF:
Old logic -> 2,175,518 calls
New logic -> 1,895,955 calls
In the 64-bit case, init_magics() take 25 ms less to complete (Intel Core i5).
Finally, when playing with strength handicap, non-determinism is achieved
by setting the seed of the static RNG only once. Afterwards, there is no need
to skip output values.
The bench only changes because the Zobrist keys are now different (since they
are random numbers straight out of the PRNG).
The RNG seed has been carefully chosen so that the
resulting Zobrist keys are particularly well-behaved:
1. All triplets of XORed keys are unique, implying that it
would take at least 7 keys to find a 64-bit collision
(test suggested by ceebo)
2. All pairs of XORed keys are unique modulo 2^32
3. The cardinality of { (key1 ^ key2) >> 48 } is as close
as possible to the maximum (65536)
Point 2 aims at ensuring a good distribution among the bits
that determine an TT entry's cluster, likewise point 3
among the bits that form the TT entry's key16 inside a
cluster.
Details:
Bitset card(key1^key2)
------ ---------------
RKISS
key16 64894 = 99.020% of theoretical maximum
low18 180117 = 99.293%
low32 305362 = 99.997%
Xorshift64*, old seed
key16 64918 = 99.057%
low18 179994 = 99.225%
low32 305350 = 99.993%
Xorshift64*, new seed
key16 65027 = 99.223%
low18 181118 = 99.845%
low32 305371 = 100.000%
Bench: 9324905
Resolves #148
2014-12-07 17:10:57 -07:00
|
|
|
// PRNG sequence should be non-deterministic, so we seed it with the time at init
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
const Search::RootMoveVector& rootMoves = Threads.main()->rootMoves;
|
2015-02-24 04:24:53 -07:00
|
|
|
static PRNG rng(now());
|
2010-07-15 03:00:20 -06:00
|
|
|
|
2012-07-15 01:14:25 -06:00
|
|
|
// RootMoves are already sorted by score in descending order
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
int variance = std::min(rootMoves[0].score - rootMoves[multiPV - 1].score, PawnValueMg);
|
2012-10-24 04:05:20 -06:00
|
|
|
int weakness = 120 - 2 * level;
|
2014-12-07 16:53:33 -07:00
|
|
|
int maxScore = -VALUE_INFINITE;
|
2012-07-15 01:14:25 -06:00
|
|
|
|
|
|
|
// Choose best move. For each move score we add two terms both dependent on
|
2015-01-25 03:07:43 -07:00
|
|
|
// weakness. One deterministic and bigger for weaker levels, and one random,
|
2012-07-15 01:14:25 -06:00
|
|
|
// then we choose the move with the resulting highest score.
|
2015-01-25 03:07:43 -07:00
|
|
|
for (size_t i = 0; i < multiPV; ++i)
|
2012-07-15 01:14:25 -06:00
|
|
|
{
|
|
|
|
// This is our magic formula
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
int push = ( weakness * int(rootMoves[0].score - rootMoves[i].score)
|
2015-01-31 05:22:06 -07:00
|
|
|
+ variance * (rng.rand<unsigned>() % weakness)) / 128;
|
2012-07-15 01:14:25 -06:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
if (rootMoves[i].score + push > maxScore)
|
2012-07-15 01:14:25 -06:00
|
|
|
{
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
maxScore = rootMoves[i].score + push;
|
|
|
|
best = rootMoves[i].pv[0];
|
2012-07-15 01:14:25 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return best;
|
2010-07-15 03:00:20 -06:00
|
|
|
}
|
|
|
|
|
2015-01-31 03:54:25 -07:00
|
|
|
} // namespace
|
2011-01-01 06:13:15 -07:00
|
|
|
|
|
|
|
|
2015-01-31 03:54:25 -07:00
|
|
|
/// UCI::pv() formats PV information according to the UCI protocol. UCI requires
|
|
|
|
/// that all (if any) unsearched PV lines are sent using a previous search score.
|
2011-01-01 06:13:15 -07:00
|
|
|
|
2015-01-31 03:54:25 -07:00
|
|
|
string UCI::pv(const Position& pos, Depth depth, Value alpha, Value beta) {
|
2011-06-22 00:03:28 -06:00
|
|
|
|
2015-01-31 03:54:25 -07:00
|
|
|
std::stringstream ss;
|
2015-04-02 01:07:17 -06:00
|
|
|
int elapsed = Time.elapsed() + 1;
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
const Search::RootMoveVector& rootMoves = pos.this_thread()->rootMoves;
|
|
|
|
size_t PVIdx = pos.this_thread()->PVIdx;
|
|
|
|
size_t multiPV = std::min((size_t)Options["MultiPV"], rootMoves.size());
|
|
|
|
uint64_t nodes_searched = Threads.nodes_searched();
|
2011-06-22 00:03:28 -06:00
|
|
|
|
2015-01-31 03:54:25 -07:00
|
|
|
for (size_t i = 0; i < multiPV; ++i)
|
|
|
|
{
|
|
|
|
bool updated = (i <= PVIdx);
|
2011-12-14 01:21:00 -07:00
|
|
|
|
2015-01-31 03:54:25 -07:00
|
|
|
if (depth == ONE_PLY && !updated)
|
|
|
|
continue;
|
2011-12-14 01:21:00 -07:00
|
|
|
|
2015-01-31 03:54:25 -07:00
|
|
|
Depth d = updated ? depth : depth - ONE_PLY;
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
Value v = updated ? rootMoves[i].score : rootMoves[i].previousScore;
|
2015-01-18 00:05:05 -07:00
|
|
|
|
2015-01-31 03:54:25 -07:00
|
|
|
bool tb = TB::RootInTB && abs(v) < VALUE_MATE - MAX_PLY;
|
|
|
|
v = tb ? TB::Score : v;
|
2012-07-14 06:19:16 -06:00
|
|
|
|
2015-01-31 03:54:25 -07:00
|
|
|
if (ss.rdbuf()->in_avail()) // Not at first line
|
|
|
|
ss << "\n";
|
2015-01-03 02:51:38 -07:00
|
|
|
|
2015-01-31 03:54:25 -07:00
|
|
|
ss << "info"
|
|
|
|
<< " depth " << d / ONE_PLY
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
<< " seldepth " << pos.this_thread()->maxPly
|
2015-01-31 03:54:25 -07:00
|
|
|
<< " multipv " << i + 1
|
|
|
|
<< " score " << UCI::value(v);
|
2015-01-03 02:51:38 -07:00
|
|
|
|
2015-01-31 03:54:25 -07:00
|
|
|
if (!tb && i == PVIdx)
|
|
|
|
ss << (v >= beta ? " lowerbound" : v <= alpha ? " upperbound" : "");
|
2011-12-14 01:21:00 -07:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
ss << " nodes " << nodes_searched
|
|
|
|
<< " nps " << nodes_searched * 1000 / elapsed;
|
2015-01-25 00:57:51 -07:00
|
|
|
|
2015-01-31 05:04:15 -07:00
|
|
|
if (elapsed > 1000) // Earlier makes little sense
|
2015-01-31 05:22:06 -07:00
|
|
|
ss << " hashfull " << TT.hashfull();
|
2011-12-14 01:21:00 -07:00
|
|
|
|
2015-01-31 05:04:15 -07:00
|
|
|
ss << " tbhits " << TB::Hits
|
2015-01-31 03:54:25 -07:00
|
|
|
<< " time " << elapsed
|
|
|
|
<< " pv";
|
2012-07-14 06:19:16 -06:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
for (Move m : rootMoves[i].pv)
|
2015-01-31 03:54:25 -07:00
|
|
|
ss << " " << UCI::move(m, pos.is_chess960());
|
2011-06-22 00:03:28 -06:00
|
|
|
}
|
|
|
|
|
2015-01-31 03:54:25 -07:00
|
|
|
return ss.str();
|
|
|
|
}
|
2008-08-31 23:59:13 -06:00
|
|
|
|
2010-12-29 03:00:32 -07:00
|
|
|
|
2012-01-14 05:49:25 -07:00
|
|
|
/// RootMove::insert_pv_in_tt() is called at the end of a search iteration, and
|
|
|
|
/// inserts the PV back into the TT. This makes sure the old PV moves are searched
|
|
|
|
/// first, even if the old TT entries have been overwritten.
|
2010-12-29 03:00:32 -07:00
|
|
|
|
2012-01-14 05:49:25 -07:00
|
|
|
void RootMove::insert_pv_in_tt(Position& pos) {
|
2010-12-29 03:00:32 -07:00
|
|
|
|
Cleanup MAX_PLY
This area has become obscure and tricky over the course of incremental
changes that did not respect the original's consistency and clarity. Now,
it's not clear why we use MAX_PLY = 120, or why we use MAX_PLY+6, among
other things.
This patch does the following:
* ID loop: depth ranges from 1 to MAX_PLY-1, and due to TT constraint (depth
must fit into an int8_t), MAX_PLY should be 128.
* stack[]: plies now range from 0 to MAX_PLY-1, hence stack[MAX_PLY+4],
because of the extra 2+2 padding elements (for ss-2 and ss+2). Document this
better, while we're at it.
* Enforce 0 <= ply < MAX_PLY:
- stop condition is now ss->ply >= MAX_PLY and not ss->ply > MAX_PLY.
- assert(ss->ply < MAX_PLY), before using ss+1 and ss+2.
- as a result, we don't need the artificial MAX_PLY+6 range. Instead we
can use MAX_PLY+4 and it's clear why (for ss-2 and ss+2).
* fix: extract_pv_from_tt() and insert_pv_in_tt() had no reason to use
MAX_PLY_PLUS_6, because the array is indexed by plies, so the range of
available plies applies (0..MAX_PLY before, and now 0..MAX_PLY-1).
Tested with debug compile, using MAX_PLY=16, and running bench at depth 17,
using 1 and 7 threads. No assert() fired. Feel free to submit to more severe
crash-tests, if you can think of any.
No functional change.
2014-11-03 08:36:24 -07:00
|
|
|
StateInfo state[MAX_PLY], *st = state;
|
2015-01-31 04:31:00 -07:00
|
|
|
bool ttHit;
|
2010-12-29 03:00:32 -07:00
|
|
|
|
2015-01-31 04:31:00 -07:00
|
|
|
for (Move m : pv)
|
2014-11-18 03:57:57 -07:00
|
|
|
{
|
2015-01-31 04:31:00 -07:00
|
|
|
assert(MoveList<LEGAL>(pos).contains(m));
|
2010-12-29 03:00:32 -07:00
|
|
|
|
2015-01-31 04:31:00 -07:00
|
|
|
TTEntry* tte = TT.probe(pos.key(), ttHit);
|
2010-12-29 03:00:32 -07:00
|
|
|
|
2015-01-31 04:31:00 -07:00
|
|
|
if (!ttHit || tte->move() != m) // Don't overwrite correct entries
|
|
|
|
tte->save(pos.key(), VALUE_NONE, BOUND_NONE, DEPTH_NONE, m, VALUE_NONE, TT.generation());
|
2014-11-18 03:57:57 -07:00
|
|
|
|
2015-02-15 04:20:47 -07:00
|
|
|
pos.do_move(m, *st++, pos.gives_check(m, CheckInfo(pos)));
|
2014-11-12 14:13:55 -07:00
|
|
|
}
|
2010-07-18 15:01:58 -06:00
|
|
|
|
2015-01-31 04:31:00 -07:00
|
|
|
for (size_t i = pv.size(); i > 0; )
|
|
|
|
pos.undo_move(pv[--i]);
|
2012-01-14 05:49:25 -07:00
|
|
|
}
|
2010-02-13 05:38:32 -07:00
|
|
|
|
2011-08-08 05:03:16 -06:00
|
|
|
|
2015-01-20 01:13:30 -07:00
|
|
|
/// RootMove::extract_ponder_from_tt() is called in case we have no ponder move before
|
|
|
|
/// exiting the search, for instance in case we stop the search during a fail high at
|
|
|
|
/// root. We try hard to have a ponder move to return to the GUI, otherwise in case of
|
|
|
|
/// 'ponder on' we have nothing to think on.
|
|
|
|
|
2015-01-31 04:31:00 -07:00
|
|
|
bool RootMove::extract_ponder_from_tt(Position& pos)
|
2015-01-20 01:13:30 -07:00
|
|
|
{
|
|
|
|
StateInfo st;
|
2015-01-31 04:31:00 -07:00
|
|
|
bool ttHit;
|
2015-01-20 01:13:30 -07:00
|
|
|
|
|
|
|
assert(pv.size() == 1);
|
|
|
|
|
2015-02-15 04:20:47 -07:00
|
|
|
pos.do_move(pv[0], st, pos.gives_check(pv[0], CheckInfo(pos)));
|
2015-01-31 04:31:00 -07:00
|
|
|
TTEntry* tte = TT.probe(pos.key(), ttHit);
|
2015-01-20 01:13:30 -07:00
|
|
|
pos.undo_move(pv[0]);
|
2015-01-31 04:31:00 -07:00
|
|
|
|
|
|
|
if (ttHit)
|
|
|
|
{
|
|
|
|
Move m = tte->move(); // Local copy to be SMP safe
|
|
|
|
if (MoveList<LEGAL>(pos).contains(m))
|
|
|
|
return pv.push_back(m), true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2015-01-20 01:13:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-01-02 15:40:14 -07:00
|
|
|
/// check_time() is called by the timer thread when the timer triggers. It is
|
2013-12-02 11:04:09 -07:00
|
|
|
/// used to print debug info and, more importantly, to detect when we are out of
|
|
|
|
/// available time and thus stop the search.
|
2011-11-05 04:19:21 -06:00
|
|
|
|
2012-01-02 15:40:14 -07:00
|
|
|
void check_time() {
|
2011-11-05 04:19:21 -06:00
|
|
|
|
2015-02-24 04:24:53 -07:00
|
|
|
static TimePoint lastInfoTime = now();
|
2015-04-02 01:07:17 -06:00
|
|
|
int elapsed = Time.elapsed();
|
2011-11-05 04:19:21 -06:00
|
|
|
|
2015-02-24 04:24:53 -07:00
|
|
|
if (now() - lastInfoTime >= 1000)
|
2011-11-05 04:19:21 -06:00
|
|
|
{
|
2015-02-24 04:24:53 -07:00
|
|
|
lastInfoTime = now();
|
2011-12-30 08:14:24 -07:00
|
|
|
dbg_print();
|
2011-11-05 04:19:21 -06:00
|
|
|
}
|
|
|
|
|
2014-11-23 17:49:53 -07:00
|
|
|
// An engine may not stop pondering until told so by the GUI
|
|
|
|
if (Limits.ponder)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (Limits.use_time_management())
|
2014-10-17 23:44:08 -06:00
|
|
|
{
|
|
|
|
bool stillAtFirstMove = Signals.firstRootMove
|
|
|
|
&& !Signals.failedLowAtRoot
|
2015-04-02 01:07:17 -06:00
|
|
|
&& elapsed > Time.available() * 75 / 100;
|
2014-10-17 23:44:08 -06:00
|
|
|
|
|
|
|
if ( stillAtFirstMove
|
2015-04-02 01:07:17 -06:00
|
|
|
|| elapsed > Time.maximum() - 2 * TimerThread::Resolution)
|
2014-10-17 23:44:08 -06:00
|
|
|
Signals.stop = true;
|
|
|
|
}
|
|
|
|
else if (Limits.movetime && elapsed >= Limits.movetime)
|
|
|
|
Signals.stop = true;
|
2011-11-05 04:19:21 -06:00
|
|
|
|
Lazy SMP
Start all threads searching on root position and
use only the shared TT table as synching scheme.
It seems this scheme scales better than YBWC for
high number of threads.
Verified for nor regression at STC 3 threads
LLR: -2.95 (-2.94,2.94) [-3.00,1.00]
Total: 40232 W: 6908 L: 7130 D: 26194
Verified for nor regression at LTC 3 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 28186 W: 3908 L: 3798 D: 20480
Verified for nor regression at STC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 3607 W: 674 L: 526 D: 2407
Verified for nor regression at LTC 7 threads
LLR: 2.95 (-2.94,2.94) [-3.00,1.00]
Total: 4235 W: 671 L: 528 D: 3036
Tested with fixed games at LTC with 20 threads
ELO: 44.75 +-7.6 (95%) LOS: 100.0%
Total: 2069 W: 407 L: 142 D: 1520
Tested with fixed games at XLTC (120secs) with 20 threads
ELO: 28.01 +-6.7 (95%) LOS: 100.0%
Total: 2275 W: 349 L: 166 D: 1760
Original patch of mbootsector, with additional work
from Ivan Ivec (log formula), Joerg Oster (id loop
simplification) and Marco Costalba (assorted formatting
and rework).
Bench: 8116244
2015-10-06 00:15:17 -06:00
|
|
|
else if (Limits.nodes && Threads.nodes_searched() >= Limits.nodes)
|
2014-10-17 23:44:08 -06:00
|
|
|
Signals.stop = true;
|
2011-11-05 04:19:21 -06:00
|
|
|
}
|