summaryrefslogtreecommitdiff
path: root/quacker
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2025-08-07 21:56:29 -0400
committerpommicket <pommicket@gmail.com>2025-08-07 21:56:29 -0400
commitaf95032f803d6e74e704aa4ed9aafad71f389f4f (patch)
treeaa90483fb8e072f3ef8198c4330dfd35f3566ea7 /quacker
parent0b60755eb7c38ae2995690f57ce405b5f0052f0f (diff)
send position to macondo
Diffstat (limited to 'quacker')
-rw-r--r--quacker/macondo.cpp19
-rw-r--r--quacker/macondo.h8
-rw-r--r--quacker/quacker.cpp2
3 files changed, 25 insertions, 4 deletions
diff --git a/quacker/macondo.cpp b/quacker/macondo.cpp
index 476d41b..eda49e3 100644
--- a/quacker/macondo.cpp
+++ b/quacker/macondo.cpp
@@ -5,8 +5,10 @@
#include <QPushButton>
#include <QProcess>
#include <QTimer>
+#include <random>
-Macondo::Macondo(QWidget *parent) : QWidget(parent) {
+Macondo::Macondo(TopLevel *topLevel) : QWidget() {
+ m_topLevel = topLevel;
m_updateTimer = new QTimer(this);
QGridLayout *layout = new QGridLayout(this);
m_runButton = new QPushButton(tr("Run"));
@@ -32,7 +34,20 @@ void Macondo::run() {
void Macondo::processStarted() {
m_updateTimer->start();
- m_process->write("help\n");
+ std::default_random_engine rand;
+ std::uniform_int_distribution<int> distribution(0, 26);
+ // save game file with random name
+ char filename[] = "tmpGameXXXXXXXXXXXX.gcg";
+ for (int i = 0; filename[i]; i++) {
+ if (filename[i] == 'X') {
+ filename[i] = distribution(rand) + 'A';
+ }
+ }
+ m_topLevel->writeFile(filename);
+ std::string command = "load ";
+ command += filename;
+ command += "\n";
+ m_process->write(command.c_str());
}
void Macondo::updateResults() {
diff --git a/quacker/macondo.h b/quacker/macondo.h
index e6eb749..2490e2f 100644
--- a/quacker/macondo.h
+++ b/quacker/macondo.h
@@ -1,20 +1,26 @@
#include <QWidget>
+#include "game.h"
class QPushButton;
class QProcess;
class QTimer;
+class TopLevel;
class Macondo : public QWidget {
Q_OBJECT
public:
- explicit Macondo(QWidget *parent = 0);
+ Macondo(TopLevel *topLevel);
public slots:
void run();
void updateResults();
void processStarted();
+ void movesUpdated(Quackle::MoveList *moves);
+ inline void setGame(Quackle::Game *game) { m_game = game; }
private:
+ TopLevel *m_topLevel;
QPushButton *m_runButton;
QTimer *m_updateTimer;
std::string m_execPath;
QProcess *m_process = nullptr;
+ Quackle::Game *m_game = nullptr;
};
diff --git a/quacker/quacker.cpp b/quacker/quacker.cpp
index 0270302..e9a8549 100644
--- a/quacker/quacker.cpp
+++ b/quacker/quacker.cpp
@@ -68,7 +68,7 @@ TopLevel::TopLevel(QWidget *parent)
qRegisterMetaType<OppoThread*>("OppoThread*");
m_quackerSettings = new QuackerSettings;
- m_macondo = new Macondo;
+ m_macondo = new Macondo(this);
m_settings = new Settings;
m_settings->preInitialize();
m_settings->createGUI();