Download as pdf or txt
Download as pdf or txt
You are on page 1of 21

Maze Solver: Navigating Paths with Dijkstra's, A*, and BFS

Algorithms
A PROJECT REPORT

Submitted by
Prabhat Kumar (21BCS8714)

Shreya Kesarwani (22BCS8903)

Ashutosh Jaiswal(22BCS8904)

in partial fulfillment for the award of the degree of

BACHELOR OF ENGINEERING

IN

COMPUTER SCIENCE ENGINEERING

Chandigarh University
MAY 2023

1
BONAFIDE CERTIFICATE

Certified that this project report “Maze Solver: Navigating Paths with Dijkstra's,
A*, and BFS Algorithms” is the bonafide work of “Prabhat Kumar, Shreya
Kesarwani and Ashutosh Jaiswal who carried out the project work under my
supervision.

SIGNATURE SIGNATURE

Dr. Rahul Bhandari


HEAD OF DEPARTMENT SUPERVISOR
Deptt. of Computer Science & Engineering Deptt. of Computer Science & Engineering

Submitted for the project viva-voice examination held on 02/11/2023.

INTERNAL EXAMINER EXTERNAL EXAMINER

2
TABLE OF CONTENTS

Abstract……………………………………………………………………………………….5
CHAPTER 1. INTRODUCTION........................................................................................6-9
1.1 Identification of client………………...……………………………...................................6
1.2 Identification of Problem .................................................................................................6-7
1.3 Identification of Tasks .........................................................................................................7
1.4 Timeline ...............................................................................................................................8
1.5 Organization of the Report ...............................................................................................8-9
CHAPTER 2. DESIGN FLOW.........................................................................................10-14
2.1. Evaluation and selection of specification...........................................................................10
2.2. Design Constraint..........................................................................................................10-11
2.3. Analysis and feature finalisation subject to constraints………………………..................11
2.4. Design Flow………...........................................................................................................12
2.5. Design Selection…............................................................................................................13
2.6. Implementation plan .........................................................................................................14

CHAPTER 3. RESULTS ANALYSIS AND VALIDATION .........................................15-18


3.1. Implementation of solution………………………...........................................................15
3.1.1. Djikstra…….......................................................................................................15
3.1.2. A* Algorithm…………………………………………......................................15
3.1.3. Making the maze................................................................................................15
3.1.4.Developing the code......................................................................................16-18
3.1.5. Result.................................................................................................................18
CHAPTER 4.CONCLUSION AND FUTURE WORK.....................................................19
REFERENCES .................................................................................................................... 20
USER MANUAL .................................................................................................................. 21

3
4
ABSTRACT

Maze solving problem is a very old problem, but still now it is considered as an important
field of robotics. This field is based on decision making algorithms. The main aim of this
project is to make an Arduino based efficient autonomous maze solver robot. Two simple
maze solving algorithms “Wall following algorithm” and “Flood fill algorithm” are used to
make this robot. In this project Hardware development, software development and maze
construction had been done. For performance testing, the robot will implement to solve 4×4
maze. Capability of finding the shortest path is also verified.

5
CHAPTER 1.
INTRODUCTION

1.1. Client Identification/Need Identification/Identification of relevant contemporary issue

Need Identification:
Maze solving is the process of figuring out how to move from one place to another through
a maze. This topic has been a contentious study topic in the disciplines of robotics and
computer science for many years. The objective of solving a maze is to locate the shortest
or most efficient path to the destination while avoiding obstacles and dead ends.

1.2. Identification of Problem

To design software for maze solving, construct software with the combination of wall
following and flood fill algorithms then implement the software in the maze solving.
At last, make a maze 6×6 maze to verify.

6
The problem faced is whether the algorithm will be using wall-following, flood-
filling, A* search algorithm and many more methods possible or whether to combine
two or more algorithms in a robot. There are pros and
cons for every each of the algorithm that may varies the results in different efficiency
and effectiveness in solving the maze. Another consideration is that how much time
will it take to find the destination as the robot itself will take time to process it’s
surrounding depending on the algorithm being used by the robot.

1.3. Identification of Tasks

• Understand and implement the wall follower and Flood fill algorithm.
• Design and build a program to solve a maze.
• Make a small 4×4 maze.
• Selecting suitable programming interface for writing the code properly and
testing it.
• Develop the code: This will be done in alignment to our project objectives.
This includes developing a facial recognition system, which is the basis of our
project.
• Testing and debugging: Testing the code to ensure that the emotion is being
measured and that the output is accurate. Debugging any issues that may arise
during testing.
• Maintenance: Fixing any bugs encountered during the testing phase and
adding improvements if needed.

7
1.4. Timeline

Fig 2: Gantt Chart showing the timeline of the project.

1.5. Organization of the Report

Chapter 1: Introduction

This chapter provides background information on the project, including the technology
that analyses facial expressions from static images to reveal information on one's
emotional state, the scope of the project, and the objectives. In this chapter, we mainly
focus on what our project is about, who will be our main clients, why we need this
project and what makes us to select this project.

Chapter 2: Design Flow/Process

This chapter will involve the steps taken in conducting the research. The design flow
will ensure that the research study will be conducted in a systematic manner to produce
reliable results.

Chapter 3: Results Analysis And Validation

The purpose of this chapter will be to draw meaningful conclusions from the data. In
this chapter, the data will be presented in a clear and concise manner using appropriate
charts, graphs, or tables.

8
Chapter 4: Conclusion And Future Work

The conclusion is an important section that summarizes the key findings,


interpretations, and implications of the study. It will act as an opportunity to summarize
the main findings and significance of the study and to suggest avenues for future
research.

9
CHAPTER 2.
DESIGN FLOW/PROCESS

2.1. Evaluation & Selection of Specifications/Features

1. Functional Specifications:
• Evaluation: Assess the functionality required for effective maze solving,
considering factors like pathfinding algorithms, sensor integration, and decision-
making processes.
• Selection: Choose specifications that align with the project's primary goal of
navigating mazes efficiently.
2. Performance Specifications:
• Evaluation: Define performance metrics such as speed, accuracy, and reliability.
• Selection: Select specifications that optimize performance within the constraints
of the project.
3. Sensory System:
• Evaluation: Examine sensor options for environment perception, such as
cameras, infrared sensors, or lidar.
• Selection: Choose a sensory system that suits the maze-solving requirements,
considering factors like precision and adaptability.
4. Decision-Making Algorithms:
• Evaluation: Explore various algorithms for decision-making in maze navigation.
• Selection: Select algorithms that strike a balance between computational
efficiency and effective decision-making.
5. Power Requirements:
• Evaluation: Analyze power needs based on the selected features and
components.
• Selection: Opt for power-efficient specifications to extend the maze solver's
operational duration.

2.2. Design Constraints

1. Regulations:
• Ensure compliance with any relevant industry standards and
regulations.
• Adhere to safety guidelines and protocols in the design and implementation.

10
2. Economic:
• Stay within budget constraints for materials, components, and overall project
cost.
• Consider the economic feasibility of the project in terms of potential benefits and
returns.
3. Environmental:
• Choose materials and manufacturing processes with minimal environmental
impact.
• Consider energy efficiency and sustainable practices in the design.
4. Health:
• Prioritize user safety in the operation of the maze solver.
• Minimize any potential health risks associated with the project.
5. Manufacturability:
• Design components that are feasible to manufacture using available
technologies.
• Consider ease of assembly and maintenance during the
manufacturing process.

2.3. Analysis and Feature finalization subject to constraints

1. Regulations:
• Analysis: Examine each feature to ensure compliance with industry regulations
and standards.
• Finalization: Select features that align with regulatory requirements, avoiding
any that may lead to non-compliance.
2. Economic:
• Analysis: Evaluate the cost implications of each feature, including development,
manufacturing, and maintenance costs.
• Finalization: Choose features that offer a balance between functionality and cost-
effectiveness, staying within budget constraints.
3. Environmental:
• Analysis: Assess the environmental impact of materials and processes

11
associated with each feature.
• Finalization: Opt for features that minimize the project's ecological footprint and
promote sustainability.
4. Health:
• Analysis: Identify features that may have health implications for users or those
involved in the manufacturing process.
• Finalization: Prioritize features that enhance user safety and well-being,
eliminating any potential health risks.
5. Manufacturability:
• Analysis: Examine the feasibility of manufacturing each feature, considering
available technologies and resources.
• Finalization: Optimize the design for manufacturability, choosing features that
are practical and efficient to produce.

2.4. Design Flow

12
2.5. Design selection

13
2.6. Implementation plan/methodology

Algorithm: The modified wall-follower method

1: let 𝑆𝑅 be the solver


mobile
2: let 𝑆𝑑=0
be the default direction value at the source point
3: let (𝑥𝑖, 𝑦𝑖) be the 2D coordinates for
a point 𝑖
4: let (𝑥𝑓, 𝑦𝑓) be the 2D coordinates for the destination
point 𝑓
5: let 𝑛𝑜𝑑𝑒𝑚 be the
node 𝑚
in the maze area
5: let 𝑙𝑖𝑠𝑡[𝑛𝑜𝑑𝑒𝑠]
be the list of nodes in the maze area
5: let 𝑙𝑖𝑠𝑡[𝑣𝑖𝑠𝑖𝑡𝑒𝑑_𝑛𝑜𝑑𝑒𝑠]
be the list of coordinates that 𝑆𝑅
traveled through
6: let (𝑥𝑆𝑅, 𝑦𝑆𝑅) be the 2D coordinates for the
solver robot 𝑆𝑅
7: while ( (𝑥𝑆𝑅, 𝑦𝑆𝑅)
!=∉
∑𝑛𝑖=0𝑝𝑜𝑠𝑖𝑡𝑖𝑜𝑛
(𝑛𝑜𝑑𝑒𝑖)
8: { 𝑆𝑅
moves in the maze area until it finds an intersection point (𝑥𝑖, 𝑦𝑖)
9: if (𝑥𝑖, 𝑦𝑖)
∈𝑙𝑖𝑠𝑡[𝑥, 𝑦]
then
10: rotate_180(𝑆𝑅
)
11: else add (𝑥𝑖, 𝑦𝑖)
to 𝑙𝑖𝑠𝑡[𝑥, 𝑦] }
12: end

14
CHAPTER 3.
RESULTS ANALYSIS AND VALIDATION

3.1. Implementation of solution

3.1.1 Djikstra Algorithm

Edsger W. Dijkstra, a Dutch computer scientist, created the Djikstra algorithm


in 1956. The shortest path in a weighted graph can be found using Dijkstra's
method, a graph search algorithm. The algorithm keeps track of both a set of
visited and unvisited nodes. Apart for the starting node, which is added to the
visited set, all nodes are initially unvisited. The method then continually chooses
and includes in the visited set the node that is furthest from the starting node in
the unvisited set. Based on the edge weights and the most recent distance to the
visited node, the method modifies the distance to every newly visited node's
neighbors. The new distance is updated if it is less than the previous distance.
When the destination node is added to the visited set or when all nodes have
been visited, the process comes to an end. The path that the algorithm has
constructed is the one that, at the conclusion of the procedure, leads from the
starting node to the destination node in the smallest amount of time.

3.1.2 A* Algorithm

A* (pronounced "A-star") algorithm is a heuristic search algorithm used to


determine the shortest path between any two nodes in a graph. Peter Hart, Nils
Nilsson, and Bertram Raphael created it in 1968. By incorporating an additional
heuristic function that calculates the separation between a node and a
destination, the A* method improves upon Dijkstra's algorithm. The approach is
more effective than Dijkstra's algorithm for big graphs because this heuristic is
utilized to direct the search in the direction of the target node.

3.1.3 Making the maze

To check if the project is successfully working, a maze needs to be designed.


This is done with the help of wooden planks. Designing the correct type of maze
is important for the project to be implemented successfully. The first thing that
needs to be decided is the shape and size of the maze. Maze can be rectangular,
pentagonal, or even a circle. In this case, a rectangular maze was made. The size
of the maze was 6 inches * 6 inches.

15
3.1.4 Developing the code

from PIL import Image, ImageDraw


images = []

a=[
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0 ,0, 0, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0 ,0, 0, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0 ,0, 0, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0 ,0, 0, 0, 1, 0, 1, 1, 1, 1],
[1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0 ,0, 0, 0, 1, 0, 0, 0, 0, 0],
[1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0 ,0, 0, 0, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0 ,0, 0, 0, 0, 0, 0, 0, 0, 1],
[1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0 ,0, 0, 0, 0, 0, 0, 0, 0, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
]
zoom = 20 borders = 6
start = 1,1
end = 5,19

def make_step(k): for i in


range(len(m)): for j in
range(len(m[i])):
if m[i][j] == k: if i>0 and m[i-1][j] == 0 and
a[i-1][j] == 0:
m[i-1][j] = k + 1 if j>0 and m[i][j-1] == 0
and a[i][j-1] == 0:
m[i][j-1] = k + 1 if i<len(m)-1 and m[i+1][j] == 0
and a[i+1][j] == 0:
m[i+1][j] = k + 1 if j<len(m[i])-1 and m[i][j+1] == 0
and a[i][j+1] == 0:
m[i][j+1] = k + 1

def print_m(m):
for i in range(len(m)):
for j in range(len(m[i])):
print( str(m[i][j]).ljust(2),end=' ') print()

def draw_matrix(a,m, the_path = []):

16
im = Image.new('RGB', (zoom * len(a[0]), zoom * len(a)), (255,
255, 255))
draw = ImageDraw.Draw(im) for i in
range(len(a)):
for j in range(len(a[i])): color
= (255, 255, 255)
r=0 if a[i][j]
== 1: color = (0,
0, 0) if i == start[0]
and j == start[1]:
color = (0, 255, 0) r=
borders if i == end[0] and j ==
end[1]:
color = (0, 255, 0)
r = borders
draw.rectangle((j*zoom+r, i*zoom+r, j*zoom+zoom-r-1, i*zoom+zoom-
r-1), fill=color) if m[i][j] > 0: r = borders
draw.ellipse((j * zoom + r, i * zoom + r, j * zoom + zoom - r
- 1, i * zoom + zoom - r - 1),
fill=(255,0,0)) for u
in range(len(the_path)-1):
y = the_path[u][0]*zoom + int(zoom/2) x=
the_path[u][1]*zoom + int(zoom/2) y1 =
the_path[u+1][0]*zoom + int(zoom/2) x1 =
the_path[u+1][1]*zoom + int(zoom/2)
draw.line((x,y,x1,y1), fill=(255, 0,0), width=5)
draw.rectangle((0, 0, zoom * len(a[0]), zoom * len(a)), outline=(0,255,0),
width=2)
images.append(im)

m = [] for i in range(len(a)):
m.append([]) for j in
range(len(a[i])):
m[-1].append(0)
i,j = start
m[i][j] = 1

k = 0 while m[end[0]][end[1]] == 0:
k += 1 make_step(k)
draw_matrix(a, m)

17
i, j = end k = m[i][j] the_path = [(i,j)]
while k > 1: if i > 0 and m[i - 1][j]
== k-1: i, j = i-1, j
the_path.append((i, j))

3.1.5 Result

18
CHAPTER 4.
CONCLUSION AND FUTURE WORK

4.1. Conclusion

In this paper, we designed and implemented a modified wallfollower system (MWFS)


based on the wall-follower algorithm, with tiny changes on the searching priority and with
an offloopback. Three different maze solving systems were experimentally tested, and the
results were compared to the proposed MWFS’ results. The developed MWFS could solve
the loop-back issue that existed in the existing wall-follower systems. In addition, the
proposed maze solving robotic system efficiently navigated the maze area, found out all
the possible paths, and then estimated the shortest path possible. For future research, we
aim to develop various maze-solving algorithms and assess the speed and efficiency for
each one. Finally, we aim to conduct our experiments in large maze areas to verify the
effectiveness of the maze-solving algorithm and conduct some real experiments using
different robot platforms.

4.2. Future work

Robots that can navigate mazes have a huge range of possible uses in a variety of industries.
There are several potential applications for these robots. Maze-solving robots can be
employed in search and rescue operations to find and save individuals in need by
navigating through challenging terrain like buildings or rubble. This can help save a lot of
time and potentially save lives. Robots that can solve mazes can be utilized in
manufacturing and logistics to efficiently transfer products and supplies through factories
or warehouses. We may anticipate seeing more effective and intelligent maze-solving
robots in the future that can carry out more difficult jobs with increased accuracy and
precision thanks to the growing advances in robotics technology. Artificial intelligence and
machine learning can also be used to improve the capabilities of these robots and increase
their adaptability to various settings and tasks. Overall, maze-solving robots have a bright
future, and in the years to come, we may anticipate more fascinating advancements in this
area.

19
REFERENCES
[1] MSP-EXP432P401R: Out of Box MSP-EXP432P401R | Out of Box - MSP-EXP432P401R -
Welcome 1.20.00.45 documentation. (n.d.). Retrieved April 7, 2023, from
https://software-
dl.ti.com/msp430/msp430_public_sw/mcu/msp430/SIMPLELINK_MSP432_S
DK/1.20.00
.45/exports/docs/simplelink_mcu_sdk/project0/project0/docs/MSPEXP432P401R.htm
l

[2] 2.1. System Requirements - Code Composer Studio 12.2.0 Documentation. (n.d.). Retrieved April
7, 2023, from https://software-
dl.ti.com/ccs/esd/documents/users_guide/ccs_overview.html

[3] Wikimedia Foundation. (2023, June 13). Code composer studio. Wikipedia.
https://en.wikipedia.org/wiki/Code_Composer_Studio

[4] Maze Solving Robot with Automated Obstacle Avoidance Redirecting from
https://doi.org/10.1016/j.procs.2017.01.192

[5] Survey on techniques used in Autonomous Maze Solving Robot IEEE Xplore. from
https://ieeexplore.ieee.org/Xplore/guesthome.jsp

[6] Autonomous Maze Solving Robot IEEE Xplore: Advanced Search from
https://ieeexplore.ieee.org/search/advanced

[7] Alamri, S., Alamri, H., Alshehri, W., Alshehri, S., Alaklabi, A., & Alhmiedat, T. (2023,
February 8). An Autonomous Maze-Solving Robotic System Based on an Enhanced
Wall-Follower Approach. Machines; MDPI. https://doi.org/10.3390/machines11020249

[8] An Efficient Algorithm for Robot Maze-Solving. (2010, August 1). IEEE Conference Publication |
IEEE Xplore. https://ieeexplore.ieee.org/document/5591159

[9] ArcBotics - Maze Solving. (n.d.). http://arcbotics.com/lessons/maze-solving-home-lessons/

[10] Learn How Artificial Intelligence (AI) Is Changing Robotics. (n.d.). Intel.
https://www.intel.com/content/www/us/en/robotics/artificial-intelligence-robotics.html

20
USER MANUAL

1. Introduction
• Purpose of the User Manual.
2. Getting Started
• Mapping of maze should be fixed.
• Indexing should be done.

3. Solving
• Find out all the possible path
• Estimated the shortest path.

21

You might also like