Optimization of Flood Fill Algorithm Using
Optimization of Flood Fill Algorithm Using
Abstract— In this paper further optimization of Flood fill (shortest) path which will allow the mouse to run in the shortest
algorithm is proposed. Our aim is to reach the center of the possible time. [7]
maze with shortest distance and in fastest time possible. With MicroMouse applies the knowledge from different fields, such as
the present work, a Micromouse traverses a maze of unknown computer science, computer engineering, electrical engineering,
dimensions by travelling the shortest path, irrespective of and mechanical engineering. It is a great opportunity to utilize
looking the path that exists beyond it, thereby increasing time interdisciplinary theoretical fundamentals to create a physical
complexity. Combining Flood Fill algorithm with Look Ahead project. [7] The contributions to this paper are thus twofold.
technique, time optimization is achieved by not allowing the Firstly, to design and develop the optimizing techniques (time and
Micromouse to travel those paths beyond which no further distance) for Flood fill algorithm and secondly to integrate Look
route(s) exist. A performance comparison has been done with Ahead technique with flood-fill algorithm as it will help in
normal flood fill execution, line follower algorithm, and look optimization of distance traveled and time taken. This paper spans
ahead alone. The results show that it can significantly span across two major searching techniques, i.e. Look-Ahead
improve the performance which in turn will help in technique and Flood-Fill algorithm. The concept has been coined
improving the performance of flood fill algorithm. as Flood-Ahead Algorithm.
This paper is organized as follows. In the first section, brief
introduction about the motivations for the research and
Keywords- flood-fill algorithm; flood-ahead algorithm, IR
development of MicroMouse optimization is presented. In the
sensors.
second section literature review of earlier proposed techniques are
shown. The third section comprises of the framework that we
have proposed for our entire Micromouse system to optimize the
I. INTRODUCTION time complexity. In section four, details about the dataset used i.e.
------ is explained. In section five and six the experiments
The micromouse is a miniature robot designed to race inside a conducted and subsequent performance evaluation are shown.
maze from a starting point to the destination. A maze is a tour Finally, at the end of this paper we conclude and give suggestions
puzzle in the form of a complex branching passage through which for future work in this field.
the solver must find a route. Along the way, there are walls and
rooms with hedges that micromouse has to go through and decide
the shortest and fastest way the reach the destination. The II. RELATED WORK
destination is at the centre of the maze. [7]
In order to make the micromouse navigate properly to reach the Many researchers have contributed in the field of Artificial
destination inside the maze, it must be equipped with at least Intelligence optimizing the flood fill algorithm. The core
sensors, microcontrollers and motors. The most important algorithm was given by Lee [1]. After analyzing it, we saw that it
equipment inside the micromouse is controller that must be was a Breadth First Search (BFS) algorithm; an application to
programmed with software to ensure micromouse making wise Dijkstra’s algorithm. But its drawback was that it suffered from
decision and navigating smoothly. What determines micromouse huge memory requirements and slow performance. Many other
is making wise decision using software algorithm inside the authors have contributed in this area. In [2], the authors tried to
microcontroller. Developing algorithm for the micromouse improvise the Ackers [3] algorithm in which a two bit encoding
ultimately controls the autonomy positioning of the robot. [8] To technique was used per cell instead of saving the real distance.
accomplish this task, the micromouse needs to map the maze The authors proceeded in two phases: The filling phase: here they
through intelligent exploration, and then track the optimal filled the neighboring cells to the starting point (S) with a one; the
next cells were marked with two (these values are the distance of
each cell from the source). They repeated this till they reached the
670
IRACST – Engineering Science and Technology: An International Journal (ESTIJ), ISSN: 2250-3498,
Vol.3, No.4, August 2013
target point (T). Retrace phase: If the target was reached in step I, It is divided into two phases:
they traced their way back by going to the cell with value I-1. A. Initial Framework
They repeated this till they reached the starting point S. But this B. Proposed Framework
algorithm did not provide viable results for every maze. Hence,
lead to its drawback. Consequently, an update procedure is used A. INITIAL FRAMEWORK
to modify the last search without re-starting. This technique is
known as the Modified Flood Fill algorithm [4], which again is Here we throw light on the existing techniques and algorithms
widely used by micromouse contesters. In [5], the authors used being used contemporarily, i.e. Flood Fill algorithm and Look
three approaches primarily. The wall follower logic: This worked Ahead algorithm.
on the rule of following either left wall or right wall continuously
until it lead to the center. The micro mouse sensed the wall on the 1.) FLOOD FILL ALGORITHM
left or right, and followed it to wherever it lead until the center
was reached. This simple logic used for solving the maze. Flood fill, also called seed fill, is an algorithm
Mathematical approach: Here, they had an array of 16 rows and that determines the area connected to a given node in a multi-
16 columns. If the array was denoted by M, then each cell was dimensional array. It is based on Bellmen- Ford algorithm. The
represented by M[R][C]. They assumed the present position of flood fill algorithm is one of the most popular algorithms used for
array as M2 [R2] [C2], the previous position as M1 [R1] [C1], maze solving. It combines both solution speed and easy handling
and the next position as M3 [R3][C3]. Now they proceeded as of locations to give a quick solution to the maze concerned. The
follows: basic idea behind the algorithm is to imagine one pouring water
down the destination cell and to follow the path of flow of the
If R2-R1>0, then it is currently moving straight, upwards through stream. The water will flow and cover all cells one by one until it
the maze array. reaches the destination cell. The solution is the path of water from
If R2-R1<0, then it is currently moving straight, downwards the source to the destination. The algorithm works as follows:
through the maze array.
If C2-C1>0, then it is currently moving rightwards, through the 1.1 Each cell is assigned a value which indicates its distance
maze array. from the destination cell. Thus the destination cell is assigned a
If C2-C1<0, then it is currently moving leftwards, through the value 0.
maze array. 1.2 Any open neighbor to the destination cell is assigned a
value 1. Similarly, all the open neighbors to the current set of
Depth-First algorithm: Depth- First search was an intuitive open neighbors are assigned a value 2 and so on.
algorithm for searching a maze in which the mouse first started 1.3 The value of the cell therefore is an indication of how far we
moving forward and randomly chose a path when it came to an are from the destination. Any cell will have at least one adjacent
intersection. If that path leads to a dead end, the mouse returned cell holding a value one less than the current value.
to the intersection and chose another path. This algorithm forced 1.4 To find the solution one has to simply follow the path
the mouse to explore each possible path within the maze, and by of decreasing values from their current position, it is assured
exploring every cell, the mouse eventually found the center. It that they will reach the destination. This has been taken from
was called “depth first” [6] because if the maze was considered a [2].
spanning tree, the full depth of one branch was searched before
moving onto the next branch. The relative advantage of this Dynamic flood fill algorithm: It is the basic method to flood fills a
method was that the micromouse always found the route. maze. If we have all the wall information, then all we need to do
Unfortunately the major drawback was that the mouse did not is follow the numbers from the current value till machine reaches
necessarily find the shortest or quickest route and it wasted too zero. Let’s say we start from 10, then jump to the neighboring cell
much time exploring the entire maze. that has value 9, and then to 8 and so on. But when we start our
Different researchers have tried in the area of optimization of machine for the first time it has no information of walls and its
various algorithms of micromouse. But if their technique were memory is completely clean. Assume there are no walls. Now
simple, the time complexity of the algorithm was too large and if flood fills the maze. Jump to the neighboring cell with one value
the time complexity was minimal, then the technique used was less than the current cell. Use sensors to read the walls and update
not practically possible. Till date the best algorithm to execute the the maze. Again flood fill and jump to the neighboring cell with
program of micromouse has been the flood fill algorithm. In our one value less than the current cell. Go on doing this till we reach
paper we have tried to further optimize the flood fill algorithm to the destination. By this method we need not follow the shortest
provide better results. We have proposed a framework in which a path when we run the machine for the first time. Repeat the steps
cell looks ahead (for the cells with and without walls) every time and come back to start position. Again follow these steps. But this
it follows the flood-fill path. It helps the MicroMouse o eliminate time we have more wall information and so we will go by a
those nodes where dead end exists and thereby optimizing the different path (this too may not be the shortest). Eventually may
distance travelled and the time taken. be in 3rd - 4th run) we will have enough wall information (need
not have all wall information) and we will follow shortest path.
671
IRACST – Engineering Science and Technology: An International Journal (ESTIJ), ISSN: 2250-3498,
Vol.3, No.4, August 2013
In backtracking algorithms, look ahead is the generic term for 14. Compare the values in the unblocked neighboring cells of
a sub-procedure that attempts to foresee the effects of choosing (X, Y).
a branching variable to evaluate or one of its values. The two 15. Move micromouse to the cell which has the minimum value
main aims of look-ahead are to choose a variable to evaluate next and is closest to the centre i.e. (0, 0).
and the order of values to assign to it. Look Ahead algorithm 16. Repeat these steps until micromouse reaches at the centre
incurs extra cost for assigning values as it needs to propagate of the maze.
constraints. Look ahead algorithm; helps to restrict the search
space significantly as it remove values from future domains
which does not suit the context. Look Ahead algorithm has no
change on worst case performance but it can significantly reduce
the amount of path traversed by the MicroMouse in best case.
B. PROPOSED FRAMEWORK
ALGORITHM OF FLOOD-AHEAD
672
IRACST – Engineering Science and Technology: An International Journal (ESTIJ), ISSN: 2250-3498,
Vol.3, No.4, August 2013
B. STEPPER MOTOR
A defining characteristic of a stepper motor is that, under normal
circumstances, it is made to take up and hold one of a number of
fixed positions. Movement from one of these positions to another
is only by stepping it through a series of intermediate positions. A
typical stepper motor might have 200 such positions in a single,
complete rotation of the drive shaft. With little effort, this can be
increased, on the same motor, to 400 steps. [8]
C. IR SENSORS
A defining characteristic of a stepper motor is that, under normal
circumstances, it is made to take up and hold one of a number of
fixed positions. Movement from one of these positions to another
is only by stepping it through a series of intermediate positions. A
typical stepper motor might have 200 such positions in a single,
complete rotation of the drive shaft. With little effort, this can be
increased, on the same motor, to 400 steps. [8]
V. PERFORMANCE EVALUATION
IV. DATASET
A. MICROPROCESSOR
673
IRACST – Engineering Science and Technology: An International Journal (ESTIJ), ISSN: 2250-3498,
Vol.3, No.4, August 2013
Figure 2(a): Execution of flood fill Figure 3(a): Execution of flood ahead
674
IRACST – Engineering Science and Technology: An International Journal (ESTIJ), ISSN: 2250-3498,
Vol.3, No.4, August 2013
Flood-ahead is an algorithm whereas, look ahead is a [3] Akers, S.B., "A Modification of Lee's Path Connection
Algorithm", IEEE Transactions of Electronics Computers,
condition. According to the look-ahead condition, whenever a
February 1967.
675
IRACST – Engineering Science and Technology: An International Journal (ESTIJ), ISSN: 2250-3498,
Vol.3, No.4, August 2013
[4]http://www.micromouseinfo.com/introduction/mfloodfill.html[
accessed on July 2013]
[8]http://www.google.com/url?q=http%3A%2F%2Fmadan.wordp
ress.com%2F2006%2F07%2F24%2Fmicromouse-maze-solving-
algorithm%2F&sa=D&sntz=1&usg=AFQjCNF0x7vp7y7STl2vZ-
PVHlyu4f6fcQ
AUTHORS PROFILE
676