diff options
-rw-r--r-- | move.h | 4 | ||||
-rw-r--r-- | quacker/macondo.cpp | 3 | ||||
-rw-r--r-- | quacker/macondobackend.cpp | 17 | ||||
-rw-r--r-- | quacker/movebox.cpp | 5 |
4 files changed, 19 insertions, 10 deletions
@@ -59,8 +59,8 @@ public: int startrow = 0; int startcol = 0; - // Human-readable outcomes for pre-endgame solving - std::string outcomes; + // Human-readable extra information about move (e.g. used for pre-endgame outcomes) + std::string comment; // returns whether this is not a Nonmove bool isAMove() const; diff --git a/quacker/macondo.cpp b/quacker/macondo.cpp index 6a20c2d..831e94d 100644 --- a/quacker/macondo.cpp +++ b/quacker/macondo.cpp @@ -1,9 +1,12 @@ /* TODO: +- pre-endgame solve w generated moves only - configurable execPath +- save options - detect Macondo crashing? - stop Macondo solve when game position changes - configurable max plies +- other peg/endgame options */ #include "macondo.h" diff --git a/quacker/macondobackend.cpp b/quacker/macondobackend.cpp index d5c00c9..20d54ba 100644 --- a/quacker/macondobackend.cpp +++ b/quacker/macondobackend.cpp @@ -296,7 +296,6 @@ static bool extractEndgameMove(QByteArray &processOutput, Quackle::Move &move) { seqStart += endgameBestSeqMarker.length(); string sequenceStr(processOutput.data() + seqStart, processOutput.size() - seqStart); vector<string> sequence = splitLines(sequenceStr); - // TODO: do something with rest of moves? or just extract first move? const string &firstMove = sequence[0]; vector<string> moveWords = splitWords(firstMove); bool ok = false; @@ -311,9 +310,9 @@ static bool extractEndgameMove(QByteArray &processOutput, Quackle::Move &move) { if (parseInt(scoreInParentheses.substr(1), score, &scoreLen)) { scoreIsValid = scoreLen == scoreInParentheses.length() - 2; } - if (scoreIsValid) { + if (scoreIsValid) { move.score = score; - } else { + } else { qWarning("bad move score syntax: %s", scoreInParentheses.c_str()); } ok = true; @@ -325,7 +324,14 @@ static bool extractEndgameMove(QByteArray &processOutput, Quackle::Move &move) { } processOutput.clear(); if (ok) { + std::stringstream remainingSequence; + // show remainder of sequence as comment on Move + for (size_t i = 1; i < sequence.size(); i++) { + if (i > 1) remainingSequence << " "; + remainingSequence << sequence[i]; + } move.equity = spreadDiff; + move.comment = remainingSequence.str(); move.win = finalSpread < 0 ? 0.0 // loss/something went wrong : finalSpread == 0 ? 0.5 // draw : 1.0; // win @@ -363,7 +369,7 @@ static Quackle::Move extractPreEndgameMove(const string &moveStr) { move.equity = parseEquity(words[2]); else move.equity = -999 + 0.01 * move.win; // ensure moves are still sorted by win% - move.outcomes = outcomes; + move.comment = outcomes; return move; } @@ -441,7 +447,7 @@ void MacondoBackend::timer() { } break; } - if (int i; (i = m_processStderr.lastIndexOf(preEndgameStartingMarker)) != -1 + if (int i = m_processStderr.lastIndexOf(preEndgameStartingMarker); i != -1 && m_processStderr.indexOf('\n', i) != -1) { removeTempGCG(); // extract # of plays Macondo will analyze @@ -502,6 +508,7 @@ void MacondoBackend::timer() { int currBestMarkerIdx = m_processStderr.lastIndexOf(endgameCurrBestMarker, lastNewline); std::string currBest; if (currBestMarkerIdx != -1) { + removeTempGCG(); int currBestStart = currBestMarkerIdx + endgameCurrBestMarker.length(); int currBestEnd = m_processStderr.indexOf('"', currBestStart); if (currBestEnd != -1) { diff --git a/quacker/movebox.cpp b/quacker/movebox.cpp index 9370fdb..5ca9572 100644 --- a/quacker/movebox.cpp +++ b/quacker/movebox.cpp @@ -262,10 +262,9 @@ QTreeWidgetItem *MoveBox::createItem(const Quackle::Move &move) item->setText(LeaveColumn, QuackleIO::Util::letterStringToQString(QuackleIO::Util::arrangeLettersForUser(m_rack - move))); item->setText(WinPercentageColumn, formatWinPercentage(move.win)); item->setText(EquityColumn, formatValuation(move.equity)); - if (!move.outcomes.empty()) { - // show Macondo pre-endgame outcomes when item is hovered over + if (!move.comment.empty()) { for (int column = 0; column < m_treeWidget->columnCount(); column++) { - item->setToolTip(column, QString::fromStdString(move.outcomes)); + item->setToolTip(column, QString::fromStdString(move.comment)); } } return item; |