*/
#include <cassert>
-#include <iomanip>
#include <sstream>
-#include <stack>
#include "movegen.h"
#include "notation.h"
return MOVE_NONE;
}
-
-
-/// pretty_pv() formats human-readable search information, typically to be
-/// appended to the search log file. It uses the two helpers below to pretty
-/// format the time and score respectively.
-
-static string format(int64_t msecs) {
-
- const int MSecMinute = 1000 * 60;
- const int MSecHour = 1000 * 60 * 60;
-
- int64_t hours = msecs / MSecHour;
- int64_t minutes = (msecs % MSecHour) / MSecMinute;
- int64_t seconds = ((msecs % MSecHour) % MSecMinute) / 1000;
-
- stringstream ss;
-
- if (hours)
- ss << hours << ':';
-
- ss << setfill('0') << setw(2) << minutes << ':' << setw(2) << seconds;
-
- return ss.str();
-}
-
-static string format(Value v) {
-
- stringstream ss;
-
- if (v >= VALUE_MATE_IN_MAX_PLY)
- ss << "#" << (VALUE_MATE - v + 1) / 2;
-
- else if (v <= VALUE_MATED_IN_MAX_PLY)
- ss << "-#" << (VALUE_MATE + v) / 2;
-
- else
- ss << setprecision(2) << fixed << showpos << double(v) / PawnValueEg;
-
- return ss.str();
-}
-
-string pretty_pv(const Position& pos, int depth, Value value, int64_t msecs, Move pv[]) {
-
- const uint64_t K = 1000;
- const uint64_t M = 1000000;
-
- stringstream ss;
- ss << setw(2) << depth << setw(8) << format(value) << setw(8) << format(msecs);
-
- if (pos.nodes_searched() < M)
- ss << setw(8) << pos.nodes_searched() / 1 << " ";
-
- else if (pos.nodes_searched() < K * M)
- ss << setw(7) << pos.nodes_searched() / K << "K ";
-
- else
- ss << setw(7) << pos.nodes_searched() / M << "M ";
-
- string str = ss.str();
-
- for (Move *m = pv; *m != MOVE_NONE; m++)
- str += move_to_uci(*m, pos.is_chess960()) + ' ';
-
- return str;
-}
std::string score_to_uci(Value v, Value alpha = -VALUE_INFINITE, Value beta = VALUE_INFINITE);
Move move_from_uci(const Position& pos, std::string& str);
const std::string move_to_uci(Move m, bool chess960);
-std::string pretty_pv(const Position& pos, int depth, Value score, int64_t msecs, Move pv[]);
inline char to_char(File f, bool tolower = true) {
return char(f - FILE_A + (tolower ? 'a' : 'A'));
#include <algorithm>
#include <cassert>
-#include <cfloat>
#include <cmath>
#include <cstring>
#include <iostream>
goto finalize;
}
- if (Options["Write Search Log"])
- {
- Log log(Options["Search Log Filename"]);
- log << "\nSearching: " << RootPos.fen()
- << "\ninfinite: " << Limits.infinite
- << " ponder: " << Limits.ponder
- << " time: " << Limits.time[RootPos.side_to_move()]
- << " increment: " << Limits.inc[RootPos.side_to_move()]
- << " moves to go: " << Limits.movestogo
- << "\n" << std::endl;
- }
-
// Reset the threads, still sleeping: will wake up at split time
for (size_t i = 0; i < Threads.size(); ++i)
Threads[i]->maxPly = 0;
Threads.timer->run = false; // Stop the timer
- if (Options["Write Search Log"])
- {
- Time::point elapsed = Time::now() - SearchTime + 1;
-
- Log log(Options["Search Log Filename"]);
- log << "Nodes: " << RootPos.nodes_searched()
- << "\nNodes/second: " << RootPos.nodes_searched() * 1000 / elapsed
- << "\nBest move: " << move_to_uci(RootMoves[0].pv[0], RootPos.is_chess960())
- << "\nPonder move: " << move_to_uci(RootMoves[0].pv[1], RootPos.is_chess960())
- << std::endl;
- }
-
finalize:
// When search is stopped this info is not printed
if (skill.candidates_size() && skill.time_to_pick(depth))
skill.pick_move();
- if (Options["Write Search Log"])
- {
- RootMove& rm = RootMoves[0];
- if (skill.best != MOVE_NONE)
- rm = *std::find(RootMoves.begin(), RootMoves.end(), skill.best);
-
- Log log(Options["Search Log Filename"]);
- log << pretty_pv(pos, depth, rm.score, Time::now() - SearchTime, &rm.pv[0])
- << std::endl;
- }
-
// Have we found a "mate in x"?
if ( Limits.mate
&& bestValue >= VALUE_MATE_IN_MAX_PLY
void init(OptionsMap& o) {
o["Write Debug Log"] << Option(false, on_logger);
- o["Write Search Log"] << Option(false);
- o["Search Log Filename"] << Option("SearchLog.txt");
o["Contempt Factor"] << Option(0, -100, 100);
o["Min Split Depth"] << Option(0, 0, 12, on_threads);
o["Threads"] << Option(1, 1, MAX_THREADS, on_threads);