Artificial Intelligence lab report 3, Study Guides, Projects, Research of Artificial Intelligence

Artificial Intelligence lab report

Typology: Study Guides, Projects, Research

2022/2023

Uploaded on 10/29/2023

rehan-10
rehan-10 🇵🇰

6 documents

1 / 14

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
COMSATS UNIVERSITY ABBOTABAD DEPARTMENT
OF
ELECTRICAL AND COMPUTER ENGINEERING
Submitted By:
NAME Registration
Ahmed Raheel Jadoon
FA21
-
BCE-015
Muhammad Rehan
FA21
-
BCE-002
Artificial Intelligence
Lab Report #: 3
Date: 10-Oct-2023
Course Instructor: Dr. Imran Shahzad
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe

Partial preview of the text

Download Artificial Intelligence lab report 3 and more Study Guides, Projects, Research Artificial Intelligence in PDF only on Docsity!

COMSATS UNIVERSITY ABBOTABAD DEPARTMENT

OF

ELECTRICAL AND COMPUTER ENGINEERING

Submitted By:

NAME Registration

Ahmed Raheel Jadoon FA21^ -

BCE- 015

Muhammad Rehan FA21^ -

BCE- 002

Artificial Intelligence

Lab Report #: 3

Date: 10-Oct-

Course Instructor: Dr. Imran Shahzad

Task 1:

Implementation of Breadth First Search (BFS).

Flowchart:

Program Output:

Discussion:

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.

Task 2:

Implementation of Depth First Search (DFS).

Flowchart:

Program Ouput:

Discussion:

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.

Task #3:

Implementation of Depth Limited Search(DLS).

Flowchart:

Program Output:

Discussion:

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.

Program Code:

Program Output:

Discussion:

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.