mirror of
https://github.com/sockspls/badfish
synced 2025-07-12 03:59:15 +00:00
Reset search time as early as possible
In particualr before to wake up main thread that could take some random time. Until we don't reset search time we are not able to correctly track the elapsed search time and this can be dangerous under extreme time pressure. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
d033d5e06a
commit
cc6c745b54
3 changed files with 5 additions and 3 deletions
|
@ -28,7 +28,6 @@
|
||||||
#include "book.h"
|
#include "book.h"
|
||||||
#include "evaluate.h"
|
#include "evaluate.h"
|
||||||
#include "history.h"
|
#include "history.h"
|
||||||
#include "misc.h"
|
|
||||||
#include "movegen.h"
|
#include "movegen.h"
|
||||||
#include "movepick.h"
|
#include "movepick.h"
|
||||||
#include "search.h"
|
#include "search.h"
|
||||||
|
@ -43,6 +42,7 @@ namespace Search {
|
||||||
LimitsType Limits;
|
LimitsType Limits;
|
||||||
std::vector<RootMove> RootMoves;
|
std::vector<RootMove> RootMoves;
|
||||||
Position RootPosition;
|
Position RootPosition;
|
||||||
|
Time SearchTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
@ -118,7 +118,6 @@ namespace {
|
||||||
|
|
||||||
size_t MultiPV, UCIMultiPV, PVIdx;
|
size_t MultiPV, UCIMultiPV, PVIdx;
|
||||||
TimeManager TimeMgr;
|
TimeManager TimeMgr;
|
||||||
Time SearchTime;
|
|
||||||
int BestMoveChanges;
|
int BestMoveChanges;
|
||||||
int SkillLevel;
|
int SkillLevel;
|
||||||
bool SkillLevelEnabled, Chess960;
|
bool SkillLevelEnabled, Chess960;
|
||||||
|
@ -253,7 +252,6 @@ void Search::think() {
|
||||||
Position& pos = RootPosition;
|
Position& pos = RootPosition;
|
||||||
Chess960 = pos.is_chess960();
|
Chess960 = pos.is_chess960();
|
||||||
Eval::RootColor = pos.side_to_move();
|
Eval::RootColor = pos.side_to_move();
|
||||||
SearchTime.restart();
|
|
||||||
TimeMgr.init(Limits, pos.startpos_ply_counter(), pos.side_to_move());
|
TimeMgr.init(Limits, pos.startpos_ply_counter(), pos.side_to_move());
|
||||||
TT.new_search();
|
TT.new_search();
|
||||||
H.clear();
|
H.clear();
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "misc.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
class Position;
|
class Position;
|
||||||
|
@ -94,6 +95,7 @@ extern volatile SignalsType Signals;
|
||||||
extern LimitsType Limits;
|
extern LimitsType Limits;
|
||||||
extern std::vector<RootMove> RootMoves;
|
extern std::vector<RootMove> RootMoves;
|
||||||
extern Position RootPosition;
|
extern Position RootPosition;
|
||||||
|
extern Time SearchTime;
|
||||||
|
|
||||||
extern void init();
|
extern void init();
|
||||||
extern int64_t perft(Position& pos, Depth depth);
|
extern int64_t perft(Position& pos, Depth depth);
|
||||||
|
|
|
@ -432,6 +432,8 @@ void ThreadsManager::start_searching(const Position& pos, const LimitsType& limi
|
||||||
const std::set<Move>& searchMoves) {
|
const std::set<Move>& searchMoves) {
|
||||||
wait_for_search_finished();
|
wait_for_search_finished();
|
||||||
|
|
||||||
|
SearchTime.restart(); // As early as possible
|
||||||
|
|
||||||
Signals.stopOnPonderhit = Signals.firstRootMove = false;
|
Signals.stopOnPonderhit = Signals.firstRootMove = false;
|
||||||
Signals.stop = Signals.failedLowAtRoot = false;
|
Signals.stop = Signals.failedLowAtRoot = false;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue