blob: 55d5deb69b9e09ccee52f151289b9b3cfb07ff18 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#include "macondo.h"
#include "macondobackend.h"
#include "movebox.h"
#include "quacker.h"
#include <QGridLayout>
#include <QPushButton>
#include <QCheckBox>
Macondo::Macondo(Quackle::Game *game, MoveBox *moveBox) : View() {
m_game = game;
m_moveBox = moveBox;
QGridLayout *layout = new QGridLayout(this);
m_useMacondo = new QCheckBox(tr("Use Macondo for 'Simulate'"));
layout->setAlignment(Qt::AlignTop);
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_backend, SIGNAL(gotSimMoves(const Quackle::MoveList *)), this, SIGNAL(newMoves(const Quackle::MoveList *)));
}
Macondo::~Macondo() {
delete m_backend;
}
void Macondo::simulate() {
if (m_backend->isRunning()) {
// stop analysis
stop();
return;
}
MacondoSimulateOptions options;
m_backend->simulate(options);
}
void Macondo::setGame(Quackle::Game *game) {
delete m_backend;
m_backend = new MacondoBackend(game, *initOptions);
m_game = game;
}
void Macondo::stop() {
m_backend->stop();
}
bool Macondo::useForSimulation() const {
return m_useMacondo->isChecked();
}
|