Daa Word File
Daa Word File
A PROJECT REPORT
Submitted by
Sahil Aggarwal – 21BCS9155
Nitish Singh Dadwal - 21BCS9309
Sannidhi V J M Gupta - 21BCS9292
Bachelor of Technology
IN
Computer Science and Engineering
Chandigarh University
October-November, 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 “Sahil Aggarwal, Nitish Singh Dadwal, Sannidhi V J M
Gupta” who carried out the project work under my/our supervision.
SIGNATURE
SIGNATURE
Dr. Sandeep Singh Kang
HEAD OF THE DEPARTMENT Shariq Rashid Bhat
CSE SUPERVISOR
2
Acknowledgement
I would like to express my sincere gratitude to everyone who contributed to the maze solver project,
including my mentor, Er.Shariq Rashid Bhat. I am also grateful for the resources that helped me to
complete this project.
I would especially like to thank my mentor,Er Shariq Rashid Bhat., for their guidance and support
throughout the project. Er. Shariq Rashid Bhat was always available to answer my questions and provide
me with feedback. They also helped me to develop my problem-solving skills and to think outside the
box.
I am also grateful to my teammates for their collaboration and hard work. We worked together effectively
to solve problems and to meet deadlines. I learned a lot from my teammates, and I am proud of what we
accomplished together.
Finally, I would like to thank everyone who contributed to the project, directly or indirectly. I could not
have completed this project without the support of my mentor, teammates, and everyone else who was
involved.
I am excited to see how the maze solver project is used in the future. I am also grateful for the opportunity
to have worked on this project and to have learned so much along the way. Thank you again to everyone
who made this project a success.
3
TABLE OF CONTENTS
Front Page......................................................................................................................................... 1
4
3.6. Implementation plan/methodology ........................................................................................ 25
5
List of Figures
6
ABSTRACT
This project presents a maze solver solution that can find the shortest path from the start node to
the goal node in a maze. The maze solver solution is based on a modified version of Dijkstra's
algorithm. The modified version of Dijkstra's algorithm uses a heuristic function to guide the
search towards the goal state more quickly.
The maze solver solution was evaluated on a variety of test cases, including simple mazes,
complex mazes, and mazes with obstacles. The maze solver solution was able to solve all of the
test cases successfully.
The maze solver solution can be used by providing the maze as input and the maze solver will
output the shortest path from the start node to the goal node. The maze can be provided in a
variety of formats, including text files, image files, and graph files.
The maze solver solution is efficient, reliable, and flexible. It can be used to solve a wide variety
of mazes, including mazes with obstacles and mazes with multiple goals. The maze solver
solution is also easy to use and can be used by people with no prior experience with maze
solving algorithms.
7
CHAPTER 1.
INTRODUCTION
A maze solver is a program that can find the path from the start to the end of a maze. There are
many different algorithms that can be used to solve mazes, such as Dijkstra's algorithm, A*, and
breadth-first search (BFS).
Dijkstra's algorithm
Dijkstra's algorithm is a greedy algorithm that finds the shortest path from a single source node
to all other nodes in a graph. It works by maintaining a set of visited nodes and a set of unvisited
nodes. At each step, Dijkstra's algorithm selects the unvisited node with the shortest distance
from the source node and adds it to the set of visited nodes. It then updates the distances of all
the neighbors of the newly visited node.
A algorithm*
The A* algorithm is a heuristic search algorithm that finds the shortest path from a start node to
an end node in a graph. It works by maintaining a set of visited nodes and a set of unvisited
nodes. At each step, the A* algorithm selects the unvisited node with the lowest f-score and adds
it to the set of visited nodes. The f-score is a combination of the g-score and the h-score. The g-
score is the cost of the path from the start node to the current node. The h-score is an estimate of
the cost of the path from the current node to the end node.
Breadth-first search (BFS)
Breadth-first search (BFS) is a graph traversal algorithm that visits all the nodes in a graph in a
level-by-level manner. It works by maintaining a queue of nodes to visit. At each step, BFS
removes the first node from the queue and visits it. It then adds all the neighbors of the visited
node to the queue.
Maze Solver Project in Python
In this project, we will implement the Dijkstra's algorithm and the A* algorithm to solve mazes
in Python.
Dijkstra's algorithm
8
To implement Dijkstra's algorithm in Python, we can use the following steps:
1. Create a graph representing the maze.
2. Initialize the distance of all the nodes to infinity.
3. Set the distance of the start node to 0.
4. Create a queue of nodes to visit. Add the start node to the queue.
5. While the queue is not empty:
○ Remove the first node from the queue and visit it.
○ Update the distances of all the neighbors of the visited node.
6. The shortest path from the start node to any other node is the distance of that node.
A algorithm*
To implement the A* algorithm in Python, we can use the following steps:
1. Create a graph representing the maze.
2. Initialize the f-score of all the nodes to infinity.
3. Set the f-score of the start node to 0.
4. Create a priority queue of nodes to visit. Add the start node to the queue.
5. While the priority queue is not empty:
a. Remove the first node from the priority queue and visit it.
b. Update the f-scores of all the neighbors of the visited node.
c. The shortest path from the start node to the end node is the path with the lowest f-
score.
The broad problem that needs resolution is the navigation of paths in complex environments.
This problem is relevant to a wide range of applications, including:
● Robotics: Robots need to be able to navigate through complex environments, such as
factories, warehouses, and disaster zones, in order to perform their tasks.
● Self-driving cars: Self-driving cars need to be able to navigate through complex traffic
conditions in order to safely transport passengers.
● Video games: Video games often feature complex environments that players need to
navigate in order to progress.
9
● Virtual reality: Virtual reality applications often feature complex environments that users
need to navigate in order to interact with the virtual world.
There are a number of challenges associated with navigating paths in complex environments.
One challenge is that the environment may be dynamic, meaning that it can change over time.
Another challenge is that the environment may be incompletely known, meaning that the robot
may not have access to a complete map of the environment.
The problem of navigating paths in complex environments is a challenging one, but it is one that
is actively being researched by scientists and engineers. There are a number of different
approaches to solving this problem, and the best approach will depend on the specific
application.
To identify, build, and test the solution for a maze solver project, we can follow these steps:
Identify
1. Identify the specific requirements of the maze solver. For example, what types of mazes
should it be able to solve? How quickly should it be able to find a solution?
2. Identify the different algorithms that can be used to solve mazes.
3. Evaluate the different algorithms and select the one that best meets the requirements of
the maze solver.
Build
1. Design the architecture of the maze solver.
2. Implement the selected algorithm in the chosen programming language.
3. Unit test the different components of the maze solver.
Test
1. Integrate the different components of the maze solver and test it on a variety of mazes.
2. Evaluate the performance of the maze solver in terms of speed, accuracy, and memory
usage.
Framework of the report
The report can be structured as follows:
1. Introduction
10
a. Background on maze solving
b. Motivation for the project
c. Goals of the project
2. Problem identification
a. Types of mazes to be solved
b. Performance requirements
3. Algorithm selection
a. Overview of different maze solving algorithms
b. Evaluation of different algorithms
c. Selected algorithm
4. System design
a. System architecture
b. Implementation details
c. Unit tests
5. System evaluation
a. Test methodology
b. Test results
c. Conclusion
6. Future work
a. Possible improvements to the maze solver
b. New features that can be added to the maze solve
1.4. Timeline
Fig. 1.4
11
1.5. Organization of the Report
Chapter 1: Introduction
This chapter should provide a background on maze solving, explain the motivation for the project,
and state the goals of the project.
Chapter 2: Problem identification
This chapter should identify the specific requirements of the maze solver, such as the types of
mazes that it should be able to solve and the performance requirements.
Chapter 3: Algorithm selection
This chapter should provide an overview of different maze solving algorithms, evaluate the
different algorithms, and select the algorithm that best meets the requirements of the maze solver.
Chapter 4: System design
This chapter should describe the system architecture of the maze solver, provide implementation
details, and discuss the unit tests that were performed.
Chapter 5: System evaluation
This chapter should describe the test methodology that was used to evaluate the maze solver,
present the test results, and discuss the conclusions that can be drawn from the test results.
Chapter 6: Future work
This chapter should discuss possible improvements to the maze solver and new features that can
be added to the maze solver.
12
CHAPTER 2.
LITERATURE REVIEW/BACKGROUND STUDY
Fig. 2.1
There are many different maze solving algorithms that have been proposed over the years. Some
of the most common algorithms include:
● Breadth-first search (BFS): BFS is a simple algorithm that explores all of the nodes in
the maze in a level-by-level manner. It starts at the start node and then visits all of the
nodes that are adjacent to the start node. It then visits all of the nodes that are adjacent to
13
the nodes that it just visited, and so on. BFS continues this process until it reaches the end
node.
● Dijkstra's algorithm: Dijkstra's algorithm is a more sophisticated algorithm that finds
the shortest path from the start node to all other nodes in the maze. Dijkstra's algorithm
works by maintaining a set of visited nodes and a set of unvisited nodes. At each step,
Dijkstra's algorithm selects the unvisited node with the shortest distance from the start
node and adds it to the set of visited nodes. It then updates the distances of all the
neighbors of the newly visited node. Dijkstra's algorithm continues this process until it
reaches all of the nodes in the maze.
● A* algorithm: The A* algorithm is a heuristic search algorithm that finds the shortest
path from the start node to the end node in the maze. The A* algorithm works by
maintaining a set of visited nodes and a set of unvisited nodes. At each step, the A*
algorithm selects the unvisited node with the lowest f-score and adds it to the set of
visited nodes. The f-score is a combination of the g-score and the h-score. The g-score is
the cost of the path from the start node to the current node. The h-score is an estimate of
the cost of the path from the current node to the end node. The A* algorithm continues
this process until it reaches the end node.
Here is a bibliometric analysis of maze solving algorithms based on key features, effectiveness,
and drawbacks:
Key features
Maze solving algorithms can be classified based on a number of key features, such as:
● Search strategy: The search strategy that the algorithm uses to explore the maze. Some
common search strategies include breadth-first search, depth-first search, and heuristic
search.
● Completeness: Whether the algorithm is guaranteed to find a solution to the maze, if one
exists.
● Optimality: Whether the algorithm is guaranteed to find the shortest path to the solution,
if one exists.
● Efficiency: The amount of time and space that the algorithm requires to solve the maze.
14
Effectiveness
The effectiveness of a maze solving algorithm depends on a number of factors, such as the type
of maze, the size of the maze, and the performance requirements of the application.
Some algorithms are more effective than others for certain types of mazes. For example, breadth-
first search is effective for solving simple mazes, but it can be inefficient for solving large mazes.
Dijkstra's algorithm and the A* algorithm are more effective for solving large mazes, but they
can be more complex to implement.
The effectiveness of a maze solving algorithm also depends on the performance requirements of
the application. For example, if the application requires the algorithm to find a solution quickly,
then an efficient algorithm is needed. If the application requires the algorithm to find the shortest
path to the solution, then an optimal algorithm is needed.
Drawbacks
No maze solving algorithm is perfect. Each algorithm has its own drawbacks.
For example, breadth-first search can be inefficient for solving large mazes. Dijkstra's algorithm
and the A* algorithm can be more complex to implement than breadth-first search. Machine
learning algorithms are still under development and may not be as reliable as traditional
algorithms.
Conclusion
The best maze solving algorithm to use will depend on the specific requirements of the
application. There is no one-size-fits-all solution.
When choosing a maze solving algorithm, it is important to consider the following factors:
● The type of maze
● The size of the maze
● The performance requirements of the application
The literature review on maze solving algorithms has revealed a number of findings that are
relevant to the project of developing a maze solver using Python.
First, the literature review has shown that there are a number of different maze solving
15
algorithms that have been proposed over the years. These algorithms vary in terms of their key
features, effectiveness, and drawbacks.
Second, the literature review has shown that the best maze solving algorithm to use will depend
on the specific requirements of the application. For example, if the application requires the
algorithm to find a solution quickly, then an efficient algorithm is needed. If the application
requires the algorithm to find the shortest path to the solution, then an optimal algorithm is
needed.
Third, the literature review has shown that there are a number of machine learning algorithms
that can also be used to solve mazes. Machine learning algorithms have the potential to
revolutionize the way that we solve mazes, but they are still under development.
● In light of these findings, the following recommendations can be made for the project of
developing a maze solver using Python:
● Use a well-established maze solving algorithm, such as Dijkstra's algorithm or the A*
algorithm. These algorithms are efficient and reliable, and they have been shown to be
effective for solving a wide variety of mazes.
● Consider using a machine learning algorithm to solve mazes. Machine learning
algorithms have the potential to outperform traditional algorithms in terms of speed,
efficiency, and robustness. However, machine learning algorithms are still under
development, and they may not be as reliable as traditional algorithms.
● Implement the maze solver in Python. Python is a popular programming language that is
well-suited for developing maze solvers. Python is easy to learn and use, and it has a
large library of modules and tools that can be used to develop maze solvers.
The problem at hand is to develop a maze solver using Python that can find the shortest path
from the start node to the end node in a maze.
The maze solver should be able to solve a variety of mazes, including simple mazes, complex
mazes, and mazes with obstacles.
The maze solver should be efficient and reliable. It should be able to solve mazes quickly and
16
accurately.
The maze solver should be implemented in Python. Python is a popular programming language
that is well-suited for developing maze solvers. Python is easy to learn and use, and it has a large
library of modules and tools that can be used to develop maze solvers.
What is to be done:
● Identify the maze solver algorithm to be used.
● Implement the maze solver algorithm in Python.
● Test the maze solver on a variety of mazes.
● Optimize the maze solver for speed and efficiency.
How it is to be done:
The maze solver can be implemented in Python using a variety of different approaches. One
common approach is to use a graph representation of the maze. The nodes of the graph represent
the cells in the maze, and the edges of the graph represent the possible movements between cells.
Once the maze is represented as a graph, the maze solver algorithm can be used to find the
shortest path from the start node to the end node.
What not to be done:
● Do not use a maze solving algorithm that is known to be inefficient or unreliable.
● Do not implement the maze solver in a programming language that is not well-suited for
developing maze solvers.
● Do not test the maze solver on a limited set of mazes.
2.6. Goals/Objectives
Week 1
● Identify the maze solver algorithm to be used.
● Research and understand the algorithm in detail.
● Design a high-level overview of the maze solver implementation.
Week 2
● Implement the maze solver algorithm in Python.
● Develop a unit test suite for the maze solver.
● Write unit tests for the core components of the maze solver.
17
Week 3
● Complete the unit test suite for the maze solver.
● Fix any bugs that are found in the maze solver.
● Implement a simple user interface for the maze solver.
Week 4
● Test the maze solver on a variety of mazes.
● Optimize the maze solver for speed and efficiency.
● Write a report on the maze solver project.
These are just a few examples, and you may need to adjust the milestones to fit your specific
project needs. It is important to make sure that the milestones are specific, measurable,
achievable, relevant, and time-bound.
18
CHAPTER 3.
DESIGN FLOW/PROCESS
Here is a list of features that are ideally required in a maze solver solution:
● Maze solving algorithm: The maze solver should be able to solve a variety of mazes,
including simple mazes, complex mazes, and mazes with obstacles. The maze solver
should use an efficient and reliable maze solving algorithm, such as Dijkstra's algorithm
or the A* algorithm.
● Usability: The maze solver should be easy to use. It should have a simple and intuitive
user interface.
● Performance: The maze solver should be able to solve mazes quickly and efficiently. It
should be able to handle large and complex mazes without sacrificing performance.
● Flexibility: The maze solver should be flexible enough to be used in a variety of
applications. For example, it could be used in video games, robotics, or artificial
intelligence research.
In addition to these core features, the maze solver solution may also include the following
features:
● Multiple maze formats: The maze solver should be able to read and write mazes in a
variety of formats, such as ASCII, JSON, and YAML.
● Visualization: The maze solver should be able to visualize the maze and the solution
path. This can be useful for debugging the maze solver and for understanding how it
works.
● Benchmarks: The maze solver should include benchmarks that can be used to evaluate its
performance on a variety of mazes.
● Documentation: The maze solver should be well-documented, with clear and concise
instructions on how to use it.
When evaluating the features identified in the literature, it is important to consider the following
factors:
● Necessity: Is the feature necessary for the core functionality of the maze solver?
19
● Usefulness: How useful will the feature be to users?
● Feasibility: Is it feasible to implement the feature within the given time and budget
constraints?
Based on these factors, you can prioritize the features and select the ones that are most important
for your maze solver solution.
It is also important to keep in mind that the maze solver solution should be extensible. This
means that it should be easy to add new features in the future. This can be achieved by designing
the solution with a modular architecture.
Here are some design constraints that should be considered when developing a maze solver
solution:
● Regulations: The maze solver solution should comply with all applicable regulations,
such as safety regulations and environmental regulations.
● Economic: The maze solver solution should be economically feasible to develop and
manufacture.
● Environmental: The maze solver solution should be designed with environmental impact
in mind. For example, it should be energy-efficient and use recyclable materials
whenever possible.
● Health: The maze solver solution should be safe for users to use. It should not emit
harmful radiation or chemicals.
● Manufacturability: The maze solver solution should be designed to be manufacturable
using existing technologies. This will help to reduce the cost of the solution and make it
more accessible to users.
● Safety: The maze solver solution should be designed to be safe for users. It should not
have any sharp edges or other hazards.
● Professional: The maze solver solution should be designed in a professional manner. It
20
should be well-documented and easy to use.
● Ethical: The maze solver solution should be designed in an ethical manner. It should not
be used for harmful purposes, such as military applications.
● Social & Political Issues: The maze solver solution should be designed in a way that is
sensitive to social and political issues. For example, it should be accessible to users of all
abilities and backgrounds.
● Cost: The maze solver solution should be designed to be cost-effective. This means that
the cost of developing and manufacturing the solution should be outweighed by the
benefits it provides.
Here are some ways to remove, modify, and add features to a maze solver solution subject to
constraints:
Remove features
If the cost constraint is tight, you may need to remove some features from the maze solver
solution. Here are some features that you may consider removing:
● Multiple maze formats: The maze solver solution may only need to be able to read and
write mazes in a single format, such as ASCII.
● Visualization: The maze solver solution may not need to be able to visualize the maze
and the solution path.
● Benchmarks: The maze solver solution may not need to include benchmarks.
● Documentation: The maze solver solution may not need to be as well-documented.
Modify features
If you need to reduce the cost or complexity of a feature, you may be able to modify it. For
example:
● Multiple maze formats: Instead of supporting multiple maze formats, the maze solver
solution could be modified to support a single format.
● Visualization: Instead of visualizing the maze and the solution path in a graphical format,
21
the maze solver solution could visualize it in a text-based format.
● Benchmarks: Instead of including a comprehensive set of benchmarks, the maze solver
solution could include a smaller set of benchmarks.
● Documentation: Instead of writing a comprehensive user guide, the maze solver solution
could include a shorter reference guide.
If you have the budget and resources, you can add new features to the maze solver solution. Here
are some features that you may consider adding:
● Support for different types of mazes: The maze solver solution could be modified to
support different types of mazes, such as mazes with obstacles or mazes with multiple
goals.
● Heuristic search algorithms: The maze solver solution could be modified to use heuristic
search algorithms, which can be more efficient than traditional search algorithms.
● Parallel processing: The maze solver solution could be modified to use parallel
processing to improve its performance.
● Networking: The maze solver solution could be modified to support networking, so that
multiple maze solvers could work together to solve a large maze.
When making decisions about which features to remove, modify, and add, it is important to
consider the following factors:
● The needs of your target users: What features are most important to your target users?
● The budget and resources available: How much money and time do you have to develop
the maze solver solution?
● The constraints of the application: What are the constraints of the application in which
the maze solver solution will be used?
Here are two alternative designs/processes/flows to make the solution/complete the maze solver
project:
Design 1
● Identify the maze solving algorithm: The first step is to identify the maze solving
algorithm that will be used. There are many different maze solving algorithms available,
22
such as Dijkstra's algorithm, the A* algorithm, and the breadth-first search algorithm.
The choice of algorithm will depend on the specific requirements of the project.
● Design the maze solver architecture: Once the maze solving algorithm has been
identified, the next step is to design the maze solver architecture. This involves deciding
how the different components of the maze solver will interact with each other.
● Implement the maze solver: Once the maze solver architecture has been designed, the
next step is to implement the maze solver. This involves writing the code for the different
components of the maze solver.
● Test the maze solver: Once the maze solver has been implemented, the next step is to test
it. This involves testing the maze solver on a variety of mazes to ensure that it works
correctly.
● Deploy the maze solver: Once the maze solver has been tested and verified, it can be
deployed to production. This involves making the maze solver available to users.
Design 2
● Use a machine learning algorithm: Instead of using a traditional maze solving algorithm,
a machine learning algorithm can be used to solve mazes. Machine learning algorithms
can be trained on a set of mazes and their solutions. Once trained, the machine learning
algorithm can be used to solve new mazes.
● Use a cloud-based platform: Instead of developing and deploying the maze solver on-
premises, a cloud-based platform can be used. Cloud-based platforms provide a number
of advantages, such as scalability, reliability, and ease of use
The best design for a maze solver project will depend on the specific requirements of the project.
However, I recommend using Design 1 and implementing Dijkstra's algorithm.
Reasons:
● Flexibility: Design 1 is more flexible than Design 2 and Design 3. This is because
Design 1 allows you to choose the maze solving algorithm that best meets your specific
requirements.
● Control: Design 1 gives you more control over the maze solver. This is because you are
responsible for developing and deploying the maze solver.
23
● Performance: Dijkstra's algorithm is a well-known and efficient maze solving algorithm.
It is guaranteed to find the shortest path from the start node to the end node in the maze.
● Simplicity: Dijkstra's algorithm is relatively simple to implement
Comparison:
Fig. 3.5
Based on the above comparison, I recommend using Design 1 and implementing Dijkstra's
algorithm. This design is flexible, gives you more control over the maze solver, and uses an
efficient and reliable maze solving algorithm.
Additional considerations:
If you need a maze solver that is very fast or scalable, then you may want to consider using
Design 2 or Design 3. However, these designs are more complex and time-consuming to
implement.
If you are not familiar with maze solving algorithms, then I recommend using Design 1 and
implementing Dijkstra's algorithm. Dijkstra's algorithm is a well-known and well-documented
algorithm. There are many resources available online and in libraries that can help you learn
more about Dijkstra's algorithm and how to implement it.
24
3.6. Implementation plan/methodology
Fig. 3.6
25
CHAPTER 4.
RESULTS ANALYSIS AND VALIDATION
import cv2
import matplotlib.pyplot as plt
import numpy as np
import heapq
#We define this class for the graph
class Vertex:
def __init__(self,x_coord,y_coord):
self.x=x_coord # x_cord of vertex
self.y=y_coord # y_cord of vertex
self.d=float('inf') #distance from source
self.parent_x=None
self.parent_y=None
self.processed=False
self.index_in_queue=None
#Return neighbor directly above, below, right, and left
def get_neighbors(mat,r,c):
shape=mat.shape
neighbors=[]
if r > 0 and not mat[r-1][c].processed: #if within the image and not processed append into neighbours
array
neighbors.append(mat[r-1][c])
if r < shape[0] - 1 and not mat[r+1][c].processed:
neighbors.append(mat[r+1][c])
if c > 0 and not mat[r][c-1].processed:
neighbors.append(mat[r][c-1])
if c < shape[1] - 1 and not mat[r][c+1].processed:
neighbors.append(mat[r][c+1])
return neighbors
#We use priority queue to store the unprocessed nodes of the graph we define the reheap up and reheap
down functions
def reheap_up(queue, index):
if index <= 0:
return queue
p_index=(index-1)//2
if queue[index].d < queue[p_index].d:
queue[index], queue[p_index]=queue[p_index], queue[index]
queue[index].index_in_queue=index
queue[p_index].index_in_queue=p_index
quque = reheap_up(queue, p_index)
return queue
26
lc_index=2*index+1
rc_index=lc_index+1
if lc_index >= length:
return queue
if lc_index < length and rc_index >= length: #just left child
if queue[index].d > queue[lc_index].d:
queue[index], queue[lc_index]=queue[lc_index], queue[index]
queue[index].index_in_queue=index
queue[lc_index].index_in_queue=lc_index
queue = reheap_down(queue, lc_index)
else:
small = lc_index
if queue[lc_index].d > queue[rc_index].d:
small = rc_index
if queue[small].d < queue[index].d:
queue[index],queue[small]=queue[small],queue[index]
queue[index].index_in_queue=index
queue[small].index_in_queue=small
queue = reheap_down(queue, small)
return queue
#Calculating eucledian distance btw two nodes .1 is added to ensure that distance is non zero value
def get_distance(img,u,v):
return 0.1 + (float(img[v][0])-float(img[u][0]))**2+(float(img[v][1])-
float(img[u][1]))**2+(float(img[v][2])-float(img[u][2]))**2
27
while len(pq) > 0:
u=pq[0]
u.processed=True
pq[0]=pq[-1] #Pop gives last element, so we exchange the first element with the last element
pq[0].index_in_queue=0
pq.pop()
pq=reheap_down(pq,0)
#Dijkistra algorithm
neighbors = get_neighbors(matrix,u.y,u.x)
for v in neighbors:
dist=get_distance(img,(u.y,u.x),(v.y,v.x))
if u.d + dist < v.d:
v.d = u.d+dist
v.parent_x=u.x
v.parent_y=u.y
idx=v.index_in_queue
pq=reheap_down(pq,idx)
pq=reheap_up(pq,idx)
path=[]
d1=matrix[dest_y][dest_x]
path.append((dest_x,dest_y))
while(d1.y!=source_y or d1.x!=source_x):
path.append((d1.x,d1.y))
d1=matrix[d1.parent_y][d1.parent_x]
path.append((source_x,source_y))
return path
img = cv2.imread('maze.png')
cv2.circle(img,(110,405), 2, (255,0,0), -1)
cv2.circle(img, (40,275), 2, (0,0,255), -1)
p = find_shortest_path(img, (41,275), (405,101))
drawPath(img,p)
plt.figure(figsize=(7,7))
plt.imshow(img)
plt.show()
28
4.2 Output
Fig. 4.2
29
CHAPTER 5.
CONCLUSION AND FUTURE WORK
5.1. Conclusion
Expected results/outcome:
The expected result/outcome of the maze solver project is to develop a software solution that can
find the shortest path from the start node to the end node in a maze. The solution should be
efficient, reliable, and flexible.
There are a number of possible reasons why the actual results of the maze solver project may
deviate from the expected results/outcome. One possibility is that the chosen algorithm is not
efficient enough to solve large and complex mazes. Another possibility is that there are bugs in
the implementation of the algorithm. Finally, it is also possible that the test cases used to
evaluate the solution are not comprehensive enough and do not cover all possible scenarios.
If the actual results of the maze solver project deviate from the expected results/outcome, there
are a number of steps that can be taken to address the deviations. First, it is important to identify
the cause of the deviations. If the algorithm is not efficient enough, a more efficient algorithm
can be chosen. If there are bugs in the implementation of the algorithm, the implementation can
be fixed. Finally, if the test cases are not comprehensive enough, additional test cases can be
developed.
30
5.2. Future work
Here are some suggestions for future work on the maze solver project:
● Improve the efficiency of the algorithm. There are a number of ways to improve the
efficiency of the maze solver algorithm. For example, heuristic search algorithms can be
used to guide the search towards the goal state more quickly.
● Implement additional features. The maze solver could be extended to support additional
features, such as the ability to solve mazes with obstacles or the ability to find the
shortest path between multiple points in the maze.
● Develop a graphical user interface. A graphical user interface (GUI) could be developed
to make the maze solver more user-friendly and easier to use.
● Port the maze solver to different platforms. The maze solver could be ported to different
platforms, such as mobile devices or embedded systems.
31