summaryrefslogtreecommitdiff
path: root/quacker
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2025-08-21 18:36:29 -0400
committerpommicket <pommicket@gmail.com>2025-08-21 18:36:29 -0400
commita71b0ecc36665c8d28d19e0c0e06f70713b816ab (patch)
treed014c028ac6425867184918fc35606898bd8d016 /quacker
parentf7bba783ccf693ccb92c870562931ef3377852f0 (diff)
Editable Macondo executable path
Diffstat (limited to 'quacker')
-rw-r--r--quacker/macondo.cpp33
-rw-r--r--quacker/macondo.h6
-rw-r--r--quacker/macondobackend.h3
3 files changed, 32 insertions, 10 deletions
diff --git a/quacker/macondo.cpp b/quacker/macondo.cpp
index d43395b..a5776e9 100644
--- a/quacker/macondo.cpp
+++ b/quacker/macondo.cpp
@@ -1,10 +1,9 @@
/*
TODO:
-- pre-endgame solve w generated moves only
- configurable execPath
+ - Choose file... button
- save options
- detect Macondo crashing?
-- stop Macondo solve when game position changes
- configurable max plies
- other peg/endgame options
*/
@@ -18,6 +17,7 @@ TODO:
#include <QLabel>
#include <QGroupBox>
#include <QMessageBox>
+#include <QLineEdit>
Macondo::Macondo(Quackle::Game *game) : View() {
m_game = game;
@@ -27,9 +27,12 @@ Macondo::Macondo(Quackle::Game *game) : View() {
const char *home = getenv("HOME");
std::string execPath = home ? home : "/";
execPath += "/apps/macondo/macondo";
- initOptions = std::make_unique<MacondoInitOptions>(execPath);
- m_backend = new MacondoBackend(game, *initOptions);
+ m_initOptions = std::make_unique<MacondoInitOptions>(execPath);
+ m_backend = new MacondoBackend(game, *m_initOptions);
connectBackendSignals();
+ QLabel *execPathLabel = new QLabel(tr("Macondo executable"));
+ QPushButton *selectExecButton = new QPushButton(tr("Choose File..."));
+ m_execPath = new QLineEdit;
m_solve = new QPushButton(tr("Solve"));
m_solve->setDisabled(true);
QGroupBox *pegBox = new QGroupBox(tr("Pre-endgame options"));
@@ -37,19 +40,31 @@ Macondo::Macondo(Quackle::Game *game) : View() {
m_generatedMovesOnly = new QCheckBox(tr("Generated moves only"));
m_generatedMovesOnly->setToolTip("Only analyze the moves that have been generated in the 'Choices' box.");
pegLayout->addWidget(m_generatedMovesOnly);
- QGridLayout *layout = new QGridLayout(this);
pegBox->setLayout(pegLayout);
+ QHBoxLayout *execPathLayout = new QHBoxLayout;
+ execPathLayout->addWidget(execPathLabel);
+ execPathLayout->addWidget(m_execPath);
+ execPathLayout->addWidget(selectExecButton);
+ QVBoxLayout *layout = new QVBoxLayout(this);
layout->setAlignment(Qt::AlignTop);
- layout->addWidget(m_useMacondo, 0, 0);
- layout->addWidget(pegBox, 1, 0);
- layout->addWidget(m_solve, 2, 0);
+ layout->addLayout(execPathLayout);
+ layout->addWidget(m_useMacondo);
+ layout->addWidget(pegBox);
+ layout->addWidget(m_solve);
connect(m_solve, SIGNAL(clicked()), this, SLOT(solve()));
+ connect(m_execPath, SIGNAL(editingFinished()), this, SLOT(newExecPath()));
}
Macondo::~Macondo() {
delete m_backend;
}
+void Macondo::newExecPath() {
+ std::string newPath = m_execPath->text().toStdString();
+ m_backend->setExecPath(newPath);
+ m_initOptions->execPath = newPath;
+}
+
void Macondo::simulate() {
if (m_isSolving) {
// don't start a simulation if we're solving a (pre-)endgame
@@ -96,7 +111,7 @@ void Macondo::solve() {
void Macondo::gameChanged(Quackle::Game *game) {
delete m_backend;
- m_backend = new MacondoBackend(game, *initOptions);
+ m_backend = new MacondoBackend(game, *m_initOptions);
connectBackendSignals();
m_game = game;
}
diff --git a/quacker/macondo.h b/quacker/macondo.h
index a8916c9..406cc31 100644
--- a/quacker/macondo.h
+++ b/quacker/macondo.h
@@ -6,9 +6,11 @@
class QCheckBox;
class QPushButton;
+class QLineEdit;
class MacondoBackend;
struct MacondoInitOptions;
class MoveBox;
+
class Macondo : public View {
Q_OBJECT
public:
@@ -39,11 +41,13 @@ public slots:
void positionChanged(const Quackle::GamePosition *position) override;
private slots:
void gotMoves(const Quackle::MoveList &moves);
+ void newExecPath();
private:
void connectBackendSignals();
void updateSolveButton();
QCheckBox *m_useMacondo;
QCheckBox *m_generatedMovesOnly;
+ QLineEdit *m_execPath;
QPushButton *m_solve;
Quackle::Game *m_game;
MacondoBackend *m_backend;
@@ -53,7 +57,7 @@ private:
int m_viewingPlyNumber = 0;
bool m_anyUpdates = false;
bool m_isSolving = false;
- std::unique_ptr<MacondoInitOptions> initOptions;
+ std::unique_ptr<MacondoInitOptions> m_initOptions;
};
#endif
diff --git a/quacker/macondobackend.h b/quacker/macondobackend.h
index dfc4fc9..bda9048 100644
--- a/quacker/macondobackend.h
+++ b/quacker/macondobackend.h
@@ -33,6 +33,9 @@ public:
void solveEndgame(const MacondoEndgameOptions &options);
void solvePreEndgame(const MacondoPreEndgameOptions &options);
std::string getSimResults();
+ inline void setExecPath(const std::string &path) {
+ m_execPath = path;
+ }
inline bool isRunning() const { return m_command != Command::None; }
// stop current Macondo analysis
void stop();