








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Artificial Intelligence lab report
Typology: Study Guides, Projects, Research
1 / 14
This page cannot be seen from the preview
Don't miss anything!









Implementation of Breadth First Search (BFS).
In our lab, we implemented the breadth-first search (BFS) algorithm. Within this lab exercise, we defined a Node class, equipping it with attributes like state, parent, cost, and heuristic, in order to represent nodes within the graph. Additionally, we included essential helper functions for tasks such as verifying goal states and extracting paths. Within the main BFS function, we utilized a queue to systematically explore nodes, commencing from an initial node. The algorithm concludes its search upon reaching the goal state or once all nodes have been examined. This implementation demonstrates the fundamental principles of BFS and its applications in graph theory.
Implementation of Depth First Search (DFS).
This Python code extends the previous BFS algorithm with a depth-first search (DFS) utilizing backtracking and removal. The dfs function explores nodes using a stack, tracking
visited nodes to find a path from the initial state to the goal. It provides an alternative approach to graph traversal compared to BFS. The code showcases its functionality on both simple character-based and real-world city graphs, demonstrating its versatility in solving different types of problems.
Implementation of Depth Limited Search(DLS).
The code defines a Node class and functions for Depth-Limited Search. It operates on a real- life cities graph, finding a path from 'Abbottabad' to 'Peshawer' within a depth limit of 3. The algorithm uses a stack for exploration, tracking node depth to manage the search limit effectively. It backtracks when the depth limit is reached without finding the goal. The provided Depth-Limited Search algorithm efficiently explores nodes within the defined depth limit. It utilizes a stack data structure to manage node exploration, ensuring that the search doesn't exceed the specified depth constraint. By effectively backtracking when necessary, the algorithm can accurately determine whether a path exists within the given depth limit from the initial city 'Abbottabad' to the target city 'Peshawer' in the specified graph of real-life cities.
The provided code exemplifies an Iterative Deepening Depth-First Search (IDDFS) algorithm, employing a stack-based Depth-Limited Search (DLS) approach. By utilizing a custom Node class and essential helper functions, it efficiently explores node successors until the goal state is found. The algorithm ensures depth-limit compliance, gradually increasing the limit for effective pathfinding. This practical illustration utilizes a real-life cities graph, showcasing the algorithm's capability to find a path from 'Abbottabad' to 'Peshawer'. Through the iterative deepening strategy, it systematically searches through the graph, maintaining efficiency by avoiding unnecessary exploration. This implementation reflects a fundamental application of search algorithms, crucial for various problem-solving scenarios in computer science and artificial intelligence.