summaryrefslogtreecommitdiff
path: root/quacker
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2025-08-21 14:14:52 -0400
committerpommicket <pommicket@gmail.com>2025-08-21 14:14:52 -0400
commitfe37762ef767818eb7edfb8de4e64bc638b3db5b (patch)
treebc1f1344d9d714567155b09a0f19d06197e0fb52 /quacker
parent2a724471eb4c588b9f28dc807cb9eae7a1cfaf2f (diff)
Show endgame sequence in move comment
Diffstat (limited to 'quacker')
-rw-r--r--quacker/macondo.cpp3
-rw-r--r--quacker/macondobackend.cpp17
-rw-r--r--quacker/movebox.cpp5
3 files changed, 17 insertions, 8 deletions
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;