Ai Lab 10
Ai Lab 10
Fig 12.1
Algorithm:
Step-1 Define a grid representing the environment with obstacles. 0 represents a passable cell, and
1 represents an obstacle and define directions (up, down, left, right) for movement.
Step-2 Create two separate queues for the start and end searches, respectively and create two sets
for tracking visited nodes in the start and end searches.
Step-3 Now add the start node to and the end node .While both queue_start and queue_end have
nodes.Pop a node from both queue_start and queue_end If current_start is equal to current_end, or
current_start is in visited_end .
Return True
Step-4 For each direction in directions, check neighboring nodes Ensure the neighboring node is within the
grid boundaries.Ensure the neighboring node is not an obstacle.
Step-5 If conditions are met, add the neighboring node to the appropriate queue .
Step-6 If the loop completes without finding a meeting point, return False.
Code:
Output: