We were given a task, to familiarize ourselves with stacks and queues, to write a program to solve a maze problem. We are given text files with pre-defined values letting us know the size of the maze, the mouse's position, the cheese's position as well as the value each cell carries.
I attached some extra info for a more clear understanding of this assignment.
What am trying to do....where i got some questions is.....ok so the input file is read and each cell contains an interger value that gets translated into its binary notation where starting from the left, each bit represents N E S W (North, east, south and west). How do i have it recognize where there are 1's and 0's ( 1 signifies a pathway within the room, 0...a c omplete wall) within the binary number. She provided us with the below header file....my questions is the "&" symbol does what? doorEncoding(which is the value of the cell) & 0x08...what does that mean? am thinking it compares the number's 1 positions after the symbol to the cell value?
Maze.h
typedef struct
{
unsigned short int doorEncoding; // Range 0..15.
north = doorEncoding & 0x08 // 8 = 1000 ( north position has 1)
east = doorEncoding & 0x04 // 4 = 0100 ( east position has 1)
south = doorEncoding & 0x02
west = doorEncoding & 0x01
bool visited;
int parentRow;
int parentCol;
char direction; // From parent.
} MazeCell;
Maze.cpp
// Read and initialize all the cells.
int x = 0;
while(txtfile >> x)
{
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < cols; j++)
{
maze[i][j].doorEncoding = x;
}
}
}
Thank you, and am srry for the troubles once again.