struct ExtMove {
Move move;
Value value;
+
+ operator Move() const { return move; }
};
inline bool operator<(const ExtMove& f, const ExtMove& s) {
const ExtMove* begin() const { return moveList; }
const ExtMove* end() const { return last; }
size_t size() const { return last - moveList; }
- bool contains(Move m) const {
- for (const ExtMove& ms : *this) if (ms.move == m) return true;
+ bool contains(Move move) const {
+ for (const auto& m : *this) if (m == move) return true;
return false;
}
CheckInfo ci(pos);
const bool leaf = (depth == 2 * ONE_PLY);
- for (const ExtMove& ms : MoveList<LEGAL>(pos))
+ for (const auto& m : MoveList<LEGAL>(pos))
{
if (Root && depth <= ONE_PLY)
cnt = 1, nodes++;
else
{
- pos.do_move(ms.move, st, ci, pos.gives_check(ms.move, ci));
+ pos.do_move(m, st, ci, pos.gives_check(m, ci));
cnt = leaf ? MoveList<LEGAL>(pos).size() : perft<false>(pos, depth - ONE_PLY);
nodes += cnt;
- pos.undo_move(ms.move);
+ pos.undo_move(m);
}
if (Root)
- sync_cout << UCI::move(ms.move, pos.is_chess960()) << ": " << cnt << sync_endl;
+ sync_cout << UCI::move(m, pos.is_chess960()) << ": " << cnt << sync_endl;
}
return nodes;
}
assert(!states.get());
}
- for (const ExtMove& ms : MoveList<LEGAL>(pos))
+ for (const auto& m : MoveList<LEGAL>(pos))
if ( limits.searchmoves.empty()
- || std::count(limits.searchmoves.begin(), limits.searchmoves.end(), ms.move))
- RootMoves.push_back(RootMove(ms.move));
+ || std::count(limits.searchmoves.begin(), limits.searchmoves.end(), m))
+ RootMoves.push_back(RootMove(m));
main()->thinking = true;
main()->notify_one(); // Starts main thread
if (str.length() == 5) // Junior could send promotion piece in uppercase
str[4] = char(tolower(str[4]));
- for (const ExtMove& ms : MoveList<LEGAL>(pos))
- if (str == UCI::move(ms.move, pos.is_chess960()))
- return ms.move;
+ for (const auto& m : MoveList<LEGAL>(pos))
+ if (str == UCI::move(m, pos.is_chess960()))
+ return m;
return MOVE_NONE;
}
std::ostream& operator<<(std::ostream& os, const OptionsMap& om) {
for (size_t idx = 0; idx < om.size(); ++idx)
- for (auto& it : om)
+ for (const auto& it : om)
if (it.second.idx == idx)
{
const Option& o = it.second;