summaryrefslogtreecommitdiff
path: root/quacker/macondo.h
blob: a8a61b924bc8fd07ec6e09e62c9b95bbec70fb53 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifndef MACONDO_H
#define MACONDO_H

#include "view.h"
#include "game.h"

class MacondoBackend;
struct MacondoInitOptions;
class MoveBox;
class QCheckBox;
class QPushButton;
class QLineEdit;
class QPlainTextEdit;
class QSpinBox;

class Macondo : public View {
Q_OBJECT
public:
	Macondo(Quackle::Game *game);
	~Macondo();
	// stop current analysis
	void stop();
	// should Macondo be used for simulations?
	bool useForSimulation() const;
	// returns whether there have been any updates to moves since last time anyUpdates() was called.
	inline bool anyUpdates() {
		bool any = m_anyUpdates;
		m_anyUpdates = false;
		return any;
	}
	bool isRunning() const;
	// Start Macondo simulation -- returns false if there was an error starting Macondo.
	bool simulate();
	inline bool isSolving() const { return m_isSolving; }
signals:
	void runningSolver();
	void stoppedSolver();
public slots:
	void solve();
	void gameChanged(Quackle::Game *game) override;
	void positionChanged(const Quackle::GamePosition *position) override;
private slots:
	void newLogOutput(const QByteArray &text);
	void gotMoves(const Quackle::MoveList &moves);
	void execPathChanged();
	void chooseExecPath();
private:
	void clearLog();
	void setExecPath(const std::string &);
	void connectBackendSignals();
	bool checkExecPath();
	void updateSolveButton();

	// == options ==
	QCheckBox *m_useMacondo;
	QLineEdit *m_execPath;

	// == endgame options ==
	QSpinBox *m_endgameMaxPlies;
	QCheckBox *m_firstWinOptimization;
	QCheckBox *m_preventSlowRoll;

	// == pre-endgame options ===
	QCheckBox *m_generatedMovesOnly;
	QCheckBox *m_earlyCutoff;
	QCheckBox *m_skipNonEmptying;
	QCheckBox *m_skipTieBreaker;
	QLineEdit *m_opponentRack;
	QSpinBox *m_preEndgameMaxPlies;

	QPushButton *m_solve;
	QPlainTextEdit *m_log;
	QByteArray m_logPartialUtf8;
	Quackle::Game *m_game;
	MacondoBackend *m_backend;
	Quackle::MoveList m_movesFromKibitzer;
	int m_tilesUnseen = 93;
	int m_viewingPlyNumber = 0;
	int m_logANSIState = 0;
	bool m_anyUpdates = false;
	bool m_isSolving = false;
	std::unique_ptr<MacondoInitOptions> m_initOptions;
};

#endif