-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgamemodel.h
71 lines (59 loc) · 1.8 KB
/
gamemodel.h
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
#ifndef GAMEMODEL_H
#define GAMEMODEL_H
#include <QObject>
#include <QRandomGenerator>
#include <QTimer>
#include <QTime>
#include "tilemodel.h"
class GameModel : public QObject
{
Q_OBJECT
private:
size_t _DIM;
size_t totalPlayTime;
size_t totalSteps;
size_t algoType = GameModel::Depth;
QRandomGenerator gen; // for random values
QVector<int> startTile;
QVector<QVector<QVector<bool>>> answer;
QVector<QVector<QVector<bool>>> resetVector;
QTimer *timer;
void clearEverything();
QVector<QVector<QVector<bool>>> depthAlgo();
QVector<QVector<QVector<bool>>> primAlgo();
public:
enum GameType{Depth = 0, Prim};
explicit GameModel(size_t size = 7, size_t gameSeed = QRandomGenerator::global()->bounded(0, INT_MAX), QObject *parent = nullptr);
bool gameStarted = false;
QVector<QVector<TileModel*>> game;
void initializeGame(int algo = GameModel::Depth);
void setSize(size_t size);
void setGameSeed(size_t seed);
int getBounded(int lowest, int highest);
size_t getSize() const;
QString getAlgoType();
signals:
void onGameInitialization(bool clearStatus = false);
QString sendSteps(QString totalSteps);
QString sendTime(QString totalTime);
QString sendGameSeed(QString seed);
bool onGameStatus(bool status); // true, if this is a solution
void gameStart();
void initializedNewGame();
public slots:
void setSteps() {
if (!this->gameStarted) {
this->gameStarted = true;
emit this->gameStart();
}
++totalSteps;
emit sendSteps(QString::number(totalSteps));
}
void setTime();
bool checkAnswer();
void resetGame();
void showSolution();
void showSolutionOnRandomTile();
void changeGameStarted(bool started);
};
#endif // GAMEMODEL_H