Question: I know this question has been asked, but I keep getting an error around line 91 ( /* seek for next move */ move( ¤tRow,

I know this question has been asked, but I keep getting an error around line 91
( /* seek for next move */ move( ¤tRow, ¤tColumn, &direction ); mazeTraverse(maze, currentRow, currentColumn); )
that Im just not sure how to fix. Written in C
#include
/* function main */ int mazeTraverse(char mazePtr[12][12], int currentRow, int currentColumn); void printMaze(char maze[12][12], const int currentRow, const int currentColumn);
int main(void) { int startrow = 2, startcoloumn = 0, state = 0; /* 12 by 12 array */ char maze[12][12] = { { '#', '#', '#', '#', '#', '#', '#', '#', '#','#', '#', '#' }, /* 0 */ { '#', '.', '.', '.', '#', '.', '.', '.', '.', '.', '.', '#'}, /* 1 */ { '.', '.', '#', '.', '#', '.', '#', '#', '#', '#', '.', '#'}, /* 2 */ { '#', '#', '#', '.', '#', '.', '.', '.', '.', '#', '.', '#'}, /* 3 */ { '#', '.', '.', '.', '.', '#', '#', '#', '.', '#', '.', '.'}, /* 4 */ { '#', '#', '#', '#', '.', '#', '.', '#', '.', '#', '.', '#'}, /* 5 */ { '#', '.', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#'}, /* 6 */ { '#', '#', '.', '#', '.', '#', '.', '#', '.', '#', '.', '#'}, /* 7 */ { '#', '.', '.', '.', '.', '.', '.', '.', '.', '#', '.', '#'}, /* 8 */ { '#', '#', '#', '#', '#', '#', '.', '#', '#', '#', '.', '#'}, /* 9 */ { '#', '.', '.', '.', '.', '.', '.', '#', '.', '.', '.', '#'}, /* 10 */ { '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#', '#'} /* 11 */ };
printf("The maze ******** "); printMaze(maze, 12, 12); system("pause"); system("cls"); //printf(" ");
state = mazeTraverse(maze, startrow, startcoloumn);
if (state == 0) { printf(" Player found the exit! "); }
system("pause"); return 0; }
int startingFlag = 1, direction = 0;
enum Stat { OVER, NOT_OVER };
/* function main core */ int mazeTraverse(char maze[12][12], int currentRow, int currentColumn) { int gameOver(const int currentRow, const int currentColumn); int move(char maze[12][12], int * currentRow, int * currentColumn, int * currentDirection);
enum Stat State;
/* check if game is over */ State = gameOver(currentRow, currentColumn);
if (State == OVER && startingFlag == 0) { printMaze(maze, currentRow, currentColumn); return OVER; }
/* indicate player is ready */ if (startingFlag == 1) { /* print initial maze */ printf("Player's ready ************** "); printMaze(maze, currentRow, currentColumn); system("pause"); system("cls"); if (currentRow == 0) { direction = 1; } else if (currentRow == 11) { direction = 0; } else if (currentColumn == 0) { direction = 2; } else if (currentColumn == 11) { direction == 3; } startingFlag = 0; } system("cls");
/* seek for next move */ move( ¤tRow, ¤tColumn, &direction ); mazeTraverse(maze, currentRow, currentColumn);
return OVER; }
/*seek for next move*/ enum Direction { NORTH, SOUTH, EAST, WEST }; int move(char maze[12][12], int * currentRow, int * currentColumn, int * currentDirection) { int posibble[4] = { 0 }; int counter = 0;
enum Direction Seek;
Seek = * currentDirection;
/*move player in respect to current direction*/
maze[ * currentRow][ * currentColumn] = '.';
if (Seek == NORTH) { /* print direction */ printf("direction = NORTH "); /* move north */ * currentRow -= 1; } else if (Seek == SOUTH) { /* print direction */ printf("direction = SOUTH "); /* move south */ * currentRow += 1; } else if (Seek == EAST) { /* print direction */ printf("direction = EAST "); /* move east */ * currentColumn += 1; } else if (Seek == WEST) { /* print direction */ printf("direction = WEST "); /* move west */ * currentColumn -= 1; }
//print each move printMaze(maze, * currentRow, * currentColumn); // print maze with player current position
/*analyse for next direction*/
//seek posibble direction printf("Seek next direction... "); if (maze[ * currentRow - 1][ * currentColumn] == '.' && Seek != SOUTH) { printf("NORTH is possible "); posibble[0] = 1; counter++; } if (maze[ * currentRow + 1][ * currentColumn] == '.' && Seek != NORTH) { printf("SOUTH is possible "); posibble[1] = 1; counter++; } if (maze[ * currentRow][ * currentColumn + 1] == '.' && Seek != WEST) { printf("EAST is possible "); posibble[2] = 1; counter++; } if (maze[ * currentRow][ * currentColumn - 1] == '.' && Seek != EAST) { printf("WEST is possible "); posibble[3] = 1; counter++; } printf(" ");
if (counter == 1) { if (posibble[1] == 1) { /* south */ * currentDirection = 1; } else if (posibble[2] == 1) { /* east */ * currentDirection = 2; } else if (posibble[0] == 1) { /*north */ * currentDirection = 0; } else if (posibble[3] == 1) { /* west */ * currentDirection = 3; } } else if (counter == 2) { if (posibble[2] == 1 && posibble[3] == 1) { if (Seek == SOUTH) { * currentDirection = 3; } else if (Seek == NORTH) { * currentDirection = 2; } } else if (posibble[0] == 1 && posibble[1] == 1) { if (Seek == EAST) { * currentDirection = 1; } else if (Seek == WEST) { * currentDirection = 0; } } else if (posibble[0] == 1 && posibble[3] == 1) { /* NORTHWEST */ * currentDirection = 0; } else if (posibble[0] == 1 && posibble[2] == 1) { /* NORTHEAST */ * currentDirection = 2; } else if (posibble[1] == 1 && posibble[2] == 1) { /* SOUTHEAST */ * currentDirection = 1; } else if (posibble[1] == 1 && posibble[3] == 1) { /* SOUTHWEST */ * currentDirection = 3; } } else if (counter == 3) { if (Seek == NORTH) { * currentDirection = 2; } else if (Seek == SOUTH) { * currentDirection = 3; } else if (Seek == EAST) { * currentDirection = 1; } else if (Seek == WEST) { * currentDirection = 0; } } else if (counter == 0) { //dead end if (Seek == NORTH) { * currentDirection = 1; } else if (Seek == SOUTH) { * currentDirection = 0; } else if (Seek == EAST) { * currentDirection = 3; } else if (Seek == WEST) { * currentDirection = 2; } }
}
/*check if game is over*/ int gameOver(const int currentRow, const int currentColumn) { if (currentRow == 0 || currentRow == 11 || currentColumn == 0 || currentColumn == 11) { return OVER; } else { return NOT_OVER; } }
/*print current maze*/ void printMaze(char maze[12][12], const int currentRow, const int currentColumn) { int mazeRow, mazeColumn;
printf(" "); for (mazeRow = 0; mazeRow
} printf(" "); } printf(" "); } /* end programme */
Q5. (30 points) (Maze Traversal) The following grid is a double-subscripted array representation of a maze The # symbols represent the walls of the maze, and the periods (.) represent squares in the possible paths through the maze. There is a simple algorithm for walking through a maze that guarantees finding the exit (assuming there is an exit). If there is not an exit, you'll arrive at the starting location again. Place your right hand on the wall to your right and begin walking forward. Never remove your hand from the wall. If the maze turns to the right, you follow the wall to the right. As long as you do not remove your hand from the wall, eventually you'll arrive at the exit of the maze. There may be a shorter path than the one you have taken, but you're guaranteed to get out of the maze Write recursive function mazeTraverse to walk through the maze. The function should receive as arguments a 12-by-12 character array representing the maze and the starting location of the maze. As mazeTraverse attempts to locate the exit from the maze, it should place the character X in each square in the path. The function should display the maze after each move so the user can watch as the maze is solved
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
