Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

relevant comments and indentations should be included. Q1: (Recursive Maze Trave

ID: 3702461 • Letter: R

Question

relevant comments and indentations should be included.

Q1: (Recursive Maze Traversal) (75 points) 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's a simple algorithm for walking through a maze that guarantees finding the exit (assuming there's an exit). If there's 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 Declare and initialize a 2-D array of characters using the maze given above. Write a recursive function mazeTraverse to walk through the maze. The function should receive as arguments a 15-by-15 character array representing the maze and the starting location of the maze. You may use a 15x16 maze if you want to initialize the 2-D array using strings instead of individual characters. You may pass additional parameters to your recursive function call if needed. As mazeTraverse attempts to locate the exit from the maze, it should place the character. in each square in the path that it steps on to show the progress. The function should display the maze after each move, so the user can watch as the maze is solved

Explanation / Answer

Modified Code:

#include <stdio.h>

#include <stdlib.h>

/ 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] = {

};

printf("The maze ******** ");

printMaze(maze, 12, 12);

/**

** below lines will pause the execution and clear the screen.So it is better to comment it

**/

//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);

    /**

   ** below lines will pause the execution and clear the screen.So it is better to comment it

   **/

    //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;

}

/**

** below lines will clear the screen.So it is better to comment it

**/

//system("cls");

/ seek for next move /

/**

** move function needs four parameters

** that are maze, &currentRow, &currentColumn, &direction

** but before only three parameters are passed. That's why it prints an error

**/

   move(maze, &currentRow, &currentColumn, &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 < 12; mazeRow++) {

    for (mazeColumn = 0; mazeColumn < 12; mazeColumn++) {

      if (mazeRow == currentRow && mazeColumn == currentColumn) {

        maze[mazeRow][mazeColumn] = 'X';

      }

      printf("%2c", maze[mazeRow][mazeColumn]);

    }

    printf(" ");

}

printf(" ");

} / end programme /

Output:

The maze

********

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Player's ready

**************

# # # # # # # # # # # #

# . . . # . . . . . . #

X . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

direction = EAST

# # # # # # # # # # # #

# . . . # . . . . . . #

. X # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

NORTH is possible

direction = NORTH

# # # # # # # # # # # #

# X . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

EAST is possible

direction = EAST

# # # # # # # # # # # #

# . X . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

EAST is possible

direction = EAST

# # # # # # # # # # # #

# . . X # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

SOUTH is possible

direction = SOUTH

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # X # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

SOUTH is possible

direction = SOUTH

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # X # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

SOUTH is possible

direction = SOUTH

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . X . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

EAST is possible

WEST is possible

direction = WEST

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . X . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

WEST is possible

direction = WEST

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# X . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

direction = EAST

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . X . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

EAST is possible

direction = EAST

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . X . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

NORTH is possible

EAST is possible

direction = EAST

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . X # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

SOUTH is possible

direction = SOUTH

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # X # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

SOUTH is possible

direction = SOUTH

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # X # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

SOUTH is possible

direction = SOUTH

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # X # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

SOUTH is possible

direction = SOUTH

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . X . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

EAST is possible

WEST is possible

direction = WEST

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . X . . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

WEST is possible

direction = WEST

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . X . . . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

NORTH is possible

WEST is possible

direction = NORTH

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # X # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

NORTH is possible

direction = NORTH

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . X # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

WEST is possible

direction = WEST

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# X . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

direction = EAST

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . X # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

SOUTH is possible

direction = SOUTH

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # X # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

SOUTH is possible

direction = SOUTH

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . X . . . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

EAST is possible

WEST is possible

direction = WEST

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# X . . . . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

direction = EAST

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . X . . . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

NORTH is possible

EAST is possible

direction = EAST

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . X . . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

EAST is possible

direction = EAST

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . X . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

NORTH is possible

EAST is possible

direction = EAST

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . X . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

EAST is possible

direction = EAST

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . X . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

NORTH is possible

SOUTH is possible

EAST is possible

direction = SOUTH

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # X # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

SOUTH is possible

direction = SOUTH

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . . . . X # . . . #

# # # # # # # # # # # #

Seek next direction...

WEST is possible

direction = WEST

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . . . X . # . . . #

# # # # # # # # # # # #

Seek next direction...

WEST is possible

direction = WEST

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . . X . . # . . . #

# # # # # # # # # # # #

Seek next direction...

WEST is possible

direction = WEST

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . X . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

WEST is possible

direction = WEST

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . X . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

WEST is possible

direction = WEST

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# X . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

direction = EAST

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . X . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

EAST is possible

direction = EAST

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . X . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

EAST is possible

direction = EAST

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . . X . . # . . . #

# # # # # # # # # # # #

Seek next direction...

EAST is possible

direction = EAST

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . . . X . # . . . #

# # # # # # # # # # # #

Seek next direction...

EAST is possible

direction = EAST

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . . . . X # . . . #

# # # # # # # # # # # #

Seek next direction...

NORTH is possible

direction = NORTH

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # X # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

NORTH is possible

direction = NORTH

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . X . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

NORTH is possible

EAST is possible

WEST is possible

direction = EAST

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . X . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

EAST is possible

direction = EAST

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . X # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

NORTH is possible

direction = NORTH

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # X # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

NORTH is possible

direction = NORTH

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # X # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

NORTH is possible

direction = NORTH

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # . # . .

# # # # . # . # X # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

NORTH is possible

direction = NORTH

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . . # . #

# . . . . # # # X # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

NORTH is possible

direction = NORTH

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . . X # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

WEST is possible

direction = WEST

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . . X . # . #

# . . . . # # # . # . .

# # # # . # . # . # . #

# . . # . # . # . # . #

# # . # . # . # . # . #

# . . . . . . . . # . #

# # # # # # . # # # . #

# . . . . . . # . . . #

# # # # # # # # # # # #

Seek next direction...

WEST is possible

direction = WEST

# # # # # # # # # # # #

# . . . # . . . . . . #

. . # . # . # # # # . #

# # # . # . X . . # .