Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ddugovic committed May 2, 2023
2 parents f0fc36b + 41f50b2 commit 65371e7
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 76 deletions.
35 changes: 17 additions & 18 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ Joona Kiiski (zamar)
Gary Linscott (glinscott)
Daniel Dugovic (ddugovic)
Fabian Fichter (ianfab)
Niklas Fiekas (niklasf)

# Authors and inventors of NNUE, training, NNUE port
# Authors and inventors of NNUE, training, and NNUE port
Yu Nasu (ynasu87)
Motohiro Isozaki (yaneurao)
Hisayori Noda (nodchip)

# all other authors of the code in alphabetical order
# All other authors of Stockfish code (in alphabetical order)
Aditya (absimaldata)
Adrian Petrescu (apetresc)
Ajith Chandy Jose (ajithcj)
Expand Down Expand Up @@ -50,11 +49,11 @@ Chess13234
Chris Cain (ceebo)
clefrks
Dale Weiler (graphitemaster)
Dan Schmidt (dfannius)
Daniel Axtens (daxtens)
Dan Schmidt (dfannius)
Dariusz Orzechowski (dorzechowski)
David Zar
David (dav1312)
David Zar
Daylen Yang (daylen)
Deshawn Mohan-Smith (GoldenRare)
Dieter Dobbelaere (ddobbelaere)
Expand All @@ -68,7 +67,6 @@ Eelco de Groot (KingDefender)
Elvin Liu (solarlight2)
erbsenzaehler
Ernesto Gatti
Linmiao Xu (linrock)
Fabian Beuke (madnight)
Fanael Linithien (Fanael)
fanon
Expand All @@ -84,30 +82,30 @@ Gontran Lemaire (gonlem)
Goodkov Vasiliy Aleksandrovich (goodkov)
Gregor Cramer
GuardianRM
Günther Demetz (pb00067, pb00068)
Guy Vreuls (gvreuls)
Günther Demetz (pb00067, pb00068)
Henri Wiechers
Hiraoka Takuya (HiraokaTakuya)
homoSapiensSapiens
Hongzhi Cheng
Ivan Ivec (IIvec)
Jacques B. (Timshel)
Jake Senne (w1wwwwww)
Jan Ondruš (hxim)
Jared Kish (Kurtbusch, kurt22i)
Jake Senne (w1wwwwww)
Jarrod Torriero (DU-jdto)
Jean Gauthier (OuaisBla)
Jean-Francois Romang (jromang)
Jean Gauthier (OuaisBla)
Jekaa
Jerry Donald Watson (jerrydonaldwatson)
jjoshua2
Jonathan Calovski (Mysseno)
Jonathan Buladas Dumale (SFisGOD)
Jonathan Calovski (Mysseno)
Jonathan McDermid (jonathanmcdermid)
Joost VandeVondele (vondele)
Jörg Oster (joergoster)
Joseph Ellis (jhellis3)
Joseph R. Prostko
Jörg Oster (joergoster)
Julian Willemer (NightlyKing)
jundery
Justin Blanchard (UncombedCoconut)
Expand All @@ -121,6 +119,7 @@ Krystian Kuzniarek (kuzkry)
Leonardo Ljubičić (ICCF World Champion)
Leonid Pechenik (lp--)
Liam Keegan (lkeegan)
Linmiao Xu (linrock)
Linus Arver (listx)
loco-loco
Lub van den Berg (ElbertoOne)
Expand Down Expand Up @@ -152,10 +151,11 @@ Moez Jellouli (MJZ1977)
Mohammed Li (tthsqe12)
Muzhen J (XInTheDark)
Nathan Rugg (nmrugg)
Nick Pelling (nickpelling)
Nguyen Pham (nguyenpham)
Nicklas Persson (NicklasPersson)
Nick Pelling (nickpelling)
Niklas Fiekas (niklasf)
Nikolay Kostov (NikolayIT)
Nguyen Pham (nguyenpham)
Norman Schmidt (FireFather)
notruck
Ofek Shochat (OfekShochat, ghostway)
Expand All @@ -170,6 +170,7 @@ Peter Schneider (pschneider1968)
Peter Zsifkovits (CoffeeOne)
PikaCat
Praveen Kumar Tummala (praveentml)
Prokop Randáček (ProkopRandacek)
Rahul Dsilva (silversolver1)
Ralph Stößer (Ralph Stoesser)
Raminder Singh
Expand All @@ -178,8 +179,8 @@ Reuven Peleg (R-Peleg)
Richard Lloyd (Richard-Lloyd)
Rodrigo Exterckötter Tjäder
Rodrigo Roim (roim)
Ron Britvich (Britvich)
Ronald de Man (syzygy1, syzygy)
Ron Britvich (Britvich)
rqs
Rui Coelho (ruicoelhopedro)
Ryan Schmitt
Expand All @@ -200,13 +201,12 @@ Stefano Di Martino (StefanoD)
Steinar Gunderson (sesse)
Stéphane Nicolet (snicolet)
Syine Mineta (MinetaS)
Prokop Randáček (ProkopRandacek)
Thanar2
thaspel
theo77186
Tomasz Sobczyk (Sopel97)
Tom Truscott
Tom Vijlbrief (tomtor)
Tomasz Sobczyk (Sopel97)
Torsten Franz (torfranz, tfranzer)
Torsten Hellwig (Torom)
Tracey Emery (basepr1me)
Expand All @@ -217,8 +217,7 @@ Vince Negri (cuddlestmonkey)
xefoci7612
zz4032


# Additionally, we acknowledge the authors and maintainers of fishtest,
# an amazing and essential framework for the development of Stockfish!
# an amazing and essential framework for Stockfish development!
#
# https://github.com/glinscott/fishtest/blob/master/AUTHORS
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ ifeq ($(pext),yes)
endif

### 3.7.1 Try to include git commit sha for versioning
GIT_SHA = $(shell git rev-parse --short HEAD 2>/dev/null)
GIT_SHA = $(shell git rev-parse HEAD 2>/dev/null | cut -c 1-8)
ifneq ($(GIT_SHA), )
CXXFLAGS += -DGIT_SHA=$(GIT_SHA)
endif
Expand Down
10 changes: 1 addition & 9 deletions src/evaluate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1946,7 +1946,7 @@ namespace {
/// evaluate() is the evaluator for the outer world. It returns a static
/// evaluation of the position from the point of view of the side to move.

Value Eval::evaluate(const Position& pos, int* complexity) {
Value Eval::evaluate(const Position& pos) {

assert(!pos.checkers());

Expand Down Expand Up @@ -1980,10 +1980,6 @@ Value Eval::evaluate(const Position& pos, int* complexity) {
+ (424 + optimism) * abs(psq - nnue)
) / 1024;

// Return hybrid NNUE complexity to caller
if (complexity)
*complexity = nnueComplexity;

optimism = optimism * (272 + nnueComplexity) / 256;
v = (nnue * scale + optimism * (scale - 748)) / 1024;
}
Expand All @@ -1995,10 +1991,6 @@ Value Eval::evaluate(const Position& pos, int* complexity) {
// Guarantee evaluation does not hit the tablebase range
v = std::clamp(v, VALUE_TB_LOSS_IN_MAX_PLY + 1, VALUE_TB_WIN_IN_MAX_PLY - 1);

// When not using NNUE, return classical complexity to caller
if (complexity && useClassical)
*complexity = abs(v - psq);

return v;
}

Expand Down
4 changes: 2 additions & 2 deletions src/evaluate.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Position;
namespace Eval {

std::string trace(Position& pos);
Value evaluate(const Position& pos, int* complexity = nullptr);
Value evaluate(const Position& pos);

#ifdef USE_NNUE
extern bool useNNUE;
Expand All @@ -40,7 +40,7 @@ namespace Eval {
// The default net name MUST follow the format nn-[SHA256 first 12 digits].nnue
// for the build process (profile-build and fishtest) to work. Do not change the
// name of the macro, as it is used in the Makefile.
#define EvalFileDefaultName "nn-dabb1ed23026.nnue"
#define EvalFileDefaultName "nn-e1fb1ade4432.nnue"

namespace NNUE {

Expand Down
3 changes: 1 addition & 2 deletions src/position.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,7 @@ void Position::set_check_info() const {

/// Position::set_state() computes the hash keys of the position, and other
/// data that once computed is updated incrementally as moves are made.
/// The function is only used when a new position is set up, and to verify
/// the correctness of the StateInfo data when running in debug mode.
/// The function is only used when a new position is set up

void Position::set_state() const {

Expand Down
66 changes: 24 additions & 42 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,20 +294,10 @@ void Thread::search() {

ss->pv = pv;

bestValue = delta = alpha = -VALUE_INFINITE;
beta = VALUE_INFINITE;
optimism[WHITE] = optimism[BLACK] = VALUE_ZERO;
bestValue = -VALUE_INFINITE;

if (mainThread)
{

if (!rootPos.checkers())
{
int rootComplexity;
Eval::evaluate(rootPos, &rootComplexity);
mainThread->complexity = std::min(1.03 + (rootComplexity - 241) / 1552.0, 1.45);
}

if (mainThread->bestPreviousScore == VALUE_INFINITE)
for (int i = 0; i < 4; ++i)
mainThread->iterValue[i] = VALUE_ZERO;
Expand Down Expand Up @@ -363,18 +353,15 @@ void Thread::search() {
selDepth = 0;

// Reset aspiration window starting size
if (rootDepth >= 4)
{
Value prev = rootMoves[pvIdx].averageScore;
delta = Value(10) + int(prev) * prev / 16502;
alpha = std::max(prev - delta,-VALUE_INFINITE);
beta = std::min(prev + delta, VALUE_INFINITE);

// Adjust optimism based on root move's previousScore
int opt = 120 * prev / (std::abs(prev) + 161);
optimism[ us] = Value(opt);
optimism[~us] = -optimism[us];
}
Value prev = rootMoves[pvIdx].averageScore;
delta = Value(10) + int(prev) * prev / 16502;
alpha = std::max(prev - delta,-VALUE_INFINITE);
beta = std::min(prev + delta, VALUE_INFINITE);

// Adjust optimism based on root move's previousScore
int opt = 120 * prev / (std::abs(prev) + 161);
optimism[ us] = Value(opt);
optimism[~us] = -optimism[us];

// Start with a small aspiration window and, in the case of a fail
// high/low, re-search with a bigger window until we don't fail
Expand Down Expand Up @@ -490,7 +477,7 @@ void Thread::search() {
double reduction = (1.4 + mainThread->previousTimeReduction) / (2.08 * timeReduction);
double bestMoveInstability = 1 + 1.8 * totBestMoveChanges / Threads.size();

double totalTime = Time.optimum() * fallingEval * reduction * bestMoveInstability * mainThread->complexity;
double totalTime = Time.optimum() * fallingEval * reduction * bestMoveInstability;

// Cap used time in case of a single legal move for a better viewer experience in tournaments
// yielding correct scores and sufficiently fast moves.
Expand Down Expand Up @@ -575,7 +562,7 @@ namespace {
bool givesCheck, improving, priorCapture, singularQuietLMR;
bool capture, moveCountPruning, ttCapture;
Piece movedPiece;
int moveCount, captureCount, quietCount, improvement, complexity;
int moveCount, captureCount, quietCount, improvement;

// Step 1. Initialize node
Thread* thisThread = pos.this_thread();
Expand Down Expand Up @@ -786,7 +773,6 @@ namespace {
ss->staticEval = eval = VALUE_NONE;
improving = false;
improvement = 0;
complexity = 0;
goto moves_loop;
}
else if (excludedMove)
Expand All @@ -796,17 +782,15 @@ namespace {
Eval::NNUE::hint_common_parent_position(pos);
#endif
eval = ss->staticEval;
complexity = abs(ss->staticEval - pos.psq_eg_stm());
}
else if (ss->ttHit)
{
// Never assume anything about values stored in TT
ss->staticEval = eval = tte->eval();
if (eval == VALUE_NONE)
ss->staticEval = eval = evaluate(pos, &complexity);
else // Fall back to (semi)classical complexity for TT hits, the NNUE complexity is lost
ss->staticEval = eval = evaluate(pos);
else
{
complexity = abs(ss->staticEval - pos.psq_eg_stm());
#ifdef USE_NNUE
if (PvNode)
Eval::NNUE::hint_common_parent_position(pos);
Expand All @@ -820,7 +804,7 @@ namespace {
}
else
{
ss->staticEval = eval = evaluate(pos, &complexity);
ss->staticEval = eval = evaluate(pos);
// Save static evaluation into transposition table
tte->save(posKey, VALUE_NONE, ss->ttPv, BOUND_NONE, DEPTH_NONE, MOVE_NONE, eval);
}
Expand Down Expand Up @@ -884,15 +868,15 @@ namespace {
&& (ss-1)->statScore < 18755
&& eval >= beta
&& eval >= ss->staticEval
&& ss->staticEval >= beta - 20 * depth - improvement / 13 + 253 + complexity / 25
&& ss->staticEval >= beta - 20 * depth - improvement / 13 + 253
&& !excludedMove
&& pos.non_pawn_material(us)
&& (ss->ply >= thisThread->nmpMinPly))
{
assert(eval - beta >= 0);

// Null move dynamic reduction based on depth, eval and complexity of position
Depth R = std::min(int(eval - beta) / 172, 6) + depth / 3 + 4 - (complexity > 825);
// Null move dynamic reduction based on depth and eval
Depth R = std::min(int(eval - beta) / 172, 6) + depth / 3 + 4;

ss->currentMove = MOVE_NULL;
ss->continuationHistory = &thisThread->continuationHistory[0][0][NO_PIECE][0];
Expand Down Expand Up @@ -1112,17 +1096,15 @@ namespace {
{
if (depth < 2 - capture)
continue;
// Don't prune the move if opp. King/Queen/Rook is attacked by a slider after the exchanges.
// Since in see_ge we don't update occupied when the king recaptures, we also don't prune the
// move when the opp. King gets a discovered slider attack DURING the exchanges.
Bitboard leftEnemies = pos.pieces(~us, ROOK, QUEEN, KING) & occupied;
// Don't prune the move if opp. King/Queen/Rook gets a discovered attack during or after the exchanges
Bitboard leftEnemies = pos.pieces(~us, KING, QUEEN, ROOK);
Bitboard attacks = 0;
occupied |= to_sq(move);
while (leftEnemies && !attacks)
{
Square sq = pop_lsb(leftEnemies);
attacks = pos.attackers_to(sq, occupied) & pos.pieces(us) & occupied;
// Exclude Queen/Rook(s) which were already threatened before SEE
// Exclude Queen/Rook(s) which were already threatened before SEE (opp King can't be in check when it's our turn)
if (attacks && sq != pos.square<KING>(~us) && (pos.attackers_to(sq, pos.pieces()) & pos.pieces(us)))
attacks = 0;
}
Expand Down Expand Up @@ -1294,6 +1276,9 @@ namespace {
if ((ss+1)->cutoffCnt > 3)
r++;

else if (move == ttMove)
r--;

ss->statScore = 2 * thisThread->mainHistory[us][from_to(move)]
+ (*contHist[0])[movedPiece][to_sq(move)]
+ (*contHist[1])[movedPiece][to_sq(move)]
Expand Down Expand Up @@ -1450,9 +1435,6 @@ namespace {
{
// Reduce other moves if we have found at least one score improvement (~1 Elo)
if ( depth > 1
&& ( (improving && complexity > 971)
|| value < (5 * alpha + 75 * beta) / 87
|| depth < 6)
&& beta < 12535
&& value > -12535)
depth -= 1;
Expand Down
1 change: 0 additions & 1 deletion src/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ void ThreadPool::clear() {
main()->bestPreviousScore = VALUE_INFINITE;
main()->bestPreviousAverageScore = VALUE_INFINITE;
main()->previousTimeReduction = 1.0;
main()->complexity = 1.0;
}


Expand Down
1 change: 0 additions & 1 deletion src/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ struct MainThread : public Thread {
void search() override;
void check_time();

double complexity;
double previousTimeReduction;
Value bestPreviousScore;
Value bestPreviousAverageScore;
Expand Down

0 comments on commit 65371e7

Please sign in to comment.