Presentation is loading. Please wait.

Presentation is loading. Please wait.

Maze Implementation, Analysis and Design to find Shortest Paths

Similar presentations


Presentation on theme: "Maze Implementation, Analysis and Design to find Shortest Paths"— Presentation transcript:

1 Maze Implementation, Analysis and Design to find Shortest Paths
By: Morgan Messina and Ian Warren

2 Informal Problem Statement
Our project is designed to analyze the difference in time and path taken of three different algorithms Our goal is to determine which algorithm performs in the least amount of time and taking the shortest path (least incorrect nodes visited). To do this we will implement 3 algorithms: A* Star, DFS and BFS Algorithm A perfect maze is a maze without loops

3 What is a Maze? A maze is a path or collection of paths, typically from an entrance to a goal through which the solver must find a route.

4 Solving A Maze Maze solving is the act of finding a route or path through the maze from start to finish. Some maze solving methods are designed to be used inside the maze by a traveler with no prior knowledge of the maze, whereas others are designed to be used by a person or computer program that can see the whole maze at once.

5 Real Life Application Navigation Artificial Intelligence/Robotics,
Computer Games Computer Simulations Virtual Reality Military Mazes are a simplified form of navigation.  Developments used in efficient maze solving have helped other n

6 Maze Representation Our maze was designed as positions on a graph and are identified by (x,y) coordinates. Our maze is a collection of these coordinates or cells in a 2-d array. At any given moment, you can only step in one of 4 directions. Valid moves are: • Go North: (x,y) -> (x,y-1) • Go East: (x,y) -> (x+1,y) • Go South: (x,y) -> (x,y+1) • Go West: (x,y) -> (x-1,y) A node in the graph represents a possible map location. In this discussion, we will imagine a node n as a single point with an (x, y) coordinate.

7 Formal Problem Statement
N = Number of Correct Nodes Visited M = Number of Incorrect Nodes Visited T = Total Nodes Visited k = size of the vertex list Given a set of nodes, G, each representing a state A set of Given coordinates representing a graph maze,, and two vertices s and t, solve for the k shortest paths from s to t in increasing order of length. After each run, two values were noted: the number of total path nodes in the final solution and the total run time. An adjacency list is where vertices are stored as objects and every vertex stores a list of adjacent vertices.

8 Maze Constraint Requirements
The maze is perfect. Which means it has no loops and only one way to reach the exit. The maze has to be able to accept different input parameters, to create mazes of various sizes. The maze doesn't have to be braided. Meaning dead-ends are allowed.

9 A* Star Algorithm The A * algorithm is one of the most commonly used path finding algorithms It is a tree-based search algorithm that calculates the path from one node to some pre-specified goal node Uses heuristic to guide search

10 Heuristics: Manhattan Distance
H(current_node) = abs(currentX-goalX) + abs (currentY-goalY) Heuristic Function calculating cost—> f(n)=g(n)+h(n) g(n) : represents the cost of the path from the starting cell to the current cell. h(n) represents the cost of moving from the current node to the goal node. Manhattan distance from node to goal (ignoring obstacles)

11 A* Star Explained Maintains 2 lists, one open and one closed.
The closed list keeps track of all the visited/considered nodes. The open list keeps track of potential best path nodes that have not been considered. All nodes keep a reference to the parent, meaning that backtracking is also possible. • Sort open on node.f • Removing the first node n from open list (queue) (lowest node.f, closest to goal) • Expand the node by generating its children (usually proximal neighbors in the search graph) • Goal check • Add node to closed • Compute f(n) = g(n) + h(n) for each child node • Add each child to open A* is an informed search algorithm, or a best-first search function is g(n), which is simply the cost of reaching n. The cost is usually an integer value that is simply incremented once for each step taken since departing the start node. It is meant to be a measurement that takes into account the work done by the agent in traversing the solution. Weighted A* is a simple approach to improve performance when optimality is not required, like in most games. It requires you to multiply the value of h(n) by some constant, which you should determine by experimenting. The open list or simply "open", is the list of all available un-expanded nodes. implemented as a priority queue.

12 Depth First Search DFS is an example of a brute-force search algorithm. DFS keeps walking down a path until it is forced to backtrack. It backtracks until it finds a new path to go down. Time Complexity: O(|V|+|E|) Is brute force because all nodes are traversed until the goal node is found. Recursive *last in first out

13 Depth First Search Steps
Visit the start node (or current node) and push onto a stack so we can remember it and then mark it so we won’t visit it again Go to any node adjacent to the current node that has not been visited yet Mark it as visited, and push it onto the stack Continue visiting the next adjacent nodes, until you reach a node that has no other adjacent nodes. Next pop off nodes from the stack until you find a node that has other unvisited nodes adjacent to it that you can evaluate. Repeat steps 2 through 5 until end is reached. 1.

14 Depth First Search Visualization

15 Breadth First Search BFS is also an example of a brute-force search algorithm. BFS, unlike DFS, explores all nodes nearest to root nodes before exploring nodes furthest away Time Complexity: O(|V|+|E|)

16 Breadth First Search Steps
1. Begin at the starting node(current node). 2. Visit all unvisited nodes adjacent to the current node(if there is one) mark them as visited, and insert them into the queue. 3. After visiting all adjacent nodes, remove a node from the queue (if possible) and make it the current node. 4. Continue repeating steps 2 and 3 until goal is reached. Queue: first one in first one out

17 Breadth First Search First, it visits all locations one step away, then it visits all locations that are two steps away, and so on, until an exit is found.

18 Other Works A Comparative Study of A-star Algorithms for Search and rescue in Perfect Maze Analysis of Dijkstra’s and A* Algorithm to Find the Shortest Path Path Finding Solutions For Grid Based Graph 1st: Xiang Liu: Three A-star algorithms are studied in this paper to compare the maze searching capacity and efficiency of their different heuristic functions, and the depth-first search algorithm, which has no heuristic information, is also adopted as a benchmark to judge the usefulness of the 3 heuristic functions of A-star algorithms. Experiments validated the usefulness of heuristic function with the results that the A-star algorithms outperform the depth-first search algorithm in most cases, and the A-star algorithm with the Euclidean distance from the father point of current point to the target point included in the heuristic function shows the best performance. 2: AMANI SALEH ALIJA :This study compares the Dijkstra’s, and A* algorithm to estimate search time and distance of algorithms to find the shortest path. 3. This analysis looks at Astar and BFS to find solutions to a grid based graph Dr. R.Anbuselvi M.Sc., M.Phil. Ph.D Assistant Professor in Computer Science, Bishop Heber College, Trichy-17

19 How We Determined Most Efficient Algorithm
Total Number of Nodes Visited averaged for each m x n maze size: A_STAR_AVG = [ASTAR(1), ASTAR(2), ASTAR(3),..ASTAR(n)] / 5 DFS_AVG = [DFS(1), DFS2), DFS(3), DFS(4), DFS(5)] / 5 BFS_AVG = [BFS(1),BFS(2), BFS(3), BFS(4), BFS(5)] / 5 This same formulation was used to average the runtimes for each maze m x n size: A_STAR_TIME = [ASTAR(1), ASTAR(2), ASTAR(3),..ASTAR(n)] / 5 DFS_TIME = [DFS(1), DFS2), DFS(3), DFS(4), DFS(5)] / 5 BFS_TIME = [BFS(1),BFS(2), BFS(3), BFS(4), BFS(5)] / 5 You can use a hashtable to store the parent of each node, so you can get the path from root to target.

20 Results

21 Results

22 Future Work Assess other search algorithms. Like Dijkstra’s, Pledge Algorithm or Dead-end filling Run algorithms against mazes with multiple solution paths Path Finding Solutions for

23 Questions 1. What is a Heuristic function?
-It gives an estimate of the cost to get from the state in question to the goal state. 2. What is a perfect maze? -A maze without any loops or inaccessible areas. 3. What is the time complexity of the Depth First Search Algorithm? -O(|V|+|E|) big o notation 4. Depth-First Search and Breadth-First Search are examples of ___________ algorithms. -Brute Force / Exhaustive Search 5. Name 3 Real Life applications of pathfinding algorithms. -Navigation, Artificial Intelligence/Robotics, Computer Games, Computer Simulations, Virtual Reality, Military

24 Questions?


Download ppt "Maze Implementation, Analysis and Design to find Shortest Paths"

Similar presentations


Ads by Google