mirror of
https://github.com/sockspls/badfish
synced 2025-04-29 16:23:09 +00:00
Use newly added log facility instead of LogFile
As a side effect now log file is open and closed every time it is used instead of remaining open for the whole thinking time. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
500fff920b
commit
e7cfe42d3f
1 changed files with 19 additions and 23 deletions
|
@ -20,7 +20,6 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <fstream>
|
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
@ -166,9 +165,6 @@ namespace {
|
||||||
TimeManager TimeMgr;
|
TimeManager TimeMgr;
|
||||||
SearchLimits Limits;
|
SearchLimits Limits;
|
||||||
|
|
||||||
// Log file
|
|
||||||
std::ofstream LogFile;
|
|
||||||
|
|
||||||
// Skill level adjustment
|
// Skill level adjustment
|
||||||
int SkillLevel;
|
int SkillLevel;
|
||||||
bool SkillLevelEnabled;
|
bool SkillLevelEnabled;
|
||||||
|
@ -433,17 +429,14 @@ bool think(Position& pos, const SearchLimits& limits, Move searchMoves[]) {
|
||||||
// Write to log file and keep it open to be accessed during the search
|
// Write to log file and keep it open to be accessed during the search
|
||||||
if (Options["Use Search Log"].value<bool>())
|
if (Options["Use Search Log"].value<bool>())
|
||||||
{
|
{
|
||||||
string name = Options["Search Log Filename"].value<string>();
|
Log log(Options["Search Log Filename"].value<string>());
|
||||||
LogFile.open(name.c_str(), std::ios::out | std::ios::app);
|
log << "\nSearching: " << pos.to_fen()
|
||||||
|
<< "\ninfinite: " << Limits.infinite
|
||||||
if (LogFile.is_open())
|
<< " ponder: " << Limits.ponder
|
||||||
LogFile << "\nSearching: " << pos.to_fen()
|
<< " time: " << Limits.time
|
||||||
<< "\ninfinite: " << Limits.infinite
|
<< " increment: " << Limits.increment
|
||||||
<< " ponder: " << Limits.ponder
|
<< " moves to go: " << Limits.movesToGo
|
||||||
<< " time: " << Limits.time
|
<< endl;
|
||||||
<< " increment: " << Limits.increment
|
|
||||||
<< " moves to go: " << Limits.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
|
||||||
|
@ -451,19 +444,19 @@ bool think(Position& pos, const SearchLimits& limits, Move searchMoves[]) {
|
||||||
Move bestMove = id_loop(pos, searchMoves, &ponderMove);
|
Move bestMove = id_loop(pos, searchMoves, &ponderMove);
|
||||||
|
|
||||||
// Write final search statistics and close log file
|
// Write final search statistics and close log file
|
||||||
if (LogFile.is_open())
|
if (Options["Use Search Log"].value<bool>())
|
||||||
{
|
{
|
||||||
int t = current_search_time();
|
int t = current_search_time();
|
||||||
|
|
||||||
LogFile << "Nodes: " << pos.nodes_searched()
|
Log log(Options["Search Log Filename"].value<string>());
|
||||||
<< "\nNodes/second: " << (t > 0 ? pos.nodes_searched() * 1000 / t : 0)
|
log << "Nodes: " << pos.nodes_searched()
|
||||||
<< "\nBest move: " << move_to_san(pos, bestMove);
|
<< "\nNodes/second: " << (t > 0 ? pos.nodes_searched() * 1000 / t : 0)
|
||||||
|
<< "\nBest move: " << move_to_san(pos, bestMove);
|
||||||
|
|
||||||
StateInfo st;
|
StateInfo st;
|
||||||
pos.do_move(bestMove, st);
|
pos.do_move(bestMove, st);
|
||||||
LogFile << "\nPonder move: " << move_to_san(pos, ponderMove) << endl;
|
log << "\nPonder move: " << move_to_san(pos, ponderMove) << endl;
|
||||||
pos.undo_move(bestMove); // Return from think() with unchanged position
|
pos.undo_move(bestMove); // Return from think() with unchanged position
|
||||||
LogFile.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This makes all the threads to go to sleep
|
// This makes all the threads to go to sleep
|
||||||
|
@ -641,8 +634,11 @@ namespace {
|
||||||
if (SkillLevelEnabled && depth == 1 + SkillLevel)
|
if (SkillLevelEnabled && depth == 1 + SkillLevel)
|
||||||
do_skill_level(&skillBest, &skillPonder);
|
do_skill_level(&skillBest, &skillPonder);
|
||||||
|
|
||||||
if (LogFile.is_open())
|
if (Options["Use Search Log"].value<bool>())
|
||||||
LogFile << pretty_pv(pos, depth, value, current_search_time(), &Rml[0].pv[0]) << endl;
|
{
|
||||||
|
Log log(Options["Search Log Filename"].value<string>());
|
||||||
|
log << pretty_pv(pos, depth, value, current_search_time(), &Rml[0].pv[0]) << endl;
|
||||||
|
}
|
||||||
|
|
||||||
// Init easyMove at first iteration or drop it if differs from the best move
|
// Init easyMove at first iteration or drop it if differs from the best move
|
||||||
if (depth == 1 && (Rml.size() == 1 || Rml[0].score > Rml[1].score + EasyMoveMargin))
|
if (depth == 1 && (Rml.size() == 1 || Rml[0].score > Rml[1].score + EasyMoveMargin))
|
||||||
|
|
Loading…
Add table
Reference in a new issue