You are on page 1of 11

Maze solver with Imaging

Samadhan A. Sonavane & Nitin S. Choubey


Department of Computer Engineering, MPSTME, NMIMS, Shirpur Campus, Shirpur samadhan.sonavane@gmail.com, nschoubey@gmail.com

ABSTRACT
A maze is a tour puzzle in the form of a complex branching passage through which the solver must find a route. The paper proposed the method for solving the by by using image processing application. It take the maze as a image and converts it into am graph which can be easily solved by using any graph processing algorithm. The algorithm is implemented and tested for sever different size of mazes.

KEYWORDS
Micromouse Maze, maze solving algorithm, Graph Theory.

1. INTRODUCTION
A maze is a tour puzzle in the form of a complex branching passage through which the solver must find a route. The result is a route to the target destination of the maze. [10]. There are a several automated methods for the solving of mazes. The section 2 of the paper describes few maze solving algorithms such as the random mouse, wall follower, and Trmauxs algorithms. These algorithms are designed to be used inside the maze by a traveler with no prior knowledge of the maze, whereas the other algorithm explained such as dead-end filling, Partitioned base maze solving, shortest path algorithms are designed to be used by a person or computer program that can see the whole maze at once. [7] [9]. Standard/perfect mazes do not contain loops and are equivalent to a tree in graph theory. Thus they can be made closely related to graph theory. Intuitively, if one pulled and stretched out the paths in the maze in the proper way, the result could be made to resemble a tree. The solution given in this paper is based on graph theory.

2. VARIOUS MAZE SOLVING ALGORITHMS


2.1 Random maze solving This is a trivial method that can be implemented by a very unintelligent robot or perhaps a mouse. It is simply to proceed in a straight line until a junction is reached, and then to make a random decision about the next direction to follow. Although theoretically such a method would always eventually find the right solution, it is also possible that it never finds any solution. Because the random mouse might walk any path multiple times it is extremely slow. [1] [10] 2.2 Dead End Filling This is a simple Maze solving algorithm. It focuses on the Maze, is always very fast, and uses no extra memory. Just scan the Maze, and fill in each dead end, filling in the passage backwards from the block until you reach a junction. This includes filling in passages that become parts of dead ends once other dead ends are removed as shown in Figure 1. At the end only the solution will remain, or solutions if there are more than one as shown in Figure 1. This will always find the one unique solution for perfect Mazes, but won't do much in heavily braid Mazes, and in fact won't do anything useful at all for those Mazes without dead ends. [10]

Figure 1: - Finding the Dead Ends

2.3 Wall Follower


LEFT WALL FOLLOWER LOGIC this works on the rule of following the left wall continuously until it leads to the end. The RIGHT WALL FOLOWER is similar; the only difference lies in the wall being followed. The Micro mouse senses the wall on the left, and follows it to wherever it leads until the destination is reached. This simple logic used for solving the maze is demonstrated by the following algorithm. [7]

Figure 2:- LWF: Solvable and Unsolvable maze Step 1: Sense the left wall. Step 2: If left wall present then flagl=1, if not then flagl=0. Step 3: If flagl=1 then step 4 else turn left by 90 degrees. Step 4: Sense the front wall. Step 5: If front wall present then flagf=1, if not then flagf=0. Step 6: If flagf=0, move straight else turn right by 90 degrees.

Step 7: return to step1. Figure 2 shows the output of Left Wall Follower algorithm in which first maze is perfectly finds the solution but second maze dont have proper solution. This is one of the drawbacks of this logic. The algorithm is not efficient enough to solve the mazes of high complexities and the ones which have multiple paths leading to the centre.

2.4 Trmauxs algorithm


This Maze solving method is designed to be able to be used by a human inside of the Maze. It's similar to the recursive backtracker and will find a solution for all Mazes: As you walk down a passage, draw a line behind you to mark your path. When you hit a dead end turn around and go back the way you came. When you encounter a junction you haven't visited before, pick a new passage at random. If you're walking down a new passage and encounter a junction you have visited before, treat it like a dead end and go back the way you came. If walking down a passage you have visited before (i.e. marked once) and you encounter a junction, take any new passage if one is available, and otherwise take an old passage (i.e. one you've marked once).

Figure 3:- Shortest path using Trmauxs All passages will either be empty, meaning you haven't visited it yet, marked once, meaning you've gone down it exactly once, or marked twice, meaning you've gone down it and were forced to backtrack in the opposite direction. When you finally reach the solution, paths marked exactly once will indicate a direct way back to the start as shown in the Figure 3. If the Maze has no solution, you'll find yourself back at the start with all passages marked twice. [10]

2.5 Shortest path algorithm


The input of the algorithm consists of a weighted directed graph G and a source vertex s in G. We will denote V the set of all vertices in the graph G. Each edge of the graph is an ordered pair of vertices (u, v) representing a connection from vertex u to vertex v. The set of all edges is denoted E. Weights of edges are given by a weight function w: E-> [0, ); therefore w (u, v) is the cost of moving directly from vertex u to vertex v. The cost of an edge can be thought of as (a generalization of) the distance between those two vertices. The cost of a path between two vertices is the sum of costs of the edges in that

path. For a given pair of vertices s and t in V, the algorithm finds the path from s to t with lowest cost (i.e. the shortest path).So now this fundamental nature of the algorithm can be used to find the graph. The stepwise functioning of the algorithm has been described as below. [7] STEP 1: Start ready set with start node Set start distance to 0, dist[s] =0; Others to infinite: dist[i] = (for i s); Set Ready = { }. STEP 2: Select node with shortest distance from the starting point that is not in Ready set Ready = Ready + {n}. STEP 3: Compute distances to all of its neighbours For each neighbour node m of n Check if dist[n] +edge (n, m) < dist[m] If yes then dist[m] = dist[n] +edge (n, m); STEP 4: Store path predecessors. pre[m] = n; STEP 5: Add current node to ready set. STEP 6: Check if any node is left, if yes goto step 2 STEP 7: End. Now the problem arises of how to generate the directed graph G of the. So for this problem need to get the Micro-mouse traverse the whole maze and generate the nodes! So the traversal function is defined as follows. [7] Traverse ( ): STEP 1: Move straight STEP 2: Check if any wall is present in front. If yes, then goto step 3 else goto step 1. STEP 3: Check if the current location is present in V, If no then add the location in the set V, calculate the distance between the previous and the present location. Store the value in the set E, else take 180 degree turn and traverse to the Previous entry of V. STEP 4: Check if wall is present on right. If present, take a 90 degree turn left if not then take a 90 degree turn right. STEP 5: Goto step 1 Repeat steps 1 to 5 till the entire maze is traversed. Calculation of distance between two consecutive nodes is done by adding a counter circuit at the base of the chassis near the wheels so as to count the number of cells between the destination and the source location. The solution using this method is as shown in the Figure 4.

2.5.1 Drawbacks of the algorithm There are, however, problems in using this algorithm, the major one being that the whole maze has to be traversed. For identifying the nodes, it is important to travel all the parts of the maze, irrespective of whether that portion of the maze contains the shortest path or not. Now, this is time consuming and also a lot of energy is wasted in the traversal. This solution also requires a lot of time for finding the shortest path as after the generation of the connected graph G, it has to check for all the connections that lead to the destination. This increases the execution time of the algorithm.

Figure 4:- Maze as solved by Djikstras algorithm Even for smaller mazes it will have to travel all the blocks before starting to find the shortest path. This problem would be solved if we can design a way where both the maze interpretation and path finding are done simultaneously. The other problem is that for counting the number of cells to generate the edge set E, an additional hardware is involved which includes a counter circuit that counts the rotation of the wheels and hence the distance between two consecutive locations. This adds to the complexity of the design and increases the probability of error in input data from the external environment. 2.6 Partitioned Based Maze Solving Partition-central Algorithm, which is used to find the shortest path in a Micro-Mouse competition maze. A standard 16*16 units maze is divided into 12 partitions in this algorithm. Depending on the absolute direction of the Micro-Mouse and the locations of each partition, exploring rules alter when the Micro-Mouse walks to optimize the maze exploring process. The maze is divided into 12 partitions besides the 4unit square end point, the 12 partitions division is an optimized scheme after many experiments. Moving direction is totally partition base for every partition different moving algorithm will be used. The available algorithms are Left-hand algorithm, Right-hand algorithm, Central-left algorithm and Central-right algorithm. By setting the Partitioncentral algorithm, one of the four algorithms is chosen for a Micro-Mouse to explore the shortest path. When the Micro-Mouse is located in one of the 4 partitions from partition 1 to partition 4, the algorithm selection rule is similar to the Centre-trend rule. Walking rules of other partitions are shown in Figure 5. Partition-central algorithm is more central-trend than other algorithms. [9] In Figure 5, the arrows points to the possible direction when the Micro-Mouse is in this partition unit. The letter represents the available rule for choosing.

Figure 5: - Maze partition division 2.6.1 Closed Looping Path Avoidance The optimized partition-central algorithm is more flexible than other classic algorithms. However, because of the special characteristic of centraltrend, after the partition division of the maze, if there is a T crossing or a + crossroad just between two or among three different adjacent partitions is encountered, different walk determine rules in different partitions would confuse the Micro-Mouse and then cause a process of exploring the partition border area repeatedly, thus the Micro-Mouse would be led to a searching closed looping path and making it impossible to reach the end point. 2.6.2 T crossing situation

Figure 6: - Closed loop path and T crossing

2.7 Maze solving using Image Analysis It uses a very simple set of mathematical morphology filters to find the solution to simple mazes. [11] Step 1: Reading the image with the maze: Step 2: Next we convert it to a grey-value image and threshold it to obtain a binary image. The maze walls are true and shown in red: Step 3: label the binary image; we can clearly see two discrete, separate walls

Figure 7:- Image Processing Explanation Step 4: It is fairly easy to see the path from start to finish: its the path in between the two colours. To draw this path over the image we can follow this simple sequence of commands, its all mathematical morphology. We ignore everything except the first of the two walls:

Figure 8:- Image Processing Explanation Step 5: Then we dilate the walls by a few pixels, and fill all the holes:

Step 6: Then we erode by the same amount of pixels and take the difference:

Figure 9:- Image processing Explanation Above method is best for solving random maze. This method is image analysis based method where shortest path from starting point to end point is determined, in which maze is considered as one image on which by applying some image processing operation like erosion and dilation we can calculate the shortest path from given random maze. But this method is also having some disadvantages. We can not apply it for the complex maze as shown in Figure 7, 8, and Figure 9. If we use improper size for dilation in that case we may lost the proper shortest path. It can find only one path from given maze.

3. MAZE SOLVING USING IMAGING APPLICATIONS


In maze solving using imaging application we have considered the disadvantages of all algorithms in mind and we have given solution accordingly. The drawbacks of above mentioned algorithm are as follow first is Dead end filling algorithm having disadvantage is it can not be used for complex maze and the maze having no dead ends. Trmauxs algorithm requires more memory and it also takes double time so solve any maze it unnecessary traverse all parts of the maze although the part of maze contain solution or not. Wall follower is not always gives the solution for all mazes this is one of the drawbacks of this logic. The algorithm is also not efficient enough to solve the mazes of high complexities and the ones which have multiple paths leading to the centre. In the method of maze solving using Djikstras shortest path finding algorithm the drawback is that it has to traverse whole maze to convert it in to the graph and then calculate the shortest path amongst available paths and this is very time consuming process. It also requires the complex circuitry for conversion of maze in to the graph. All such drawback of above mentioned algorithm can be overcome by using the image processing applications as follow. In this solution we have consider the maze as an Image. That should be the image of standard maze. Standard mean the maze having no loops and (0, 0) node should be start node and end at (N-1, N-1) node. In this method maze will be scan vertically and horizontally after scanning the maze we will get width of wall and width of path in the maze accordingly nodes will be place in the path. Once we decide the node position we will expand the edges of every node and in this way we will convert the maze into the graph. Figure 10 shows how the given maze is converted into the connected graph.

Figure 10:- Maze in to graph Once we convert the maze in to graph we can apply shortest path finding algorithm as shown in to the Figure 11 and Figure 12 we will get shortest path. By using image processing application we can directly reduce the work of complex circuitry to convert maze into the directed graph

EXPERIMENTAL RESULTS

Figure 11:- Solved Maze of 81 nodes

Figure 12: Solved Maze of 2500 nodes

Table 1: Experimental results Maze Maze 1 Maze 2 Maze 3 Maze 4 Number of Nodes 81 225 900 2500 Time in second 0.61 sec 0.71 sec 7.24 sec 138.5 sec

CONCLUSION
Above mentioned algorithms are used for solving the Micromouse maze. Every algorithm is having different efficiency of finding optimum path as solution to the given Micromouse maze. Above algorithms such as Dead End Filling, Maze solving based on image analysis, shortest path finding algorithm, Trmaux's algorithm and Wall Follower is having some advantages and disadvantages. Some disadvantages of one method can be overcome by method given in this paper. Some of the algorithms are use for maze having single path from start to end. For multi path maze we use shortest path algorithm to find shortest path. But using this algorithm is very complex procedure we have to use extra circuitry. For such multi path maze we can use imaging application to overcome the problem of complex circuitry used for conversion of maze into graph and then apply the shortest path algorithm to find optimum path amongst several paths.

REFERENCES
[1] MicroMouse, California State University at Northridge, hm //homepaw mac com/SBenkovic/MicroMouse/indehxt ml. [2] Babak Hosseini Kazerouni, Mona Behnam Moradi and Pooya Hosseini Kazerouni;Variable Priorities in Maze-Sloving Algorithms for Robots Movement, 2003. [3] Sung-Hee Lee, Junggon Kim, F.C.Park, Munsang Km, and James E.Bobrow;Newton-Type Algorithms for Dynamics- Based Robot Movement Optimization, Digital Object Identifier, 2004. [4] Manoj Sharma, Kaizen Robotics, Algorithms for Micro-mouse, 2009 International Conference on Future Computer and Communication. [5] Zhang xenia, A Micromouse Maze Solving Algorithm. MCU and Embeded System 2007.5: 84-85. [6] University of California, Berkeley, IEEE Student Branch (2006), http://ucsee.eecs.berkeley.edu/ [7] Swati Mishra, Pankaj Bande, Maze Solving Algorithms for Micro Mouse, 2008 IEEE International Conference on Signal Image Technology and Internet Based System [8] David M. Willardson. Analysis of Micromouse Maze Solving Algorithm [R].Learning from Data, spring 2001. [9] Jianping Cai, Xuting Wan, Meimei Huo, Jianzhong Wu.An Algorithm of Micro Mouse Maze solving. 10th IEEE International Conference on Computer and Information Technology (CIT 2010),2010 [10] http://www.micromouseonline.com. [11] file:///H:/Maze%20Solver/277.htm

You might also like