summaryrefslogtreecommitdiff
path: root/quacker/macondo.cpp
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2025-08-12 23:04:05 -0400
committerpommicket <pommicket@gmail.com>2025-08-12 23:04:05 -0400
commite43c01bd11560561daa771463c57442c3b8a761d (patch)
treea040ea23eaf10d8a7362f523777a8b61e8b55041 /quacker/macondo.cpp
parenta1a21037c465a1a01b2ca13b70f89becfc93546e (diff)
Integrate Macondo into move chooser
Diffstat (limited to 'quacker/macondo.cpp')
-rw-r--r--quacker/macondo.cpp37
1 files changed, 20 insertions, 17 deletions
diff --git a/quacker/macondo.cpp b/quacker/macondo.cpp
index c089b42..55d5deb 100644
--- a/quacker/macondo.cpp
+++ b/quacker/macondo.cpp
@@ -5,45 +5,48 @@
#include <QGridLayout>
#include <QPushButton>
+#include <QCheckBox>
-Macondo::Macondo(Quackle::Game *game) : QWidget() {
+Macondo::Macondo(Quackle::Game *game, MoveBox *moveBox) : View() {
m_game = game;
+ m_moveBox = moveBox;
QGridLayout *layout = new QGridLayout(this);
- m_moveBox = new MoveBox;
- m_simulateButton = new QPushButton(tr("Simulate"));
+ m_useMacondo = new QCheckBox(tr("Use Macondo for 'Simulate'"));
layout->setAlignment(Qt::AlignTop);
- layout->addWidget(m_simulateButton, 0, 0);
- layout->addWidget(m_moveBox, 1, 0);
+ layout->addWidget(m_useMacondo, 0, 0);
const char *home = getenv("HOME");
// TODO: configurable path
std::string execPath = home ? home : "/";
execPath += "/apps/macondo/macondo";
initOptions = std::make_unique<MacondoInitOptions>(execPath);
m_backend = new MacondoBackend(game, *initOptions);
- connect(m_simulateButton, SIGNAL(clicked()), this, SLOT(simulate()));
- connect(m_backend, SIGNAL(gotSimMoves(const Quackle::MoveList &)), this, SLOT(gotSimMoves(const Quackle::MoveList &)));
+ connect(m_backend, SIGNAL(gotSimMoves(const Quackle::MoveList *)), this, SIGNAL(newMoves(const Quackle::MoveList *)));
}
-Macondo::~Macondo() {}
+Macondo::~Macondo() {
+ delete m_backend;
+}
void Macondo::simulate() {
+ if (m_backend->isRunning()) {
+ // stop analysis
+ stop();
+ return;
+ }
MacondoSimulateOptions options;
m_backend->simulate(options);
- m_moveBox->positionChanged(&m_game->currentPosition());
}
-
void Macondo::setGame(Quackle::Game *game) {
delete m_backend;
m_backend = new MacondoBackend(game, *initOptions);
m_game = game;
}
-void Macondo::gotSimMoves(const Quackle::MoveList &moves) {
- m_moveBox->movesChanged(&moves);
- /*printf("got %zu moves\n",moves.size());
- for (const Quackle::Move &move: moves) {
- std::cout << move << std::endl;
- }
- */
+void Macondo::stop() {
+ m_backend->stop();
+}
+
+bool Macondo::useForSimulation() const {
+ return m_useMacondo->isChecked();
}