
Output − The path to follow by the rat to reach the destination, otherwise false. If x and y are in range and (x,y) place is not blocked, then Output: True if the (x,y) place is valid, otherwise false. From that matrix, we can find the path of the rat to reach the destination point. In this diagram, the top-left circle indicates the starting point and the bottom-right circle indicates the ending point. In the matrix, the value 1 indicates the free space and 0 indicates the wall or blocked area. This algorithm will take the maze as a matrix. NOTE: The rat can only move in two directions, either to the right or to the down. Below is the complete source code for a class that can be used to represent individual cells in a maze application. The maze is given using a binary matrix, where it is marked with 1, it is a valid path, otherwise 0 for a blocked cell.

If one rat starts moving from start vertex to destination vertex, we have to find that is there any way to complete the path, if it is possible then mark the correct path for the rat.

Some cells are valid to move and some cells are blocked.

The source and the destination location is top-left cell and bottom right cell respectively. Here is the code I have so far: import this problem, there is a given maze of size N x N. My code is somewhat of a mess of loops, as our teacher has just gotten to methods, constructors, and creating our own classes. If anyone could shed some light on this, I'd be very grateful. However, I haven't coded the circumstance in which the player actually gets the treasure though, so I'm wondering why my code simply spits out "Congratulations! You've found the treasure!" and nothing else. Once this rings true, it should end the game.

I've set up most of the game to run with a while loop, with the boolean "got treasure" set to false. Right now, I've got most of the code written, it's just a matter of getting it to work properly. The rules are simple: navigate the maze (represented by a 2D array) through user input and avoid the cave-ins (represented by Xs), and get to the 'P' (player) the the spot marked 'T'. The program reads in a text "map" from an input file for the layout of the maze.
