-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaze.h
More file actions
83 lines (56 loc) · 1.54 KB
/
Copy pathmaze.h
File metadata and controls
83 lines (56 loc) · 1.54 KB
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
//
// Created by Yusuf Pisan on 4/18/18.
//
#ifndef ASS3_MAZE_H
#define ASS3_MAZE_H
#include <ostream>
#include <vector>
using namespace std;
enum CELL { CLEAR = ' ', WALL = 'X', PATH = '*', VISITED = '+' };
class Maze {
friend ostream &operator<<(ostream &out, const Maze &maze);
public:
// default constructor
Maze();
// Load maze file from current directory
bool load(const string &fileName);
// true if maze can be solved
bool solve();
// path to exit
string getPath() const;
private:
// path to exit
string path;
// row position (x)
int posRow;
// column position (y)
int posColumn;
// array to hold the maze structure
vector<string> field;
// width and height of maze
int width{0}, height{0};
// location of exit row and column
int exitRow{0}, exitColumn{0};
// location of start row and column
int startRow{0}, startColumn{0};
// true if row, column is inside the maze
bool isInside(int row, int col) const;
// true if row, column is clear to move
bool isClear(int row, int col) const;
// mark location as part of the path to exit
void markAsPath(int row, int col);
// mark location as visited, not part of the path to exit
void markAsVisited(int row, int col);
bool unVisited(int row, int col) const;
// true if row, column is the exit
bool atExit(int row, int column) const;
// true if can go north
bool goNorth();
// true if can go East
bool goEast();
// true if can go West
bool goWest();
// true if can go south
bool goSouth();
};
#endif // ASS3_MAZE_H