diff --git a/Source/cli.cpp b/Source/cli.cpp index b354af1c..617f722d 100644 --- a/Source/cli.cpp +++ b/Source/cli.cpp @@ -397,7 +397,10 @@ int cliManagement(std::string cli, int argc, char ** argv){ DepthType d = 5; if ( argc > 3 ) d = atoi(argv[3]); PerftAccumulator acc; + auto start = Clock::now(); perft(p,d,acc); + auto elapsed = std::max(1, (int)std::chrono::duration_cast(Clock::now() - start).count()); + Logging::LogIt(Logging::logInfo) << "Perft done in " << elapsed << "ms"; acc.Display(); return 0; } @@ -405,7 +408,10 @@ int cliManagement(std::string cli, int argc, char ** argv){ if ( cli == "-analyze" ){ DepthType depth = 15; if ( argc > 3 ) depth = atoi(argv[3]); + auto start = Clock::now(); analyze(p,depth); + auto elapsed = std::max(1, (int)std::chrono::duration_cast(Clock::now() - start).count()); + Logging::LogIt(Logging::logInfo) << "Analysis done in " << elapsed << "ms"; return 0; } diff --git a/Source/definition.hpp b/Source/definition.hpp index 7d928102..38a36b1e 100644 --- a/Source/definition.hpp +++ b/Source/definition.hpp @@ -38,7 +38,7 @@ typedef uint64_t u_int64_t; #include #endif -const std::string MinicVersion = "2.04"; +const std::string MinicVersion = "2.05"; // *** options #define WITH_UCI diff --git a/Source/eval.hpp b/Source/eval.hpp index 268667bb..9d1cb7c5 100644 --- a/Source/eval.hpp +++ b/Source/eval.hpp @@ -296,7 +296,7 @@ inline ScoreType eval(const Position & p, EvalData & data, Searcher &context){ pe.danger[Co_Black] += EvalConfig::kingAttSemiOpenfileOur * countBit(kingFlank[bkf] & pe.semiOpenFiles[Co_White])/8; ++context.stats.counters[Stats::sid_ttPawnInsert]; - pe.h = Hash64to32(computePHash(p)); // set the pawn entry + pe.h = Hash64to32(computePHash(p)) /*^ Zobrist::ZT[pe.score[MG]%64][13] ^ Zobrist::ZT[pe.score[EG]%64][13]*/; // set the pawn entry } assert(pePtr); const Searcher::PawnEntry & pe = *pePtr; diff --git a/Source/searcher.cpp b/Source/searcher.cpp index 07f54a99..26b5e34b 100644 --- a/Source/searcher.cpp +++ b/Source/searcher.cpp @@ -115,7 +115,7 @@ bool Searcher::getPawnEntry(Hash h, PawnEntry *& pe){ assert(h > 0); PawnEntry & _e = tablePawn[h&(ttSizePawn-1)]; pe = &_e; - if ( _e.h != Hash64to32(h) ) return false; + if ( (_e.h /*^ Zobrist::ZT[_e.score[MG]%64][13] ^ Zobrist::ZT[_e.score[EG]%64][13]*/) != Hash64to32(h) ) return false; ++stats.counters[Stats::sid_ttPawnhits]; return true; } diff --git a/Source/searcher.hpp b/Source/searcher.hpp index 52042dbd..9e987071 100644 --- a/Source/searcher.hpp +++ b/Source/searcher.hpp @@ -90,8 +90,10 @@ struct Searcher{ ScoreType danger[2] = {0,0}; MiniHash h = 0; inline void reset(){ - score[MG] = 0; score[EG] = 0; - danger[0] = 0; danger[1] = 0; + score[MG] = 0; + score[EG] = 0; + danger[Co_White] = 0; + danger[Co_Black] = 0; } }; #pragma pack(pop) diff --git a/Source/searcherDriver.cpp b/Source/searcherDriver.cpp index 12beaad7..80aeeaaf 100644 --- a/Source/searcherDriver.cpp +++ b/Source/searcherDriver.cpp @@ -164,8 +164,16 @@ PVList Searcher::search(const Position & p, Move & m, DepthType & d, ScoreType & bestScore = score; if ( isMainThread() ){ displayGUI(depth,seldepth,bestScore,pv,multi+1); - if (TimeMan::isDynamic && depth > MoveDifficultyUtil::emergencyMinDepth && bestScore < depthScores[depth - 1] - MoveDifficultyUtil::emergencyMargin) { moveDifficulty = MoveDifficultyUtil::MD_hardDefense; Logging::LogIt(Logging::logInfo) << "Emergency mode activated : " << bestScore << " < " << depthScores[depth - 1] - MoveDifficultyUtil::emergencyMargin; } - if (TimeMan::isDynamic && (TimeType)std::max(1, int(std::chrono::duration_cast(Clock::now() - TimeMan::startTime).count()*1.8)) > getCurrentMoveMs()) { stopFlag = true; Logging::LogIt(Logging::logInfo) << "stopflag triggered, not enough time for next depth"; break; } // not enought time + if (TimeMan::isDynamic && depth > MoveDifficultyUtil::emergencyMinDepth + && bestScore < depthScores[depth - 1] - MoveDifficultyUtil::emergencyMargin) { + moveDifficulty = MoveDifficultyUtil::MD_hardDefense; + Logging::LogIt(Logging::logInfo) << "Emergency mode activated : " << bestScore << " < " << depthScores[depth - 1] - MoveDifficultyUtil::emergencyMargin; + } + if (TimeMan::isDynamic + && (TimeType)std::max(1, int(std::chrono::duration_cast(Clock::now() - TimeMan::startTime).count()*1.8)) > getCurrentMoveMs()) { + stopFlag = true; + Logging::LogIt(Logging::logInfo) << "stopflag triggered, not enough time for next depth"; break; + } // not enought time depthScores[depth] = bestScore; } if ( !pv.empty() ){ diff --git a/Source/searcherPVS.hpp b/Source/searcherPVS.hpp index 1e8f05f5..87634ba1 100644 --- a/Source/searcherPVS.hpp +++ b/Source/searcherPVS.hpp @@ -358,6 +358,7 @@ ScoreType Searcher::pvs(ScoreType alpha, ScoreType beta, const Position & p, Dep const bool noCheck = !isInCheck && !isCheck; const bool isPrunableStd = isPrunable && isQuiet; const bool isPrunableStdNoCheck = isPrunableStd && noCheck; + //const bool isEmergency = moveDifficulty == MoveDifficultyUtil::MD_hardDefense; ///@todo try this const bool isPrunableCap = isPrunable && Move2Type(*it) == T_capture && isBadCap(*it) && noCheck ; const bool isDangerPrune = data.danger[p.c] > SearchConfig::dangerLimitPruning[0] || data.danger[~p.c] > SearchConfig::dangerLimitPruning[1]; const bool isDangerRed = data.danger[p.c] > SearchConfig::dangerLimitReduction[0] || data.danger[~p.c] > SearchConfig::dangerLimitReduction[1]; @@ -367,7 +368,7 @@ ScoreType Searcher::pvs(ScoreType alpha, ScoreType beta, const Position & p, Dep // futility if (futility && isPrunableStdNoCheck) {++stats.counters[Stats::sid_futility]; continue;} // LMP - if (lmp && isPrunableStdNoCheck && validMoveCount > (1/*+dangerPruneFactor*/)*SearchConfig::lmpLimit[improving][depth] ) {++stats.counters[Stats::sid_lmp]; continue;} + if (lmp && isPrunableStdNoCheck && validMoveCount > (1/*+dangerPruneFactor*/)*SearchConfig::lmpLimit[improving][depth] /*+ 2*isEmergency*/ ) {++stats.counters[Stats::sid_lmp]; continue;} // History pruning (with CMH) if (historyPruning && isPrunableStdNoCheck && Move2Score(*it) < SearchConfig::historyPruningThresholdInit + depth*SearchConfig::historyPruningThresholdDepth) {++stats.counters[Stats::sid_historyPruning]; continue;} // CMH pruning alone @@ -393,6 +394,7 @@ ScoreType Searcher::pvs(ScoreType alpha, ScoreType beta, const Position & p, Dep else if ( isDangerRed ) --reduction; else if ( !noCheck ) --reduction; //else if ( ttMoveSingularExt) --reduction; + //if ( isEmergency ) --reduction; } if ( extension - reduction > 0 ) reduction = extension; if ( reduction >= depth - 1 + extension ) reduction = depth - 1 + extension - 1; diff --git a/Source/searcherSee.cpp b/Source/searcherSee.cpp index 1b6bd93a..d347fa4c 100644 --- a/Source/searcherSee.cpp +++ b/Source/searcherSee.cpp @@ -37,9 +37,10 @@ ScoreType Searcher::SEE(const Position & p, const Move & m) const { attackers &= ~SquareToBitboard(from); occupation_mask &= ~SquareToBitboard(from); + const BitBoard occupancy = p.occupancy(); - attackers |= BBTools::attack(to, p.whiteQueen() | p.blackQueen() | p.whiteRook() | p.blackRook(), p.occupancy() & occupation_mask, c) | - BBTools::attack(to, p.whiteQueen() | p.blackQueen() | p.whiteBishop() | p.blackBishop(), p.occupancy() & occupation_mask, c) ; + attackers |= BBTools::attack(to, p.whiteQueen() | p.blackQueen() | p.whiteRook() | p.blackRook(), occupancy & occupation_mask, c) | + BBTools::attack(to, p.whiteQueen() | p.blackQueen() | p.whiteBishop() | p.blackBishop(), occupancy & occupation_mask, c) ; attackers &= occupation_mask; c = ~c; @@ -64,8 +65,8 @@ ScoreType Searcher::SEE(const Position & p, const Move & m) const { attackers &= ~SquareToBitboard(from); occupation_mask &= ~SquareToBitboard(from); - attackers |= BBTools::attack(to, p.whiteQueen() | p.blackQueen() | p.whiteRook() | p.blackRook(), p.occupancy() & occupation_mask, c) | - BBTools::attack(to, p.whiteQueen() | p.blackQueen() | p.whiteBishop() | p.blackBishop(), p.occupancy() & occupation_mask, c) ; + attackers |= BBTools::attack(to, p.whiteQueen() | p.blackQueen() | p.whiteRook() | p.blackRook(), occupancy & occupation_mask, c) | + BBTools::attack(to, p.whiteQueen() | p.blackQueen() | p.whiteBishop() | p.blackBishop(), occupancy & occupation_mask, c) ; attackers &= occupation_mask; c = ~c; diff --git a/Source/transposition.cpp b/Source/transposition.cpp index ade61a7b..3aeee716 100644 --- a/Source/transposition.cpp +++ b/Source/transposition.cpp @@ -30,7 +30,7 @@ void initTable(){ void clearTT() { TT::curGen = 0; - for (unsigned int k = 0; k < ttSize; ++k) table[k] = { 0, INVALIDMINIMOVE, 0, 0, B_alpha, 0 }; + for (unsigned int k = 0; k < ttSize; ++k) table[k] = { 0, 0, 0, INVALIDMINIMOVE, B_none, -1 }; } int hashFull(){