Move StrToMove(const std::string& str, Position& pos) { for (std::string::const_iterator it = str.begin(); it != str.end(); ++it) { if (isdigit(*it) || *it == 'O') break; if (*it == ' ' || *it == 0) return 0; } MoveList mvlist; mvlist.GenAllMoves(pos); for (int n = 0; n < mvlist.Size(); ++n) { Move mv = mvlist[n].m_mv; if (MoveToStrLong(mv) == str) return mv; } for (int n = 0; n < mvlist.Size(); ++n) { Move mv = mvlist[n].m_mv; if (MoveToStrShort(mv, pos) == str) return mv; } return 0; }
void Position::Print() const { const char names[] = "-?PpNnBbRrQqKk"; out("\n"); for (int f = 0; f < 64; f++) { PIECE p = m_board[f]; Highlight (p && GetColor(p) == WHITE); out(" %c", names[p]); Highlight(false); if (Col(f) == 7) out("\n"); } if (m_undoSize) { out("\n "); for (int m = 0; m < m_undoSize; ++m) out("%s ", MoveToStrLong(m_undos[m].m_mv)); out("\n "); } out("\n"); }