- // Restore original position before to leave
- while (m != pv) pos.undo_move(*--m);
-
- return s.str();
-}
-
-
-namespace {
-
- Ambiguity move_ambiguity(const Position& pos, Move m) {
-
- MoveStack mlist[MOVES_MAX];
- Piece pc = pos.piece_on(move_from(m));
- int f = 0, r = 0;
-
- MoveStack* last = generate<MV_LEGAL>(pos, mlist);
-
- // Collect all legal moves of piece 'pc' with destination 'to'
- for (MoveStack* cur = mlist; cur != last; cur++)
- {
- if ( move_to(cur->move) == move_to(m)
- && pos.piece_on(move_from(cur->move)) == pc)
- {
- if (square_file(move_from(cur->move)) == square_file(move_from(m)))
- f++;
-
- if (square_rank(move_from(cur->move)) == square_rank(move_from(m)))
- r++;
- }
- }
-
- assert(f > 0 && r > 0);
-
- return f == 1 ? (r == 1 ? AMBIGUITY_NONE : AMBIGUITY_FILE)
- : (r == 1 ? AMBIGUITY_RANK : AMBIGUITY_BOTH);
- }
-
-
- const string time_string(int millisecs) {
-
- const int MSecMinute = 1000 * 60;
- const int MSecHour = 1000 * 60 * 60;
-
- int hours = millisecs / MSecHour;
- int minutes = (millisecs % MSecHour) / MSecMinute;
- int seconds = ((millisecs % MSecHour) % MSecMinute) / 1000;
-
- std::stringstream s;
-
- if (hours)
- s << hours << ':';
-
- s << std::setfill('0') << std::setw(2) << minutes << ':' << std::setw(2) << seconds;
- return s.str();
- }
-
-
- const string score_string(Value v) {
-
- std::stringstream s;
-
- if (v >= VALUE_MATE - 200)
- s << "#" << (VALUE_MATE - v + 1) / 2;
- else if (v <= -VALUE_MATE + 200)
- s << "-#" << (VALUE_MATE + v) / 2;
- else
- s << std::setprecision(2) << std::fixed << std::showpos << float(v) / PawnValueMidgame;
-
- return s.str();
- }