mirror of
https://github.com/sockspls/badfish
synced 2025-05-01 01:03:09 +00:00
Move ONE_PLY to be 1 instead of 2: search()
Now that half-plies are no more used we can simplify the code assuming that ONE_PLY is 1 and no more 2. Verified with a SMP test: LLR: 2.95 (-2.94,2.94) [-4.50,0.00] Total: 8926 W: 1712 L: 1607 D: 5607 No functional change.
This commit is contained in:
parent
27a1877299
commit
222f59b9c1
2 changed files with 34 additions and 37 deletions
|
@ -55,21 +55,20 @@ namespace {
|
||||||
enum NodeType { Root, PV, NonPV };
|
enum NodeType { Root, PV, NonPV };
|
||||||
|
|
||||||
// Dynamic razoring margin based on depth
|
// Dynamic razoring margin based on depth
|
||||||
inline Value razor_margin(Depth d) { return Value(512 + 16 * d); }
|
inline Value razor_margin(Depth d) { return Value(512 + 32 * d); }
|
||||||
|
|
||||||
// Futility lookup tables (initialized at startup) and their access functions
|
// Futility lookup tables (initialized at startup) and their access functions
|
||||||
int FutilityMoveCounts[2][32]; // [improving][depth]
|
int FutilityMoveCounts[2][32]; // [improving][depth]
|
||||||
|
|
||||||
inline Value futility_margin(Depth d) {
|
inline Value futility_margin(Depth d) {
|
||||||
return Value(100 * d);
|
return Value(200 * d);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reduction lookup tables (initialized at startup) and their access function
|
// Reduction lookup tables (initialized at startup) and their access function
|
||||||
int8_t Reductions[2][2][64][64]; // [pv][improving][depth][moveNumber]
|
int8_t Reductions[2][2][64][64]; // [pv][improving][depth][moveNumber]
|
||||||
|
|
||||||
template <bool PvNode> inline Depth reduction(bool i, Depth d, int mn) {
|
template <bool PvNode> inline Depth reduction(bool i, Depth d, int mn) {
|
||||||
|
return (Depth) Reductions[PvNode][i][std::min(int(d), 63)][std::min(mn, 63)];
|
||||||
return (Depth) Reductions[PvNode][i][std::min(int(d) / ONE_PLY, 63)][std::min(mn, 63)];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t PVIdx;
|
size_t PVIdx;
|
||||||
|
@ -127,21 +126,21 @@ void Search::init() {
|
||||||
{
|
{
|
||||||
double pvRed = 0.00 + log(double(hd)) * log(double(mc)) / 3.00;
|
double pvRed = 0.00 + log(double(hd)) * log(double(mc)) / 3.00;
|
||||||
double nonPVRed = 0.33 + log(double(hd)) * log(double(mc)) / 2.25;
|
double nonPVRed = 0.33 + log(double(hd)) * log(double(mc)) / 2.25;
|
||||||
Reductions[1][1][hd][mc] = int8_t( pvRed >= 1.0 ? pvRed+0.5: 0)*int(ONE_PLY);
|
Reductions[1][1][hd][mc] = int8_t( pvRed >= 1.0 ? pvRed + 0.5: 0);
|
||||||
Reductions[0][1][hd][mc] = int8_t(nonPVRed >= 1.0 ? nonPVRed+0.5: 0)*int(ONE_PLY);
|
Reductions[0][1][hd][mc] = int8_t(nonPVRed >= 1.0 ? nonPVRed + 0.5: 0);
|
||||||
|
|
||||||
Reductions[1][0][hd][mc] = Reductions[1][1][hd][mc];
|
Reductions[1][0][hd][mc] = Reductions[1][1][hd][mc];
|
||||||
Reductions[0][0][hd][mc] = Reductions[0][1][hd][mc];
|
Reductions[0][0][hd][mc] = Reductions[0][1][hd][mc];
|
||||||
|
|
||||||
if (Reductions[0][0][hd][mc] >= 2 * ONE_PLY)
|
if (Reductions[0][0][hd][mc] >= 2)
|
||||||
Reductions[0][0][hd][mc] += ONE_PLY;
|
Reductions[0][0][hd][mc] += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init futility move count array
|
// Init futility move count array
|
||||||
for (d = 0; d < 32; ++d)
|
for (d = 0; d < 32; ++d)
|
||||||
{
|
{
|
||||||
FutilityMoveCounts[0][d] = int(2.4 + 0.222 * pow(d + 0.00, 1.8));
|
FutilityMoveCounts[0][d] = int(2.4 + 0.222 * pow(d * 2 + 0.00, 1.8));
|
||||||
FutilityMoveCounts[1][d] = int(3.0 + 0.300 * pow(d + 0.98, 1.8));
|
FutilityMoveCounts[1][d] = int(3.0 + 0.300 * pow(d * 2 + 0.98, 1.8));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +153,7 @@ uint64_t Search::perft(Position& pos, Depth depth) {
|
||||||
StateInfo st;
|
StateInfo st;
|
||||||
uint64_t cnt, nodes = 0;
|
uint64_t cnt, nodes = 0;
|
||||||
CheckInfo ci(pos);
|
CheckInfo ci(pos);
|
||||||
const bool leaf = depth == 2 * ONE_PLY;
|
const bool leaf = (depth == 2 * ONE_PLY);
|
||||||
|
|
||||||
for (MoveList<LEGAL> it(pos); *it; ++it)
|
for (MoveList<LEGAL> it(pos); *it; ++it)
|
||||||
{
|
{
|
||||||
|
@ -561,8 +560,7 @@ namespace {
|
||||||
assert(eval - beta >= 0);
|
assert(eval - beta >= 0);
|
||||||
|
|
||||||
// Null move dynamic reduction based on depth and value
|
// Null move dynamic reduction based on depth and value
|
||||||
Depth R = (3 + (depth / 8 )) * ONE_PLY
|
Depth R = (3 + depth / 4 + std::min(int(eval - beta) / PawnValueMg, 3)) * ONE_PLY;
|
||||||
+ std::min(int(eval - beta) / PawnValueMg, 3) * ONE_PLY;
|
|
||||||
|
|
||||||
pos.do_null_move(st);
|
pos.do_null_move(st);
|
||||||
(ss+1)->skipNullMove = true;
|
(ss+1)->skipNullMove = true;
|
||||||
|
@ -627,10 +625,9 @@ namespace {
|
||||||
&& !ttMove
|
&& !ttMove
|
||||||
&& (PvNode || ss->staticEval + 256 >= beta))
|
&& (PvNode || ss->staticEval + 256 >= beta))
|
||||||
{
|
{
|
||||||
Depth d = depth - 2 * ONE_PLY - (PvNode ? DEPTH_ZERO : depth / 4);
|
Depth d = 2 * (depth - 2 * ONE_PLY) - (PvNode ? DEPTH_ZERO : depth / 2);
|
||||||
d = (d / 2) * 2; // Round to nearest full-ply
|
|
||||||
ss->skipNullMove = true;
|
ss->skipNullMove = true;
|
||||||
search<PvNode ? PV : NonPV, false>(pos, ss, alpha, beta, d, true);
|
search<PvNode ? PV : NonPV, false>(pos, ss, alpha, beta, d / 2, true);
|
||||||
ss->skipNullMove = false;
|
ss->skipNullMove = false;
|
||||||
|
|
||||||
tte = TT.probe(posKey);
|
tte = TT.probe(posKey);
|
||||||
|
@ -696,7 +693,7 @@ moves_loop: // When in check and at SpNode search starts from here
|
||||||
Signals.firstRootMove = (moveCount == 1);
|
Signals.firstRootMove = (moveCount == 1);
|
||||||
|
|
||||||
if (thisThread == Threads.main() && Time::now() - SearchTime > 3000)
|
if (thisThread == Threads.main() && Time::now() - SearchTime > 3000)
|
||||||
sync_cout << "info depth " << depth / ONE_PLY
|
sync_cout << "info depth " << depth
|
||||||
<< " currmove " << move_to_uci(move, pos.is_chess960())
|
<< " currmove " << move_to_uci(move, pos.is_chess960())
|
||||||
<< " currmovenumber " << moveCount + PVIdx << sync_endl;
|
<< " currmovenumber " << moveCount + PVIdx << sync_endl;
|
||||||
}
|
}
|
||||||
|
@ -726,10 +723,10 @@ moves_loop: // When in check and at SpNode search starts from here
|
||||||
&& !ext
|
&& !ext
|
||||||
&& pos.legal(move, ci.pinned))
|
&& pos.legal(move, ci.pinned))
|
||||||
{
|
{
|
||||||
Value rBeta = ttValue - int(depth);
|
Value rBeta = ttValue - int(2 * depth);
|
||||||
ss->excludedMove = move;
|
ss->excludedMove = move;
|
||||||
ss->skipNullMove = true;
|
ss->skipNullMove = true;
|
||||||
value = search<NonPV, false>(pos, ss, rBeta - 1, rBeta, (depth / 4) * 2, cutNode);
|
value = search<NonPV, false>(pos, ss, rBeta - 1, rBeta, depth / 2, cutNode);
|
||||||
ss->skipNullMove = false;
|
ss->skipNullMove = false;
|
||||||
ss->excludedMove = MOVE_NONE;
|
ss->excludedMove = MOVE_NONE;
|
||||||
|
|
||||||
|
@ -750,7 +747,7 @@ moves_loop: // When in check and at SpNode search starts from here
|
||||||
{
|
{
|
||||||
// Move count based pruning
|
// Move count based pruning
|
||||||
if ( depth < 16 * ONE_PLY
|
if ( depth < 16 * ONE_PLY
|
||||||
&& moveCount >= FutilityMoveCounts[improving][depth] )
|
&& moveCount >= FutilityMoveCounts[improving][depth])
|
||||||
{
|
{
|
||||||
if (SpNode)
|
if (SpNode)
|
||||||
splitPoint->mutex.lock();
|
splitPoint->mutex.lock();
|
||||||
|
@ -1229,7 +1226,7 @@ moves_loop: // When in check and at SpNode search starts from here
|
||||||
|
|
||||||
// Increase history value of the cut-off move and decrease all the other
|
// Increase history value of the cut-off move and decrease all the other
|
||||||
// played quiet moves.
|
// played quiet moves.
|
||||||
Value bonus = Value(int(depth) * int(depth));
|
Value bonus = Value(4 * int(depth) * int(depth));
|
||||||
History.update(pos.moved_piece(move), to_sq(move), bonus);
|
History.update(pos.moved_piece(move), to_sq(move), bonus);
|
||||||
for (int i = 0; i < quietsCnt; ++i)
|
for (int i = 0; i < quietsCnt; ++i)
|
||||||
{
|
{
|
||||||
|
|
12
src/types.h
12
src/types.h
|
@ -211,14 +211,14 @@ enum Piece {
|
||||||
|
|
||||||
enum Depth {
|
enum Depth {
|
||||||
|
|
||||||
ONE_PLY = 2,
|
ONE_PLY = 1,
|
||||||
|
|
||||||
DEPTH_ZERO = 0 * ONE_PLY,
|
DEPTH_ZERO = 0,
|
||||||
DEPTH_QS_CHECKS = 0 * ONE_PLY,
|
DEPTH_QS_CHECKS = 0,
|
||||||
DEPTH_QS_NO_CHECKS = -1 * ONE_PLY,
|
DEPTH_QS_NO_CHECKS = -1,
|
||||||
DEPTH_QS_RECAPTURES = -5 * ONE_PLY,
|
DEPTH_QS_RECAPTURES = -5,
|
||||||
|
|
||||||
DEPTH_NONE = -6 * ONE_PLY
|
DEPTH_NONE = -6
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Square {
|
enum Square {
|
||||||
|
|
Loading…
Add table
Reference in a new issue