Lesson Informed Search Algorithms - Artificial Intelligence - ثالث ثانوي

Lesson 4 Informed Search Algorithms

Applications of Search Algorithms

Uninformed Search Algorithms

Lesson 4 Informed Search Algorithms

For instance, DFS begins at the root node

Informed Search Algorithms

Lesson 4 Informed Search Algorithms

In this unit you will see some visual examples

Lesson 4 Informed Search Algorithms

In this numeric representation of a maze,

Lesson 4 Informed Search Algorithms

Given any such maze, the following function can be used to

Lesson 4 Informed Search Algorithms

Using BFS to Solve Maze Puzzles

Lesson 4 Informed Search Algorithms

# the shortest distance from the start cell to itself, zero

Lesson 4 Informed Search Algorithms

The function follows the standard BFS approach of

Lesson 4 Informed Search Algorithms

BFS successfully finds the shortest path after 10 cells visits.

Lesson 4 Informed Search Algorithms

This function allows the user to assign a custom weight

Lesson 4 Informed Search Algorithms

As expected, the BFS solver mistakenly reports the exact same path as before,

Using A* Search to Solve Maze Puzzles

Lesson 4 Informed Search Algorithms

The above implementation utilizes a for loop to

Lesson 4 Informed Search Algorithms

Similar to bfs_maze_solver( ), the above function also uses

Lesson 4 Informed Search Algorithms

The same happens if the neighbor has been visited before,

Lesson 4 Informed Search Algorithms

The results reveal that astar_maze_solver() manages to

Algorithm Comparison

Lesson 4 Informed Search Algorithms

BFS unweighted.

Lesson 4 Informed Search Algorithms

weighted version

Lesson 4 Informed Search Algorithms

The results are consistent with the ones reported for the small maze:

Lesson 4 Informed Search Algorithms

Table 2.6: Comparison of uninformed and informed algorithms

Manhattan Distance

Lesson 4 Informed Search Algorithms

This can be easily implemented as a python function as follows:

Lesson 4 Informed Search Algorithms

The results verify that the Manhattan Distance heuristic can indeed help

Table 2.7: Comparison of algorithms performance

Lesson 4 Informed Search Algorithms

Identify two applications of search algorithms.

Identify a difference between uninformed and informed search algorithms and mention an example of each algorithm.

Lesson 4 Informed Search Algorithms

Explain briefly how the A* algorithm works.

Modify your code by changing the diagonal weight from 3 to 1.5. What do you observe? Does the shortest path change for the cases of BFS and A* Search?

Modify your code by swapping the starting cell with the target cell coordinates. What do you observe? Is the path the same as before for the weighted cases of BFS and A* Search?