-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMaze.h
110 lines (86 loc) · 2.64 KB
/
Maze.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#ifndef __MAZE__HEADER__INCLUDED__
#define __MAZE__HEADER__INCLUDED__
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <ctime>
#include "InterfaceFunctions.h"
#include "Position.h"
typedef std::vector<std::vector<Position>> MAZE;
typedef std::vector<std::vector<bool>> VISITED_MATRIX;
typedef std::vector<std::vector<PositionInformation>> POSITIONS_INFO;
const int DIRECTIONS = 4;
const int ONE_STEP = 1;
const char WHITE_SQUARE = 0xDB;
const char BLACK_SQUARE = 0xFF;
const int DX[] = { -1,0,0,1 };
const int DY[] = { 0,-1,1,0 };
class Maze
{
private:
MAZE field;
size_t x_size;
size_t y_size;
int monsters;
RACE_CHOICE race_choice;
unsigned free_cells;
Position* character_pos;
std::queue<Coordinates>* movingPath;
std::vector<Position*> monsters_list;
public:
Maze();
Maze(const MAZE&, int, int, int);
Maze(const Maze&) = default;
Maze& operator=(const Maze&) = default;
~Maze();
public:
bool startLevel(RACE_CHOICE);
bool validMazeCheck()const;
bool operator<(const Maze&)const;
inline int getSize()const;
inline int getMonsters()const;
void setFreeCells(unsigned);
private:
bool startGame();
bool haveReachedPortal()const;
bool killedByMonster()const;
void restartLevel();
void setStartAndPortal();
void setCharacterCell(RACE_CHOICE);
void spawnMonsters();
void spawnMonster();
bool canSpawn(unsigned, unsigned)const;
void addMonsterToList(int,int);
void changeMonsterList(int, int, int, int);
void moveMonsters();
void moveMonster(int, int, int, int);
void generateMagusPath();
void DFS_iterative(); //Used for generating a path in maze going in a streight direction until a hidrance is met.
void changeMagusDirection(MOVING_DIRECTION&)const;
void generateEnchanterPath();
void pathTracing(const POSITIONS_INFO&);
void aStarAlgorithm(); //Use for generating the shortest path using additional heuristics for calculating the current shortest path to the sink node.
void initPositionInfo(POSITIONS_INFO&)const;
double calcHdist(int, int)const;
void moveCharacter();
bool BFS()const;
bool markedUnvisited(VISITED_MATRIX&)const;
bool validCellCheck(int,int)const;
void print()const;
void printColNumbers()const;
void printRow(int, char, char)const;
void printExtraRow(char, char)const;
void printCell(const Position&, char)const;
void blockCells();
void blockCell();
void chooseNumCellsToBlock(unsigned&);
void chooseWhichCellsToBlock(unsigned);
bool validCellsToBlock(unsigned)const;
bool validCoordinates(int, int)const;
bool alreadyBlocked(int, int)const;
bool alreadyOccupied(int, int)const;
bool isPortal(int, int)const;
bool noEscapeCell(int x_coord, int y_coord)const;
};
#endif