diff options
author | pommicket <pommicket@gmail.com> | 2025-08-07 21:56:29 -0400 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2025-08-07 21:56:29 -0400 |
commit | af95032f803d6e74e704aa4ed9aafad71f389f4f (patch) | |
tree | aa90483fb8e072f3ef8198c4330dfd35f3566ea7 /quacker/macondo.cpp | |
parent | 0b60755eb7c38ae2995690f57ce405b5f0052f0f (diff) |
send position to macondo
Diffstat (limited to 'quacker/macondo.cpp')
-rw-r--r-- | quacker/macondo.cpp | 19 |
1 files changed, 17 insertions, 2 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() { |