/*
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
- Copyright (C) 2008-2010 Marco Costalba, Joona Kiiski, Tord Romstad
+ Copyright (C) 2008-2012 Marco Costalba, Joona Kiiski, Tord Romstad
Stockfish is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
RootMove(){}
RootMove(Move m) {
- nodes = 0;
score = prevScore = -VALUE_INFINITE;
pv.push_back(m);
pv.push_back(MOVE_NONE);
void extract_pv_from_tt(Position& pos);
void insert_pv_in_tt(Position& pos);
- int64_t nodes;
Value score;
Value prevScore;
std::vector<Move> pv;
int64_t Search::perft(Position& pos, Depth depth) {
StateInfo st;
- int64_t sum = 0;
+ int64_t cnt = 0;
MoveList<MV_LEGAL> ml(pos);
// At the last ply just return the number of moves (leaf nodes)
- if (depth <= ONE_PLY)
+ if (depth == ONE_PLY)
return ml.size();
CheckInfo ci(pos);
for ( ; !ml.end(); ++ml)
{
pos.do_move(ml.move(), st, ci, pos.move_gives_check(ml.move(), ci));
- sum += perft(pos, depth - ONE_PLY);
+ cnt += perft(pos, depth - ONE_PLY);
pos.undo_move(ml.move());
}
- return sum;
+ return cnt;
}
|| count(SearchMoves.begin(), SearchMoves.end(), ml.move()))
RootMoves.push_back(RootMove(ml.move()));
- if (Options["OwnBook"].value<bool>())
+ if (Options["OwnBook"])
{
- if (Options["Book File"].value<string>() != book.name())
- book.open(Options["Book File"].value<string>());
+ if (book.name() != (string)Options["Book File"])
+ book.open(Options["Book File"]);
- Move bookMove = book.probe(pos, Options["Best Book Move"].value<bool>());
+ Move bookMove = book.probe(pos, Options["Best Book Move"]);
if ( bookMove != MOVE_NONE
&& count(RootMoves.begin(), RootMoves.end(), bookMove))
read_evaluation_uci_options(pos.side_to_move());
Threads.read_uci_options();
- TT.set_size(Options["Hash"].value<int>());
- if (Options["Clear Hash"].value<bool>())
+ TT.set_size(Options["Hash"]);
+ if (Options["Clear Hash"])
{
Options["Clear Hash"] = false;
TT.clear();
}
- UCIMultiPV = Options["MultiPV"].value<size_t>();
- SkillLevel = Options["Skill Level"].value<int>();
+ UCIMultiPV = Options["MultiPV"];
+ SkillLevel = Options["Skill Level"];
// Do we have to play with skill handicap? In this case enable MultiPV that
// we will use behind the scenes to retrieve a set of possible moves.
SkillLevelEnabled = (SkillLevel < 20);
MultiPV = (SkillLevelEnabled ? std::max(UCIMultiPV, (size_t)4) : UCIMultiPV);
- if (Options["Use Search Log"].value<bool>())
+ if (Options["Use Search Log"])
{
- Log log(Options["Search Log Filename"].value<string>());
+ Log log(Options["Search Log Filename"]);
log << "\nSearching: " << pos.to_fen()
<< "\ninfinite: " << Limits.infinite
<< " ponder: " << Limits.ponder
Threads.set_timer(0);
Threads.set_size(1);
- if (Options["Use Search Log"].value<bool>())
+ if (Options["Use Search Log"])
{
int e = elapsed_time();
- Log log(Options["Search Log Filename"].value<string>());
+ Log log(Options["Search Log Filename"]);
log << "Nodes: " << pos.nodes_searched()
<< "\nNodes/second: " << (e > 0 ? pos.nodes_searched() * 1000 / e : 0)
<< "\nBest move: " << move_to_san(pos, RootMoves[0].pv[0]);
if (SkillLevelEnabled && depth == 1 + SkillLevel)
skillBest = do_skill_level();
- if (Options["Use Search Log"].value<bool>())
+ if (Options["Use Search Log"])
pv_info_to_log(pos, depth, bestValue, elapsed_time(), &RootMoves[0].pv[0]);
// Filter out startup noise when monitoring best move stability
assert(pos.thread() >= 0 && pos.thread() < Threads.size());
Move movesSearched[MAX_MOVES];
- int64_t nodes;
StateInfo st;
const TTEntry *tte;
Key posKey;
if (RootNode)
{
Signals.firstRootMove = (moveCount == 1);
- nodes = pos.nodes_searched();
if (pos.thread() == 0 && elapsed_time() > 2000)
cout << "info depth " << depth / ONE_PLY
if (RootNode && !Signals.stop)
{
RootMove& rm = *find(RootMoves.begin(), RootMoves.end(), move);
- rm.nodes += pos.nodes_searched() - nodes;
// PV move or new best move ?
if (isPvMove || value > alpha)
while (m != pv)
pos.undo_move(*--m);
- Log l(Options["Search Log Filename"].value<string>());
+ Log l(Options["Search Log Filename"]);
l << s.str() << endl;
}