Symphony 1.0
Loading...
Searching...
No Matches
MazeState Class Reference

#include <simple_maze.h>

Inheritance diagram for MazeState:
Collaboration diagram for MazeState:

Public Member Functions

 MazeState ()
 
 MazeState (std::vector< std::vector< int > > maze, int x, int y)
 
void print () override
 Prints the state details.
 
- Public Member Functions inherited from State
 State ()
 Constructor for the State class.
 
virtual ~State ()
 Virtual destructor for the State class.
 

Public Attributes

std::vector< std::vector< int > > maze
 
int x
 
int y
 

Detailed Description

Definition at line 13 of file simple_maze.h.

Constructor & Destructor Documentation

◆ MazeState() [1/2]

MazeState::MazeState ( )
inline

Definition at line 16 of file simple_maze.h.

16 {
17 maze = {
18 {0, 0, 0, 0, 0},
19 {0, 1, 1, 1, 0},
20 {0, 1, -1, 0, 0},
21 {0, 1, 1, 1, 0},
22 {0, 0, 0, 0, 0}
23 };
24 x = 1;
25 y = 1;
26 }
std::vector< std::vector< int > > maze
Definition simple_maze.h:28

References maze, x, and y.

◆ MazeState() [2/2]

MazeState::MazeState ( std::vector< std::vector< int > >  maze,
int  x,
int  y 
)
inline

Definition at line 27 of file simple_maze.h.

27: maze(maze), x(x), y(y) {}

Member Function Documentation

◆ print()

void MazeState::print ( )
inlineoverridevirtual

Prints the state details.

This method should be overridden by the user to display meaningful information about the state.

Reimplemented from State.

Definition at line 31 of file simple_maze.h.

31 {
32 int row_index = 0;
33 for (auto &row : maze) {
34 int col_index = 0;
35 for (auto &cell : row) {
36 if (x == row_index && y == col_index) {
37 std::cout << "V";
38 col_index++;
39 continue;
40 }
41 if (cell == 0) {
42 std::cout << " ";
43 } else if (cell == 1) {
44 std::cout << "#";
45 } else if (cell == -1) {
46 std::cout << "X";
47 }
48 col_index++;
49 }
50 row_index++;
51 std::cout << std::endl;
52 }
53 }

References maze, x, and y.

Member Data Documentation

◆ maze

std::vector<std::vector<int> > MazeState::maze

Definition at line 28 of file simple_maze.h.

Referenced by MazeProblem::goal_test(), MazeState(), and print().

◆ x

int MazeState::x

Definition at line 29 of file simple_maze.h.

Referenced by MazeState(), and print().

◆ y

int MazeState::y

Definition at line 30 of file simple_maze.h.

Referenced by MazeState(), and print().


The documentation for this class was generated from the following file: