Presentation is loading. Please wait.

Presentation is loading. Please wait.

TRAVEL MAZE Using A* TECHNIQUE Project Guide: Presented By: Dr. Suchit PurohitPalak Doshi(11007) Suraj Singh(11024) M.Sc.(AI & ML) – I Project – I December.

Similar presentations


Presentation on theme: "TRAVEL MAZE Using A* TECHNIQUE Project Guide: Presented By: Dr. Suchit PurohitPalak Doshi(11007) Suraj Singh(11024) M.Sc.(AI & ML) – I Project – I December."— Presentation transcript:

1 TRAVEL MAZE Using A* TECHNIQUE Project Guide: Presented By: Dr. Suchit PurohitPalak Doshi(11007) Suraj Singh(11024) M.Sc.(AI & ML) – I Project – I December 2019 Department of Computer Science Gujarat University Ahmedabad-380009

2 Maze Problem A maze is a path or collection of paths, typically from an entrance to a goal. OR A network of paths and hedges designed as a puzzle through which one has to find a way.

3 Techniques to solve Maze in AI In Artificial Intelligence there are many techniques to solve Maze problems: BFS(Breath First Search) Algorithm DFS(Depth First Search) Algorithm BFS(Best First Search) Algorithm Djikshtra’s Algorithm A* Algorithm

4 Introduction to Maze  A simple maze consists of a rectangular grid of cells. Elements and their Roles in Pathfinding: 1) Cell: A cell is the basic unit in this game. It defines the minimal space that an element should take. We have two types of cells: free cells and occupied cells. 2) FreeCell: FreeCell is a list of cells where agent has to allowed to move. The agent can start from Initial state and is allowed to travel on the free cells and whose sole purpose in maze is to get to the goal only. 3) Obstacle(Occupied Cells): An obstacle is a cell or a list of cells. It cannot be pass through. It means we cannot move in obstacles. 4) Board: It is implemented using a NumPy and each element in the array is a cell, so it contains 20*20 cells in our Maze. In our model, the agent will be "encouraged" to find the shortest path to the target cell and to do this we used A* Algorithm.

5 A*(“Astar”) A* ("A-star") is a graph traversal and path search algorithm, which is often used in computer science due to its completeness, optimality, and optimal efficiency. A* is probably the most popular path finding algorithm in AI. Completeness: A* is guaranteed to terminate and is complete, it will always find a solution if one exists. A* is guaranteed to terminate only if there exists a solution. Optimality: When a search algorithm has the property of optimality, it means it is guaranteed to find the best possible solution.

6 Finding Path Using A* To find the Path using A* first we have to understand following: Staring node – where to start searching from. Goal node – The target to stop searching. g – g is the cost to reach starting node to current node. h’ – The estimated cost of getting distance from the current state to goal state. F’ – Total cost of node. The A* algorithm Use formula for finding path is F’ = g + h’.

7 Heuristic Function A* algorithm improves the computational efficiency significantly by introducing a heuristic approach. Using a heuristic approach means, rather than an exhaustive expansion, only the states that look like better options are examined. The heuristic function used in A* algorithm is to estimate the cost from any nodes on the graph to the desired destination. Here is two ways to calculate heuristics value. (1) Calculate Exact value (which is time consuming). (2) Approximate value of h’ using some heuristic (less time consuming). So, we are using here Approximate value for calculate heuristic value.

8 Approximation Heuristic Using Distance Formula

9 Approximation Heuristic Using Manhattan Distance It is nothing but the sum of absolute values of differences in the goal’s x and y coordinates and the current cell’s x and y coordinates respectively. This Heuristic is used when we are allowed to move only in four directions only (right, left, top, bottom). d =| − | + | − | d = distance (x1, y1) = coordinates of the first point (x2, y2) = coordinates of the second point

10 Algorithm 1. Add the starting node to the open list. 2. Repeat the following steps: a. Look for the node which has the lowest f on the open list. Refer to this node as the current node. b. Switch it to the closed list. c. For each reachable node from the current node: i. If it is on the closed list, ignore it. ii. If it isn’t on the open list, add it to the open list. Make the current node the parent of this node. Record the f, g, and h value of this node. iii. If it is on the open list already, check to see if this is a better path. If so, change its parent to the current node, and recalculate the f and g value. d. Stop when: i. Add the target node to the closed list. ii. Fail to find the target node, and the open list is empty. 3. Tracing backwards from the target node to the starting node. That is your path.

11 Data Structure Once a node has been initialized from the Node Bank, it needs to be put somewhere for fast retrieval. We used data structure to implement open list and closed list. A priority queue is the best way to maintain an OPEN list. It can be implemented by a binary heap. Open list: Open list contains nodes that have been generated and have had heuristic function applied to them but which have not yet been examined. Close list: Close list contains nodes that have been already examined.

12 How A* Works?

13 In this example of A* S is our Initial State and H is Goal State. 1)OPEN_LIST = [ ] CLOSED_LIST = [ ] 2) Take Starting Node S and put it in a Open List. OPEN_LIST = [S] CLOSED_LIST = [ ] 3)Generate the Successors of the Initial state S and make it parent and put it in a Closed list and its successors put in open list. OPEN_LIST = [A2,B8] CLOSED_LIST = [ S] S S AB

14 4)Now, we apply the Heuristic function to node A and B, and we can see that A has smallest heuristic value 2, so Make A2 to parent and put it in closed list and generate its successors. OPEN_LIST = [B7,D8, C9] CLOSED_LIST = [ S, A2] 5)Here, The smallest heuristic value is 7 of node B so we generate the successors of B node next and put it in a closed list. OPEN_LIST = [D8,C9,E12,F14] CLOSED_LIST = [ S, A2,B7] S AB CD

15 6)Now, The smallest value of heuristic is node D which has no successors so put it in a closed list and then apply evaluation function to another better successor. OPEN_LIST = [C9,E12,F14] CLOSED_LIST = [ S, A2,B7,D8] S AB C DE F

16 7)Now, Smallest Heuristic function of node C is 9 so we choose the next node C9 and generate its Successors. OPEN_LIST = [H5,G6,E12,F14] CLOSED_LIST = [ S, A2,B7,D8,C9] Now, H5 is our Shortest heuristic value and H is our goal state so we don’t find the solution for h’s value. Final Path is = [S, A2,B7,D8,C9,H5] S AB F D H G C E

17 RESULT Result with Iterations: Example: Initial State – (0,3) and Goal State – (6,5) 8 Iterations: [(0, 3), (1, 3), (2, 3), (3, 4), (4, 5), (5, 6), (6, 5)] 1111111111111

18 RESULT COMPARISON OF TWO DIFFERENT HEURISTIC FUNCTION 1. Heuristic For Euclidean distance It is allowed to move in 8 Different Directions. When we enter the Initial Node as (0,5) and Goal Node as (0,18), it produce the Result: Path: [(0, 5), (1, 5), (2, 5), (3, 6), (4, 6), (5, 6), (6, 6), (7, 6), (8, 5), (9, 5), (10, 5), (11, 5), (12, 4), (13, 3), (14, 2), (15, 1), (16, 1), (17, 1), (18, 2), (18, 3), (18, 4), (18, 5), (18, 6), (18, 7), (18, 8), (18, 9), (18, 10), (18, 11), (18, 12), (17, 13), (16, 14), (15, 14), (14, 14), (13, 13), (13, 12), (13, 11), (12, 10), (11, 11), (10, 12), (10, 13), (9, 14), (9, 15), (8, 16), (7, 17), (6, 18), (5, 18), (4, 18), (3, 18), (2, 18), (1, 18), (0, 18)]

19 2) Heuristic For Manhattan distance It is allowed to move only in four Directions: Left, Right, Up and Down. When we enter the Initial Node as (0,5) and Goal Node as (0,18), it produce the Result: Path: [(0, 5), (1, 5), (2, 5), (3, 5), (4, 5), (5, 6), (6, 6), (7, 6), (8, 6), (9, 6), (10, 6), (11, 5), (12, 4), (13, 3), (14, 2), (15, 1), (16, 1), (17, 1), (18, 2), (17, 3), (16, 4), (16, 5), (16, 6), (16, 7), (16, 8), (15, 9), (15, 10), (15, 11), (16, 12), (17, 13), (16, 14), (15, 14), (14, 14), (13, 13), (13, 12), (13, 11), (12, 10), (11, 11), (10, 12), (10, 13), (9, 14), (9, 15), (8, 16), (7, 17), (6, 18), (5, 17), (4, 16), (3, 15), (2, 16), (1, 17), (0, 18)]

20 References https://www.geeksforgeeks.org/a-search-algorithm/ https://brilliant.org/wiki/a-star-search/ https://www.samyzaf.com/ML/rl/qmaze.html

21 THANK YOU


Download ppt "TRAVEL MAZE Using A* TECHNIQUE Project Guide: Presented By: Dr. Suchit PurohitPalak Doshi(11007) Suraj Singh(11024) M.Sc.(AI & ML) – I Project – I December."

Similar presentations


Ads by Google