mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 08:43:09 +00:00
Write the LogFile only at the end of an iteration
Skip writing fail high/low sequences. Note that we don't need fail high/low markers anymore in pretty_pv(). No functional change but some do/undo move sequences. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
2786aed195
commit
4ead60e2a7
3 changed files with 22 additions and 32 deletions
|
@ -179,12 +179,11 @@ const string move_to_san(Position& pos, Move m) {
|
||||||
/// It is used to write search information to the log file (which is created
|
/// It is used to write search information to the log file (which is created
|
||||||
/// when the UCI parameter "Use Search Log" is "true").
|
/// when the UCI parameter "Use Search Log" is "true").
|
||||||
|
|
||||||
const string pretty_pv(Position& pos, int time, int depth,
|
const string pretty_pv(Position& pos, int depth, Value score, int time, Move pv[]) {
|
||||||
Value score, ValueType type, Move pv[]) {
|
|
||||||
|
|
||||||
const int64_t K = 1000;
|
const int64_t K = 1000;
|
||||||
const int64_t M = 1000000;
|
const int64_t M = 1000000;
|
||||||
const int startColumn = 29;
|
const int startColumn = 28;
|
||||||
const size_t maxLength = 80 - startColumn;
|
const size_t maxLength = 80 - startColumn;
|
||||||
const string lf = string("\n") + string(startColumn, ' ');
|
const string lf = string("\n") + string(startColumn, ' ');
|
||||||
|
|
||||||
|
@ -196,8 +195,7 @@ const string pretty_pv(Position& pos, int time, int depth,
|
||||||
|
|
||||||
// First print depth, score, time and searched nodes...
|
// First print depth, score, time and searched nodes...
|
||||||
s << std::setw(2) << depth
|
s << std::setw(2) << depth
|
||||||
<< (type == VALUE_TYPE_LOWER ? " >" : type == VALUE_TYPE_UPPER ? " <" : " ")
|
<< std::setw(8) << score_string(score)
|
||||||
<< std::setw(7) << score_string(score)
|
|
||||||
<< std::setw(8) << time_string(time);
|
<< std::setw(8) << time_string(time);
|
||||||
|
|
||||||
if (pos.nodes_searched() < M)
|
if (pos.nodes_searched() < M)
|
||||||
|
|
|
@ -192,6 +192,6 @@ class Position;
|
||||||
extern const std::string move_to_uci(Move m, bool chess960);
|
extern const std::string move_to_uci(Move m, bool chess960);
|
||||||
extern Move move_from_uci(const Position& pos, const std::string& str);
|
extern Move move_from_uci(const Position& pos, const std::string& str);
|
||||||
extern const std::string move_to_san(Position& pos, Move m);
|
extern const std::string move_to_san(Position& pos, Move m);
|
||||||
extern const std::string pretty_pv(Position& pos, int time, int depth, Value score, ValueType type, Move pv[]);
|
extern const std::string pretty_pv(Position& pos, int depth, Value score, int time, Move pv[]);
|
||||||
|
|
||||||
#endif // !defined(MOVE_H_INCLUDED)
|
#endif // !defined(MOVE_H_INCLUDED)
|
||||||
|
|
|
@ -129,7 +129,7 @@ namespace {
|
||||||
|
|
||||||
void extract_pv_from_tt(Position& pos);
|
void extract_pv_from_tt(Position& pos);
|
||||||
void insert_pv_in_tt(Position& pos);
|
void insert_pv_in_tt(Position& pos);
|
||||||
std::string pv_info_to_uci(Position& pos, int depth, Value alpha, Value beta, int pvLine = 0);
|
std::string pv_info_to_uci(Position& pos, int depth, Value alpha, Value beta, int pvLine);
|
||||||
|
|
||||||
int64_t nodes;
|
int64_t nodes;
|
||||||
Value pv_score;
|
Value pv_score;
|
||||||
|
@ -544,12 +544,13 @@ bool think(Position& pos, bool infinite, bool ponder, int time[], int increment[
|
||||||
std::string name = Options["Search Log Filename"].value<std::string>();
|
std::string name = Options["Search Log Filename"].value<std::string>();
|
||||||
LogFile.open(name.c_str(), std::ios::out | std::ios::app);
|
LogFile.open(name.c_str(), std::ios::out | std::ios::app);
|
||||||
|
|
||||||
LogFile << "Searching: " << pos.to_fen()
|
LogFile << "\nSearching: " << pos.to_fen()
|
||||||
<< "\ninfinite: " << infinite
|
<< "\ninfinite: " << infinite
|
||||||
<< " ponder: " << ponder
|
<< " ponder: " << ponder
|
||||||
<< " time: " << myTime
|
<< " time: " << myTime
|
||||||
<< " increment: " << myIncrement
|
<< " increment: " << myIncrement
|
||||||
<< " moves to go: " << movesToGo << endl;
|
<< " moves to go: " << movesToGo
|
||||||
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We're ready to start thinking. Call the iterative deepening loop function
|
// We're ready to start thinking. Call the iterative deepening loop function
|
||||||
|
@ -563,19 +564,14 @@ bool think(Position& pos, bool infinite, bool ponder, int time[], int increment[
|
||||||
|
|
||||||
if (UseLogFile)
|
if (UseLogFile)
|
||||||
{
|
{
|
||||||
LogFile << "\nNodes: " << pos.nodes_searched()
|
LogFile << "Nodes: " << pos.nodes_searched()
|
||||||
<< "\nNodes/second: " << nps(pos)
|
<< "\nNodes/second: " << nps(pos)
|
||||||
<< "\nBest move: " << move_to_san(pos, bestMove);
|
<< "\nBest move: " << move_to_san(pos, bestMove);
|
||||||
|
|
||||||
StateInfo st;
|
StateInfo st;
|
||||||
pos.do_move(bestMove, st);
|
pos.do_move(bestMove, st);
|
||||||
LogFile << "\nPonder move: "
|
LogFile << "\nPonder move: " << move_to_san(pos, ponderMove) << endl;
|
||||||
<< move_to_san(pos, ponderMove) // Works also with MOVE_NONE
|
pos.undo_move(bestMove); // Return from think() with unchanged position
|
||||||
<< endl;
|
|
||||||
|
|
||||||
// Return from think() with unchanged position
|
|
||||||
pos.undo_move(bestMove);
|
|
||||||
|
|
||||||
LogFile.close();
|
LogFile.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -701,6 +697,9 @@ namespace {
|
||||||
bestValues[depth] = value;
|
bestValues[depth] = value;
|
||||||
bestMoveChanges[depth] = Rml.bestMoveChanges;
|
bestMoveChanges[depth] = Rml.bestMoveChanges;
|
||||||
|
|
||||||
|
if (UseLogFile)
|
||||||
|
LogFile << pretty_pv(pos, depth, value, current_search_time(), Rml[0].pv) << endl;
|
||||||
|
|
||||||
// Drop the easy move if differs from the new best move
|
// Drop the easy move if differs from the new best move
|
||||||
if (bestMove != easyMove)
|
if (bestMove != easyMove)
|
||||||
easyMove = MOVE_NONE;
|
easyMove = MOVE_NONE;
|
||||||
|
@ -1880,7 +1879,7 @@ split_point_start: // At split points actual search starts from here
|
||||||
if (abs(v) < VALUE_MATE - PLY_MAX * ONE_PLY)
|
if (abs(v) < VALUE_MATE - PLY_MAX * ONE_PLY)
|
||||||
s << "cp " << int(v) * 100 / int(PawnValueMidgame); // Scale to centipawns
|
s << "cp " << int(v) * 100 / int(PawnValueMidgame); // Scale to centipawns
|
||||||
else
|
else
|
||||||
s << "mate " << (v > 0 ? (VALUE_MATE - v + 1) / 2 : -(VALUE_MATE + v) / 2 );
|
s << "mate " << (v > 0 ? (VALUE_MATE - v + 1) / 2 : -(VALUE_MATE + v) / 2);
|
||||||
|
|
||||||
return s.str();
|
return s.str();
|
||||||
}
|
}
|
||||||
|
@ -2528,8 +2527,8 @@ split_point_start: // At split points actual search starts from here
|
||||||
}
|
}
|
||||||
|
|
||||||
// pv_info_to_uci() returns a string with information on the current PV line
|
// pv_info_to_uci() returns a string with information on the current PV line
|
||||||
// formatted according to UCI specification and eventually writes the info
|
// formatted according to UCI specification. It is called at each iteration
|
||||||
// to a log file. It is called at each iteration or after a new pv is found.
|
// or after a new pv is found.
|
||||||
|
|
||||||
std::string RootMove::pv_info_to_uci(Position& pos, int depth, Value alpha, Value beta, int pvLine) {
|
std::string RootMove::pv_info_to_uci(Position& pos, int depth, Value alpha, Value beta, int pvLine) {
|
||||||
|
|
||||||
|
@ -2549,13 +2548,6 @@ split_point_start: // At split points actual search starts from here
|
||||||
<< " nps " << nps(pos)
|
<< " nps " << nps(pos)
|
||||||
<< " pv " << l.str();
|
<< " pv " << l.str();
|
||||||
|
|
||||||
if (UseLogFile && pvLine == 0)
|
|
||||||
{
|
|
||||||
ValueType t = pv_score >= beta ? VALUE_TYPE_LOWER :
|
|
||||||
pv_score <= alpha ? VALUE_TYPE_UPPER : VALUE_TYPE_EXACT;
|
|
||||||
|
|
||||||
LogFile << pretty_pv(pos, current_search_time(), depth, pv_score, t, pv) << endl;
|
|
||||||
}
|
|
||||||
return s.str();
|
return s.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue