SlideShare a Scribd company logo
1 of 66
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
Vision and mission of the department
Vision of the Department
To groom students into competent engineers and entrepreneurs, by inculcating technical
education, ethical and moral values through measurable and continuous improvement methods.
Mission of the Department
1. To model students ready for industry by grooming their employability skills using academia
and corporate collaboration.
2. To blend theoretical knowledge and practical applications with the aid of trainings, peer
learning and sound academic practices.
3. Cultivate leadership skills, social awareness and responsibility among the students through
various co-curriculum and extra curriculum activities.
4. To encourage the involvement of faculty in pursuing their own academic excellence through
the aid of faculty development programmes, short term training programmes, seminars,
workshops etc.
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
Program Educational Objectives (PEOs)
Three PEO’s have been defined as
PEO1: To provide the basic knowledge of engineering concepts and fundamentals to
computer graduates by logical and practical approach for problem solving and function
effectively as a skilled computer engineer and pursue their higher education or emerge as an
entrepreneur.
PEO2: To inculcate creative abilities by imparting knowledge and skills for analyze, design, test
and implement various software applications.
PEO3: To instill leadership capabilities, social-economic sense, commitment, ethics and
community services for the protection of environment.
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
Program Outcome (POs)
PO1: Engineering knowledge: Apply the knowledge of mathematics, science,
engineering fundamentals, and an engineering specialization to the solution of complex
engineering problems.
PO2: Problem analysis: Identify, formulate, review research literature, and analyze
complex engineering problems reaching substantiated conclusions using first principles of
mathematics, natural sciences, and engineering sciences.
PO3: Design/development of solutions: Design solutions for complex engineering
problems and design system components or processes that meet the specified needs with
appropriate consideration for the public health and safety, and the cultural, societal, and
environmental considerations.
PO4: Conduct investigations of complex problems: Use research-based knowledge and
research methods including design of experiments, analysis and interpretation of data, and
synthesis of the information to provide valid conclusions.
PO5: Modern tool usage: Create, select, and apply appropriate techniques, resources,
and modern engineering and IT tools including prediction and modeling to complex
engineering activities with an understanding of the limitations.
PO6: The engineer and society: Apply reasoning informed by the contextual knowledge
to assess societal, health, safety, legal and cultural issues and the consequent
responsibilities relevant to the professional engineering practice.
PO7: Environment and sustainability: Understand the impact of the professional
engineering solutions in societal and environmental contexts, and demonstrate the
knowledge of, and need for sustainable development.
PO8: Ethics: Apply ethical principles and commit to professional ethics and
responsibilities and norms of the engineering practice.
PO9: Individual and teamwork: Function effectively as an individual, and as a member
or leader in diverse teams, and in multidisciplinary settings.
PO10: Communication: Communicate effectively on complex engineering activities with
the engineering community and with society at large, such as, being able to comprehend
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
and write effective reports and design documentation, make effective presentations, and
give and receive clear instructions.
PO11: Project management and finance: Demonstrate knowledge and understanding of
the engineering and management principles and apply these to one’s own work, as a member
and leader in a team, to manage projects and in multidisciplinary environments.
PO12: Life-long learning: Recognize the need for, and have the preparation and ability
to engage in independent and life-long learning in the broadest context of technological
change.
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
Program Specific Outcome
PSO 1: Problem Solving Ability: Ability to analyze, formulate and develop computer programs
and computer-based software’s for real time environment related to database, networking,
web development and AI.
PSO 2: Software Development: Ability to apply their practical knowledge in software project
management and development using suitable programming environments to deliver quality
product for the industry and society.
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
Mapping of Co’s with Pos
Course Name: Artificial Intelligence (BTAIML 502-20) (B.Tech DS-5th)
Year of study 2023-2024
Course Outcomes
After the course completion, students will be able to:
BTAIML
502-20.1
Understand different types of AI agents.
BTAIML
502-20.2
Develop different types of various AI search algorithms.
BTAIML
502-20.3
Construct simple knowledge-based systems and to apply knowledge
representation.
BTAIML
502-20.4
Convert intermediate representation in contest to understand learning.
BTAIML
502-20.5
Apply for various techniques for Expert Systems.
Course Name: Artificial Intelligence (BTAIML 502-20) (B.Tech DS-5th)
Year of Study 2023-2024
CO PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12
BTAIML
502-20.1
3 3 3 3 2 - - - - - - 2
BTAIML
502-20.1
3 3 3 3 3 - - - - - - 2
BTAIML
502-20.1
3 3 3 3 3 - - - - - - 2
BTAIML
502-20.1
3 3 3 3 3 - - - - - - 2
BTAIML
502-20.1
3 3 3 3 3 - - - - - - 2
Average 3 3 3 3 2.8 0 0 0 0 0 0 2
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
Course Name: Artificial Intelligence (BTAIML 502-20) (B.Tech DS-5th)
Year of Study 2023-2024
CO PSO1 PSO2
BTAIML 502-20.1 3 3
BTAIML 502-20.1 3 3
BTAIML 502-20.1 3 3
BTAIML 502-20.1 3 3
BTAIML 502-20.1 3 3
Average 3 3
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
Name of the program and semester: B.Tech, CSE DS 5th
Sem
Course Code: BTAIML 502-20
Course Incharge Name: Dr. Sucharu Mahajan
Course Name: Artificial Intelligence
Course Outcomes (Cos)
Course Outcomes
After the course completion, students will be able to:
C502-20.1 Understand different types of AI agents.
C502-20.2 Develop different types of various AI search algorithms
C502-20.3 Construct simple knowledge-based systems and to apply knowledge
representation.
C502-20.4 Convert intermediate representation in contest to understand learning.
C502-20.5 Apply for various techniques for Expert Systems.
Program Specific Outcome
PSO 1:Problem Solving Ability: Ability to analyze, formulate and develop computer programs
and computer-based softwares for real time environment related to database, networking, web
development and AI.
PSO 2:Software Development: Ability to apply their practical knowledge in software project
management and development using suitable programming environments to deliver quality product
for the industry and society.
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CO-PSO Mapping:
CO PSO1 PSO2
C502-20.1 3 3
C502-20.2 3 3
C502-20.3 3 3
C502-20.4 3 3
C502-20.5 3 3
Average 3 3
Note:
1. Enter correlations levels 1, 2 or 3 as defined below:
1. Slight (Low)
2. Moderate (Medium)
3. Substantial (High)
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
General Guidelines and Rules for Faculty
Guidelines:
1. Lab evaluation should be done by the course Instructor during the scheduled lectures on
the basis of the file record, Viva-voce and practical task executed in the computer lab.
2. There should be at least 4 lab evaluations in a semester for a particular course. The
schedule of Lab Evaluations i.e. topic and date should be intimated to the students well in
advance and preferably it should be done in the consecutive lab sessions.
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
General Instructions for students
DOs and Don’ts in Laboratory:
1. Make entry in the Log Book as soon as you enter the Laboratory.
2. All the students should sit according to their roll numbers starting from their left to right.
3. All the students are supposed to enter the terminal number in the log book.
4. Do not change the terminal on which you are working.
5. All the students are expected to get at least the algorithm of the program/concept to be
implemented.
6. Strictly observe the instructions given by the teacher/Lab Instructor.
7. Do not drink or eat in the Lab
8. Don’t use cell phones or any other mobile device unless instructed by the teacher/Instructor
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
IKGPTU Syllabus Scheme:
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
Syllabus as per IKGPTU:
Course Code:
BTAIML504-20
Course Title Artificial Intelligence Lab L:0;T:0;P:2 1 Credits
Detailed List of Tasks:
1.Write a programme to conduct uninformed and informed search.
2. Write a programme to conduct game search.
3. Write a programme to construct a Bayesian network from given data.
4. Write a programme to infer from the Bayesian network.
5. Write a programme to run value and policy iteration in a grid world.
6. Write a programme to do reinforcement learning in a grid world
Lab Outcomes: At the end of the course, the students are able to:
1. Explain artificial intelligence, its characteristics and its application areas.
2. Formulate real-world problems as state space problems, optimization
problems or constraint satisfaction problems.
3. Select and apply appropriate algorithms and AI techniques to solve complex problems.
4. Design and develop an expert system by using appropriate tools and techniques.
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
Lab Manual
PROGRAMME: B.Tech (CSE)DS
COURSE: Artificial Intelligence Lab SEMESTER: 5th
COURSE CODE: BTAIML504-20 CREDITS: 1
COURSE AREA/ DOMAIN: Programming COURSE TYPE: Compulsory
Faculty Incharge: Dr. Sucharu Mahajan CONTACT HOURS: 44hrs
Course Description:
Artificial intelligence (AI) is wide-ranging branch of computer science concerned with building
smart machines capable of performing tasks that typically require human intelligence. AI is an
interdisciplinary science with multiple approaches, but advancements in machine learning and
deep learning are creating a paradigm shift in virtually every sector of the tech industry.
Course Objective:
Humanity is at an impasse now. Governments and politicians are struggling to remain on top of a
constantly growing set of threat vectors, mountains of data, and fundamental economic and
governance issues. Moving well beyond nature’s evolution roadmap, we have created incredible
powers of information acquisition, we live longer lives, and we have greater capabilities than our
forefathers would have ever believed possible. Additional convergences of biological and digital
systems will take us to even higher levels of capabilities, but also increase complexities in
society and create even more need for analysis capabilities.
AI can assist us here. A vast and growing sector, AI – especially with deep learning - has the
ability to process massive amounts of data, whether it is images, text, voice, numbers, etc.
Numerous technology websites report on AI developments; for example, TechCrunch, CNET,
Futurism, etc.
There are daily reports of major advances by AI that go beyond what a human can accomplish.
Art forgeries are detected with 99% accuracy from a single brush stroke. Lip reading is done by
an AI with greater accuracy than the best humans. Skin cancer is detected by a deep learning
trained AI algorithm with greater fidelity than dermatologists. While still considered Narrow AI,
potential exists to expand these accomplishments into greater capabilities and thus to handle
more complex problem sets. Although progress to mimic a human in General AI is slow
presently, some researchers believe we have only begun to tap the full power of AI.
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
The challenge before us is to develop AI quickly as our society increases in its economic,
political, military and psychological challenges. We have a great future ahead of us, but only if
we get help in unraveling the complexities of our modern world.
Course Outcomes
Student will able to:
BTAIML504-
20.1
Apply various uninformed and informed AI search algorithms.
BTAIML504-
20.2
Apply AI search algorithms using Heuristic function and select amongst
different search or game-based techniques to solve them.
BTAIML504-
20.3
Apply knowledge representation and machine learning techniques to
real-world problems (production system, search problems of 3 x 3
puzzle)
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
Artificial Intelligence Lab P a g e | 10 BTCS605-18
HISTORY OF AI
Intelligent robots and artificial beings first appeared in the ancient Greek myths of Antiquity.
Aristotle's development of the syllogism and it’s use of deductive reasoning was a key moment
in mankind's quest to understand its own intelligence. While the roots are long and deep, the
history of artificial intelligence as we think of it today spans less than a century. The following is
a quick look at some of the most important events in AI.
1943
1949
1950
1956
1958
1963
1966
1969
1972
1973
● Warren McCullough and Walter Pitts publish "A Logical Calculus of Ideas
Immanent in Nervous Activity." The paper proposed the first mathematic model for
building a neural network.
● In his book The Organization of Behavior: A Neuropsychological Theory, Donald
Hebb proposes the theory that neural pathways are created from experiences and that
connections between neurons become stronger the more frequently they're used.
Hebbian learning continues to be an important model in AI.
● Alan Turing publishes "Computing Machinery and Intelligence, proposing what is
now known as the Turing Test, a method for determining if a machine is intelligent.
● Harvard undergraduates Marvin Minsky and Dean Edmonds build SNARC, the first
neural network computer.
● Claude Shannon publishes the paper "Programming a Computer for Playing Chess."
● Isaac Asimov publishes the "Three Laws of Robotics."
● The phrase artificial intelligence is coined at the "Dartmouth Summer Research
● Allen Newell and Herbert Simon demonstrate Logic Theorist (LT), the first
reasoning program.
● John McCarthy develops the AI programming language Lisp and publishes the
paper "Programs with Common Sense."
● John McCarthy starts the AI Lab at Stanford.
● The ALPAC report leads to the cancellation of all government-funded MT projects.
● The first successful expert systems are developed in DENDRAL, a XX program,
and MYCIN, designed to diagnose blood infections, are created at Stanford.
● The logic programming language PROLOG is created.
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
Artificial Intelligence Lab P a g e | 11 BTCS605-18
● The "Lighthill Report," detailing the disappointments in AI research, is released by
the British government and leads to severe cuts in funding for artificial intelligence
projects.
1980
1982
● Digital Equipment Corporation develops R1 (also known as XCON), the first
successful commercial expert system. Designed to configure orders for new
computer systems, R1 kicks off an investment boom in expert systems that will last
for much of the decade, effectively ending the first "AI Winter."
● Japan's Ministry of International Trade and Industry launches the ambitious Fifth
Generation Computer Systems project.
1983
● In response to Japan's FGCS, the U.S. government launches the Strategic
Computing Initiative to provide DARPA funded research in advanced computing
and artificial intelligence.
1987-1993
● As computing technology improved, cheaper alternatives emerged and the Lisp
machine market collapsed in 1987, ushering in the "Second AI Winter."
● Japan terminates the FGCS project in 1992, citing failure in meeting the ambitious
goals outlined a decade earlier.
● DARPA ends the Strategic Computing Initiative in 1993 after spending nearly $1
billion and falling far short of expectations.
1991
2005
2008
2014
2016
● U.S. forces deploy DART, an automated logistics planning and scheduling tool,
during the Gulf War.
● STANLEY, a self-driving car, wins the DARPA Grand Challenge.
● The U.S. military begins investing in autonomous robots like Boston Dynamic's
"Big Dog" and iRobot's "PackBot."
● Google makes breakthroughs in speech recognition and introduces the feature in its
iPhone app.
● Google makes first self-driving car to pass a state driving test.
● Google DeepMind's AlphaGo defeats world champion Go player Lee Sedol. The
complexity of the ancient Chinese game was seen as a major hurdle to clear in AI.
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
Artificial Intelligence Lab P a g e | 12 BTCS605-18
Course Name: Artificial Intelligence Lab (BTAIML504-20) (B. Tech CSE-DS 5th)
Year of study: 2023-2024
Course Outcomes
After the course completion, students will be able to:
BTCS605-
18.1
Apply various uninformed and informed AI search algorithms.
BTCS605-
18.2
Apply AI search algorithms using Heuristic function and select amongst
different search or game based techniques to solve them.
BTCS605-
18.3
Apply knowledge representation and machine learning techniques to real-
world problems (production system, search problems of 3 x 3 puzzle)
CO-PO Mapping:
CO PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12
BTCS605-
18.1
3 3 3 1 3 1 - - - - - 1
BTCS605-
18.2
3 3 3 1 3 1 - - - - - 1
BTCS605-
18.3
3 3 3 1 3 1 - - - - - 1
Average 3 3 3 1 3 1 - - - - - 1
CO-PSO Mapping:
CO PSO1 PSO2
BTCS605-18.1 3 2
BTCS605-18.2 3 3
BTCS605-18.3 3 3
Average 3 2.6
Note:
1. Enter correlations levels 1, 2 or 3 as defined below:
1. Slight (Low)
2. Moderate (Medium)
3. Substantial (High)
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
Artificial Intelligence Lab P a g e | 13 BTCS605-18
List of Practical:
Task 1. Write a Program for Depth First Search.
Task 2. Write a Program for Best First Search.
Task 3. Write a Program to Generate the output for A* Algorithm.
Task 4. Write a Lisp Program to solve Water Jug Problem Using Heuristic
Function.
Task 5. Write a Program to Show the Tic Tac Toe Game for 0 and X.
Task 6. Write A Program for Expert System by Using Forward Chaining.
Task 7. Write a program to implement tower of Hanoi.
Task 8. Write a program to implement a heuristic search procedure.
Task 9. Write a program to implement a production system.
Task 10. Write a program to implement search problems of 3 x 3 puzzle.
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
Artificial Intelligence Lab P a g e | 14 BTCS605-18
CO Mapping:
Task 1. Write a Program for Depth First Search. - (CO1)
Task 2. Write a Program for Best First Search. - (CO1)
Task 3. Write a Program to Generate the output for A* Algorithm. - (CO1)
Task 4. Write a Lisp Program to solve Water Jug Problem Using Heuristic
Function. - (CO2)
Task 5. Write a Program to Show the Tic Tac Toe Game for 0 and X. - (CO2)
Task 6. Write A Program for Expert System by Using Forward Chaining. - (CO2)
Task 7. Write a program to implement tower of Hanoi. - (CO3)
Task 8. Write a program to implement a heuristic search procedure. - (CO3)
Task 9. Write a program to implement a production system. - (CO3)
Task 10. Write a program to implement search problems of 3 x 3 puzzle. - (CO3)
Artificial Intelligence Lab P a g e | 15 BTCS605-18
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
Table of Content:
SNo. Name of the Practical Page No.
1 Write A Program for Depth First Search 16
2 Write A Program for Best First Search 22
3 Write A Program to Generate the output for A* Algorithm 28
4 Write a Lisp Program to solve Water Jug Problem Using Heuristic
Function
32
5 Write a Program to Show the Tic Tac Toe Game for 0 and X 36
6 Write A Program for Expert System by Using Forward Chaining 43
7 Write a program to implement tower of Hanoi 46
8 Write a program to implement a heuristic search procedure 48
9 Write a program to implement a production system 50
10 Write a program to implement search problems of 3 x 3 puzzle 52
Artificial Intelligence Lab P a g e | 16 BTCS605-18
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
PRACTICAL – 1
WRITE A PROGRAM TO IMPLEMENT DEPTH FIRST
SEARCH (DFS)
#include<iostream>
#define MAX 10
using namespace std;
struct stack
{
int top;
int elements[MAX];
}s;
void initialise()
{
s.top=-1;
}
int IsFull()
{
if(s.top>=(MAX-1))
{
return 1;
}
Artificial Intelligence Lab P a g e | 17 BTCS605-18
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
else
{ return 0;
}
}
int IsEmpty()
{
if(s.top==-1)
{
return 1;
}
else
{ return 0;
}
}
void Push(int item)
{
IsFull();
s.top=s.top+1;
s.elements[s.top]=item;
}
int Pop()
Artificial Intelligence Lab P a g e | 18 BTCS605-18
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
{
IsEmpty();
int item;
item=s.elements[s.top];
s.top=s.top-1;
return item;
}
void DFS(int n,int v,int cost[50][50])
{
initialise();
int u,i,visited[50];
int k=1;
for(i=1;i<=n;i++)
{
visited[i]=0;
}
u=v;
visited[v]=1;
while(k<n)
{
for(i=1;i<=n;i++)
{
if(cost[u][i]==1 && visited[i]==0)
Artificial Intelligence Lab P a g e | 19 BTCS605-18
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
{
Push(i);
visited[i]=1;
}
}
if(IsEmpty())
{
return;
}
u=Pop();
cout<<u<<"t";
k++;
}
}
int main()
{
int e,n,cost[50][50],i,j,v;
cout<<"Enter the number of vertices=";
cin>>n;
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
cost[i][j]=0;
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
Artificial Intelligence Lab P a g e | 20 BTCS605-18
}
}
cout<<"Enter the number of edges=";
cin>>e;
for(int k=1;k<=e;k++)
{
cout<<"nInitial vertex for edge "<<k<<" is = ";
cin>>i;
cout<<"Final vertex for edge "<<k<<" is = ";
cin>>j;
cost[i][j]=cost[j][i]=1;
}
cout<<"nEnter the source node = ";
cin>>v;
cout<<"Result of DFS is - "<<endl;
cout<<v<<"t";
DFS(n,v,cost);
}
OUTPUT:
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
Artificial Intelligence Lab P a g e | 21 BTCS605-18
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
Artificial Intelligence Lab P a g e | 22 BTCS605-18
PRACTICAL -2
WRITE A PROGRAM TO IMPLEMENT BEST FIRST
SEARCH(BFS)
#include<iostream.h>
#include<conio.h>
#define MAX 10
struct queue
{
int front, rear, item;
int elements[MAX];
}s;
void initialise()
{
s.front=-1;
s.rear=-1;
}
int IsFull()
{
if(s.front==0 || s.rear>=(MAX-1))
{
return 1;
}
else
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
Artificial Intelligence Lab P a g e | 23 BTCS605-18
{ return 0;
}
}
int IsEmpty()
{
if(s.front==-1 && s.rear==-1)
{
return 1;
}
else
{ return 0;
}
}
void Enqueue(int item)
{
IsFull();
if(s.front==-1)
{
s.front=s.front+1;
}
s.rear=s.rear+1;
s.elements[s.rear]=item;
}
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
Artificial Intelligence Lab P a g e | 24 BTCS605-18
int Dequeue()
{
IsEmpty();
s.item=s.elements[s.front];
s.front=s.front+1;
return s.item;
}
void BFS(int n,int v,int cost[50][50])
{
initialise();
int u,i,visited[50];
int k=1;
for(i#include<iostream.h>
#include<conio.h>
#define MAX 10
=1;i<=n;i++)
{
visited[i]=0;
}
u=v;
visited[v]=1;
while(k<n)
{
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
Artificial Intelligence Lab P a g e | 25 BTCS605-18
for(i=1;i<=n;i++)
{
if(cost[u][i]==1 && visited[i]==0)
{
Enqueue(i);
visited[i]=1;
}
}
if(IsEmpty())
{
return;
}
u=Dequeue();
cout<<u<<”t”;
k++;
}
}
void main()
{
clrscr();
int e,n,cost[50][50],i,j,v;
cout<<"Enter the number of vertices=";
cin>>n;
for(i=1;i<=n;i++)
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
Artificial Intelligence Lab P a g e | 26 BTCS605-18
{
for(j=1;j<=n;j++)
{
cost[i][j]=0;
}
}
cout<<"Enter the number of edges=";
cin>>e;
for(int k=1;k<=e;k++)
{
cout<<"nInitial vertex for edge "<<k<<" is = ";
cin>>i;
cout<<"Final vertex for edge "<<k<<" is = ";
cin>>j;
cost[i][j]=cost[j][i]=1;
}
cout<<"nEnter the source node = ";
cin>>v;
cout<<"Result of BFS is- "<<endl;
cout<<v<<”t”;
BFS(n,v,cost);
getch();
}
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
Artificial Intelligence Lab P a g e | 27 BTCS605-18
OUTPUT:
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
Artificial Intelligence Lab P a g e | 28 BTCS605-18
PRACTICAL-3
WRITE A PROGRAM TO IMPLEMENT A* SEARCH
#include<iostream>
using namespace std;
int main()
{
int i,j,m,cost[50][50],n,c,v,dist[20],s[20],path[20],p,min,minnode;
cout<<"Enter the number of vertices**";
cin>>n;
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
cost[i][j]=100;
}
}
cout<<"Enter the number of edges**";
cin>>m;
for(int k=1;k<=m;k++)
{
cout<<"Enter Edges and Cost**";
cin>>i>>j>>c;
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
Artificial Intelligence Lab P a g e | 29 BTCS605-18
cost[i][j]=c;
cost[j][i]=c;
}
cout<<"Adjency matrix for graph is **"<<endl;
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
cout<<cost[i][j]<<"t";
}
cout<<endl;
}
cout<<"Enter the initial vertex**=";
cin>>v;
for(i=1;i<=n;i++)
{
s[i]=0;
dist[i]=cost[v][i];
}
s[v]=1; dist[v]=0;
for(i=2;i<=n-1;i++)
{
min=100;
for(j=2;j<=n;j++)
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
Artificial Intelligence Lab P a g e | 30 BTCS605-18
{
if(dist[j]<min && s[j]!=1)
{
min=dist[j];
minnode=j;
}
}
cout<<"min="<<minnode<<"t";
s[minnode]=1;
for(int w=2;w<=n;w++)
{
if(cost[minnode][w]!=100 && s[w]==0)
{
if(dist[w]>=dist[minnode]+cost[minnode][w])
dist[w]=dist[minnode]+cost[minnode][w];
}
}}
for(i=1;i<=n;i++)
{ cout<<dist[i]<<"n";
}
}
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
Artificial Intelligence Lab P a g e | 31 BTCS605-18
OUTPUT:
Artificial Intelligence Lab P a g e | 32 BTCS605-18
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
PRACTICAL – 4
WRITE A LISP PROGRAM TO SOLVE WATER JUG
PROBLEM USING HEURISTIC FUNCTION.
#include<iostream>
using namespace std;
class Jug{
int capacity;
int value;
public:
Jug(int n)
{
capacity = n;
value = 0;
}
void Fill()
{
value = capacity;
}
void Empty()
{
value = 0;
}
bool isFull()
{
return value >= capacity;
}
bool isEmpty()
{
return value == 0;
}
//A[B] -> Transfer contents of B to A until A is full
void operator[](Jug &B)
{
int old_value = value;
value = value + B.value;
value = value > capacity?capacity:value;
Artificial Intelligence Lab P a g e | 33 BTCS605-18
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
B.value = B.value - (value - old_value);
}
int getValue()
{
return value;
}
};
int gcd(int n,int m)
{
if(m<=n && n%m == 0)
return m;
if(n < m)
return gcd(m,n);
else
}
return gcd(m,n%m);
bool check(int a,int b,int c){
//boundary cases
if(c>a){
cout<<"A can't hold more water than it's capacity!n";
return false;
}
//if c is multiple of HCF of a and b, then possible
if(c % gcd(a,b) == 0){
return true;
}
//if c is not multiple of HCF of a and b, then not possible
cout<<"Can't reach this state with the given jugsn";
return false;
}
void solve(Jug A, Jug B, int result)
{
while(A.getValue() != result)
{
if(!A.isFull() && B.isEmpty()){
cout<<"Fill Bn";
B.Fill();
cout << "(A, B) = (" << A.getValue() << ", " <<
B.getValue() << ")n";
}
Artificial Intelligence Lab P a g e | 34 BTCS605-18
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
if(A.isFull()){
cout<<"Empty An";
A.Empty();
cout << "(A, B) = (" << A.getValue() << ", " <<
B.getValue() << ")n";
}
cout<<"Pour from B into An";
A[B];
cout << "(A, B) = (" << A.getValue() << ", " <<
B.getValue() << ")n";
}
}
int main()
{
int a, b, result;
cout<<"Enter capacity of An";
cin >> a;
cout<<"Enter capacity of Bn";
cin >> b;
do{
cout<<"Enter required water in A:n";
cin >> result;
}
while(!check(a,b,result));
Jug A(a), B(b);
cout << "n(A, B) = (" << A.getValue() << ", " << B.getValue()
<< ")n";
solve(A, B, result);
cout<<"Done!"<<endl;
#ifdef _WIN32
system("pause");
#endif
return 0;
}
Artificial Intelligence Lab P a g e | 35 BTCS605-18
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
OUTPUT
Artificial Intelligence Lab P a g e | 36 BTCS605-18
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
PRACTICAL – 5
WRITE A PROGRAM TO IMPLEMENT TIC TAC TOE GAME
FOR 0 AND X.
#include <iostream>
using namespace std;
char square[9] = {'0','1','2','3','4','5','6','7','8'};
int checkwin()
{
if (square[0] == square [1] && square[1] == square[2] )
{ if ( square [0] == 'X' )
return 1;
else
return 2;
}
else
if (square[3] == square [4] && square[4] == square[5] )
{ if ( square [3] == 'X' )
return 1;
else
return 2;
}
else
Artificial Intelligence Lab P a g e | 37 BTCS605-18
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
if (square[6] == square [7] && square[7] == square[8] )
{ if ( square [6] == 'X' )
return 1;
else
return 2;
}
else
if (square[0] == square [3] && square[3] == square[6] )
{ if ( square [0] == 'X' )
return 1;
else
return 2;
}
else
if (square[1] == square [4] && square[4] == square[7] )
{ if ( square [1] == 'X' )
return 1;
else
return 2;
}
else
if (square[2] == square [5] && square[5] == square[8] )
{ if ( square [2] == 'X' )
return 1;
Artificial Intelligence Lab P a g e | 38 BTCS605-18
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
else
return 2;
}
else
if (square[0] == square [4] && square[4] == square[8] )
{ if ( square [0] == 'X' )
return 1;
else
return 2;
}
else
if (square[2] == square [4] && square[4] == square[6] )
{ if ( square [2] == 'X' )
return 1;
else
return 2;
}
else
if (square[0] == square [3] && square[3] == square[6] )
{ if ( square [0] == 'X' )
return 1;
else
return 2;
}
Artificial Intelligence Lab P a g e | 39 BTCS605-18
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
else
return 0;
}
void mark(int player, int box)
{
if (player == 1 )
{
square[box] = 'X';
}
else
square[box] = 'Y';
}
void display()
{
for(int i=0;i<9;i++)
{
cout<< square[i] << "t" ;
if (i == 2 || i== 5 || i==8)
cout<<"n";
}
}
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
Artificial Intelligence Lab P a g e | 40 BTCS605-18
int main()
{
int player1 = 1, player2 =2 ;
int box, result = 0, flag = 0;
for(int i=1;i<5;i++)
{
cout<< "n Player " << player1 << "Enter the Box";
cin>> box;
mark( player1, box);
display();
result =checkwin();
if (result == 1 )
{ cout<<"n Congratualtions! player " << player1 << " has Won ";
flag = 1;
break;
}
else
if (result == 2 )
{ cout<<"n Congratualtions! player " << player2 << " has Won ";
flag = 1;
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
Artificial Intelligence Lab P a g e | 41 BTCS605-18
break;
}
cout<< "n Player " << player2 << "Enter the Box";
cin>> box;
mark ( player2, box);
display();
result =checkwin();
if (result == 1 )
{ cout<<"n Congratualtions! player " << player1 << " has Won ";
flag = 1;
break;
}
else
if (result == 2 )
{ cout<<"n Congratualtions! player " << player2 << " has Won ";
flag = 1;
break;
}
}
if (flag == 0 )
cout<<" n Sorry, The game is a draw ";
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
Artificial Intelligence Lab P a g e | 42 BTCS605-18
return 0;
}
OUTPUT:
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
Artificial Intelligence Lab P a g e | 43 BTCS605-18
PRACTICAL – 6
WRITE A PROGRAM TO IMPLEMENT FORWARD
CHAINING.
#include<iostream.h>
#include<conio.h>
char database[4][10]={"Croaks","EatFlies","Shrimps","Sings"};
charknowbase[4][10]={"Frog","Canary","Green","Yellow"};
int k=0,x=0;
void display();//display text
void main()
{
clrscr();
cout<<"*-----Forward--Chaning-----*";
display();
cout<<" n";
if(x==1 || x== 2)
{
cout<<" Chance Of Frog ";
}
else if(x==3 || x==4)
{
cout<<" Chance of Canary ";
}
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
Artificial Intelligence Lab P a g e | 44 BTCS605-18
else
{
cout<<"n-------In Valid Option Select --------";
}
if(x>=1 && x<=4)
{
cout<<"n X is "<<database[x-1];
cout<<"n Color Is 1.Green 2.Yellow";
cout<<"n Select Option ";
cin>>k;
if(k==1 && (x==1 || x==2))//frog0 and green1
cout<<" yes it is "<<knowbase[0]<<" And Color Is "<<knowbase[2];
else if(k==2 &&(x==3 || x==4))//canary1 and yellow3
cout<<" yes it is "<<knowbase[1]<<" And Color Is "<<knowbase[3];
else
{
cout<<"n---InValid Knowledge Database";
}
}
getch();
}
void display()
{
Artificial Intelligence Lab P a g e | 45 BTCS605-18
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
cout<<"n X is n1.Croaks n2.Eat Flies n3.shrimps n4.Sings ";
cout<<"n Select One ";
cin>>x;
}
OUTPUT
Artificial Intelligence Lab P a g e | 46 BTCS605-18
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
PRACTICAL – 7
WRITE A PROGRAM TO IMPLEMENT TOWER OF HANOI.
#include<iostream>
using namespace std;
//tower of HANOI function implementation
void TOH(int n,char Sour, char Aux,char Des)
{
if(n==1)
{
cout<<"Move Disk "<<n<<" from "<<Sour<<" to "<<Des<<endl;
return;
}
TOH(n-1,Sour,Des,Aux);
cout<<"Move Disk "<<n<<" from "<<Sour<<" to "<<Des<<endl;
TOH(n-1,Aux,Sour,Des);
}
//main program
int main()
{
Artificial Intelligence Lab P a g e | 47 BTCS605-18
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
int n;
cout<<"Enter no. of disks:";
cin>>n;
//calling the TOH
TOH(n,'A','B','C');
return 0;
}
OUTPUT
Artificial Intelligence Lab P a g e | 48 BTCS605-18
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
PRACTICAL – 8
WRITE A PROGRAM TO IMPLEMENT HEURISTIC SEARCH
PROCEDURE.
#include <iostream>
using namespace std;
int main()
{
stringa,b,c,d,e;
intt,u,v,w,z,p,q,r;
cout<< "Enter the root node"<<endl;
cin>> a;
cout<<" Enter the value of root node"<<endl;
cin>>t;
cout<< "Enter child 1"<<endl;
cin>>b;
cout<< "Enter value from root to child 1"<<endl; cin>>u;
cout<< "Enter value from child1 to terminal"<<endl; cin>> p;
cout<< "Enter child 2"<<endl;
cin>>c;
cout<< "Enter value of child 2"<<endl;
cin>>v;
cout<< "Enter value from child2 to terminal"<<endl; cin>> q;
cout<< "Enter child 3"<<endl;
cin>>d;
cout<< "Enter value of child 3"<<endl;
cin>>w;
cout<< "Enter value from child3 to terminal"<<endl; cin>> r;
cout<< "Enter terminal node"<<endl;
cin>> e;
if((u+p)<(v+q)&& (u+p)<(w+r))
{
cout<< "Heuristic path is from a to b to e"<<endl; cout<< "Total value is"<<t+u+p;
}
else if((v+q)<(u+p)&&(v+p)<(w+r))
{
cout<< "Heuristic path is from a to c to e"<<endl; cout<< "Total value is"<<t+v+p;
}
else if((w+r)<(u+p)&& (w+r)<(v+q))
{
Artificial Intelligence Lab P a g e | 49 BTCS605-18
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
cout<< "Heuristic path is from a to d to e"<<endl; cout<< "Total value is"<<t+w+r<<endl;
}
return 0;
}
OUTPUT
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
Artificial Intelligence Lab P a g e | 50 BTCS605-18
PRACTICAL – 9
WRITE A PROGRAM TO IMPLEMENT PRODUCTION
SYSTEM.
#include<iostream.h>
#include<conio.h>
int main()
{
char answer;
clrscr();
cout<<"Answer the following question to determine whether JOHN should get scholarship or
not?"<<endl;
cout<<"Q1) Is John a Student?(y/n)n";
cin>>answer;
if(answer=='y')
{
cout<<"John enjoys Student Life"<<endl;
cout<<"John Enjoys Student Life --> John Meets Friends"<<endl;
cout<<"John Enjoys Meets Friends --> John Needs Money"<<endl;
cout<<"Q2) Does John has a job?(y/n)";
cin>>answer;
if(answer=='y')
{
cout<<"John Has Job --> John Has Free Time"<<endl;
cout<<"Since John Works in Free Time--> John Is Not Not Good In Studies "<<endl;
cout<<"John should not get the scholarship";
}
}
else
cout<<"John Will not recieve scholarship as he is not a student"<<endl;
return 0;
}
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
Artificial Intelligence Lab P a g e | 51 BTCS605-18
OUTPUT
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
Artificial Intelligence Lab P a g e | 52 BTCS605-18
PRACTICAL – 10
WRITE A PROGRAM TO IMPLEMENT SEARCH PROBLEM
OF 3*3 PUZZLE.
#include <iostream>
#include <iomanip>
#include <array>
using namespace std;
void printarray(int num[3][3])
{
for(int i = 0;i < 3; i++)
{ for(int j = 0; j< 3; j++)
{
cout << num[i][j] << " ";
}
cout << "n";
}
}
void swapValues(int (&array)[3][3], int i1,int j1,int i2,int j2)
{
int temp = array[i1][j1];
array[i1][j1] = array[i2][j2];
array[i2][j2] = temp;
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
Artificial Intelligence Lab P a g e | 53 BTCS605-18
}
void moveleft(int (&array)[3][3], int i, int j)
{
if(i==1&&j==1)
{
swapValues(array, i, j, i-1, j);
swapValues(array, i, j, i+1, j);
}
else if(i==1&&j==2)
{
swapValues(array, i, j, i, j-1);
swapValues(array, i, j, i, j-2);
}
else if(i==0&&j==0)
{
swapValues(array, i, j+2, i, j);
swapValues(array, i, j+1, i, j);
}
else if(i==0&&j==2)
{
swapValues(array, i, j, i, j);
}
else swapValues(array, i, j, i-1, j);
Artificial Intelligence Lab P a g e | 54 BTCS605-18
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
swapValues(array, i, j, i+1, j);
}
void movedown(int (&array)[3][3], int i, int j)
{
if(i==0&&j==0)
}
swapValues(array, i, j, i+1, j);
swapValues(array, i, j, i+2, j);
}
else if(i==1&&j==1)
{
swapValues(array, i+1, j, i, j);
swapValues(array, i-1, j, i, j);
}
else if(i==0&&j==2)
{
swapValues(array, i, j, i+1, j);
}
else
swapValues(array, i, j, i-1, j);
swapValues(array, i, j, i+1, j);
}
void moveright(int (&array)[3][3], int i, int j)
{
Artificial Intelligence Lab P a g e | 55 BTCS605-18
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
if(i==0&&j==0)
{
swapValues(array, i, j+1, i, j);
swapValues(array, i, j+2, i, j);
}
else if(i==1&&j==1)
{
swapValues(array, i, j+1, i, j);
swapValues(array, i, j-1, i, j);
}
else if(i==1&&j==2)
{
swapValues(array, i, j-2, i, j);
swapValues(array, i, j-1, i, j);
}
else
swapValues(array, i, j, i-1, j);
swapValues(array, i, j, i+1, j);
}
void moveup(int (&array)[3][3], int i, int j)
{
if(i==0&&j==0)
{
swapValues(array, i, j, i+2, j);
Artificial Intelligence Lab P a g e | 56 BTCS605-18
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
swapValues(array, i, j, i+1, j);
}
else if(i==1&&j==1)
{
swapValues(array, i, j, i-1, j);
swapValues(array, i, j, i+1, j);
}
else if(i==0&&j==2)
{
swapValues(array, i, j, i+1, j);
swapValues(array, i, j, i+2, j);
swapValues(array, i, j, i+1, j);
}
else
swapValues(array, i, j, i-1, j);
swapValues(array, i, j, i+2, j);
//int coord1d = j * 3 + i;
}
class Puzzle {
public: Puzzle();
void swapValues(int num[3][3], int i1, int j1, int i2, int j2);
//void moveleft(int[3][3], int start1, int start2);
void moveup(int (&array)[3][3], int i, int j);
void moveright(int (&array)[3][3], int i, int j);
Artificial Intelligence Lab P a g e | 57 BTCS605-18
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
void moveleft(int (&array)[3][3], int i, int j);
void movedown(int (&array)[3][3], int i, int j);
void printarray(int[3][3]); };
int main()
{
int state1[3][3] = {{2, 8, 3}, {1, 6, 4}, {7, 0, 5}};
int state2[3][3] = {{2, 8, 1}, {4, 6, 3}, {0, 7, 5}};
int gstate[3][3] = {{1, 2, 3}, {8, 0, 4}, {7, 6, 5}};
cout << "this is state 1" << endl; printarray(state1);
cout << "nn";
cout << "now this is state 2" << endl;
printarray(state2);
cout << "nn";
cout << "now this is the goal state" << endl;
printarray(gstate);
int start1, start2;
cout << endl << endl << "please enter your starting point in the states listed above going up or
down" << endl;
cin >> start1;
cout << "now enter the point going left to right" << endl;
cin >> start2;
//moveleft(state1, start1, start2);
cout << "this is moving coordinate (1, 1) upwards" << endl;
moveup(state1, start1, start2);
Artificial Intelligence Lab P a g e | 58 BTCS605-18
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023
printarray(state1);
cout << endl;
cout << "this is moving coordinate (1, 1) to the left" << endl;
moveleft(state1, start1, start2);
printarray(state1);
cout << endl;
cout << "this is moving coordinate (1, 1) downwards" << endl;
movedown(state1, start1, start2);
printarray(state1);
cout << endl;
cout << "this is moving coordinate (1, 1) to the right" << endl;
moveright(state1, start1, start2);
printarray(state1);
cout << endl;
cin.get();
cin.get();
return 0;
}
OUTPUT
Artificial Intelligence Lab P a g e | 59 BTCS605-18
Lyallpur Khalsa College Technical Campus
Department of Computer Science & Engineering
CAY: 2022-2023

More Related Content

Similar to AI_LAB_Manual in c with all the programs

Electronic engineering syllabus at mitaoe
Electronic engineering syllabus at mitaoeElectronic engineering syllabus at mitaoe
Electronic engineering syllabus at mitaoeMITAcademy1
 
Digital System Design with FPGAs Lab Manual.pdf
Digital System Design with FPGAs Lab Manual.pdfDigital System Design with FPGAs Lab Manual.pdf
Digital System Design with FPGAs Lab Manual.pdfAmairullahKhanLodhi1
 
OS lab manual1234512345123451234512345.pdf
OS lab manual1234512345123451234512345.pdfOS lab manual1234512345123451234512345.pdf
OS lab manual1234512345123451234512345.pdfSuperBoy40
 
information-technology-engineering-syllabus-sem-v-mumbai-university.pdf
information-technology-engineering-syllabus-sem-v-mumbai-university.pdfinformation-technology-engineering-syllabus-sem-v-mumbai-university.pdf
information-technology-engineering-syllabus-sem-v-mumbai-university.pdfVirajKale9
 
Key Components of OBE for NBA and preparing Course file
Key Components of OBE for NBA and preparing Course fileKey Components of OBE for NBA and preparing Course file
Key Components of OBE for NBA and preparing Course fileRajsekhar33797
 
SDL-LAB-MANUAL-CS606-common-for-all-the-faculties.pdf
SDL-LAB-MANUAL-CS606-common-for-all-the-faculties.pdfSDL-LAB-MANUAL-CS606-common-for-all-the-faculties.pdf
SDL-LAB-MANUAL-CS606-common-for-all-the-faculties.pdfpriyanshuurkade
 
B tech information technology syllabus - MITAOE
B tech information technology syllabus - MITAOEB tech information technology syllabus - MITAOE
B tech information technology syllabus - MITAOEMITAcademy1
 
Chennai-PPT-3-Key Components of OBE-RVR-08-06-2018.pptx
Chennai-PPT-3-Key Components of OBE-RVR-08-06-2018.pptxChennai-PPT-3-Key Components of OBE-RVR-08-06-2018.pptx
Chennai-PPT-3-Key Components of OBE-RVR-08-06-2018.pptxAbhishek pradeep
 
CS8383 Object Oriented Programming Laboratory Manual
CS8383 Object Oriented Programming Laboratory ManualCS8383 Object Oriented Programming Laboratory Manual
CS8383 Object Oriented Programming Laboratory ManualMuthu Vinayagam
 
Materials Engineering Digital Notes.pdf
Materials Engineering Digital Notes.pdfMaterials Engineering Digital Notes.pdf
Materials Engineering Digital Notes.pdfSaiM624606
 
IT6611 Mobile Application Development Lab Manual
IT6611 Mobile Application Development Lab ManualIT6611 Mobile Application Development Lab Manual
IT6611 Mobile Application Development Lab Manualpkaviya
 
PPS Manual_AY_2021-22 I & II Sem.pdf
PPS Manual_AY_2021-22 I & II Sem.pdfPPS Manual_AY_2021-22 I & II Sem.pdf
PPS Manual_AY_2021-22 I & II Sem.pdfSugnanaraoM
 
co-po-example of bloomy taxonomy to grade your teaching methods
co-po-example of bloomy taxonomy to grade your teaching methodsco-po-example of bloomy taxonomy to grade your teaching methods
co-po-example of bloomy taxonomy to grade your teaching methodseurokidsThaneBhayend
 
Te computer-syllabus-2015-course-3-4-17
Te computer-syllabus-2015-course-3-4-17Te computer-syllabus-2015-course-3-4-17
Te computer-syllabus-2015-course-3-4-17abc19789
 
Maintenance and Safety Engineering.pdf
Maintenance and Safety Engineering.pdfMaintenance and Safety Engineering.pdf
Maintenance and Safety Engineering.pdfJohnPaulAbabaLandoy
 
B.p. poddar group department of information technology | bppimt
B.p. poddar group department of information technology | bppimtB.p. poddar group department of information technology | bppimt
B.p. poddar group department of information technology | bppimtShirsendu Kar
 

Similar to AI_LAB_Manual in c with all the programs (20)

Electronic engineering syllabus at mitaoe
Electronic engineering syllabus at mitaoeElectronic engineering syllabus at mitaoe
Electronic engineering syllabus at mitaoe
 
Digital System Design with FPGAs Lab Manual.pdf
Digital System Design with FPGAs Lab Manual.pdfDigital System Design with FPGAs Lab Manual.pdf
Digital System Design with FPGAs Lab Manual.pdf
 
OS lab manual1234512345123451234512345.pdf
OS lab manual1234512345123451234512345.pdfOS lab manual1234512345123451234512345.pdf
OS lab manual1234512345123451234512345.pdf
 
Cn lab manual sb 19_scsl56 (1)
Cn lab manual sb 19_scsl56 (1)Cn lab manual sb 19_scsl56 (1)
Cn lab manual sb 19_scsl56 (1)
 
information-technology-engineering-syllabus-sem-v-mumbai-university.pdf
information-technology-engineering-syllabus-sem-v-mumbai-university.pdfinformation-technology-engineering-syllabus-sem-v-mumbai-university.pdf
information-technology-engineering-syllabus-sem-v-mumbai-university.pdf
 
Key Components of OBE for NBA and preparing Course file
Key Components of OBE for NBA and preparing Course fileKey Components of OBE for NBA and preparing Course file
Key Components of OBE for NBA and preparing Course file
 
SDL-LAB-MANUAL-CS606-common-for-all-the-faculties.pdf
SDL-LAB-MANUAL-CS606-common-for-all-the-faculties.pdfSDL-LAB-MANUAL-CS606-common-for-all-the-faculties.pdf
SDL-LAB-MANUAL-CS606-common-for-all-the-faculties.pdf
 
B tech information technology syllabus - MITAOE
B tech information technology syllabus - MITAOEB tech information technology syllabus - MITAOE
B tech information technology syllabus - MITAOE
 
0. CSE205 (3).ppt
0. CSE205 (3).ppt0. CSE205 (3).ppt
0. CSE205 (3).ppt
 
Ar18 mechanical 23-03-21
Ar18 mechanical 23-03-21Ar18 mechanical 23-03-21
Ar18 mechanical 23-03-21
 
Chennai-PPT-3-Key Components of OBE-RVR-08-06-2018.pptx
Chennai-PPT-3-Key Components of OBE-RVR-08-06-2018.pptxChennai-PPT-3-Key Components of OBE-RVR-08-06-2018.pptx
Chennai-PPT-3-Key Components of OBE-RVR-08-06-2018.pptx
 
CS8383 Object Oriented Programming Laboratory Manual
CS8383 Object Oriented Programming Laboratory ManualCS8383 Object Oriented Programming Laboratory Manual
CS8383 Object Oriented Programming Laboratory Manual
 
Materials Engineering Digital Notes.pdf
Materials Engineering Digital Notes.pdfMaterials Engineering Digital Notes.pdf
Materials Engineering Digital Notes.pdf
 
Oose lab notes
Oose lab notesOose lab notes
Oose lab notes
 
IT6611 Mobile Application Development Lab Manual
IT6611 Mobile Application Development Lab ManualIT6611 Mobile Application Development Lab Manual
IT6611 Mobile Application Development Lab Manual
 
PPS Manual_AY_2021-22 I & II Sem.pdf
PPS Manual_AY_2021-22 I & II Sem.pdfPPS Manual_AY_2021-22 I & II Sem.pdf
PPS Manual_AY_2021-22 I & II Sem.pdf
 
co-po-example of bloomy taxonomy to grade your teaching methods
co-po-example of bloomy taxonomy to grade your teaching methodsco-po-example of bloomy taxonomy to grade your teaching methods
co-po-example of bloomy taxonomy to grade your teaching methods
 
Te computer-syllabus-2015-course-3-4-17
Te computer-syllabus-2015-course-3-4-17Te computer-syllabus-2015-course-3-4-17
Te computer-syllabus-2015-course-3-4-17
 
Maintenance and Safety Engineering.pdf
Maintenance and Safety Engineering.pdfMaintenance and Safety Engineering.pdf
Maintenance and Safety Engineering.pdf
 
B.p. poddar group department of information technology | bppimt
B.p. poddar group department of information technology | bppimtB.p. poddar group department of information technology | bppimt
B.p. poddar group department of information technology | bppimt
 

Recently uploaded

Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)simmis5
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 

Recently uploaded (20)

Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 

AI_LAB_Manual in c with all the programs

  • 1. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering
  • 2. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering Vision and mission of the department Vision of the Department To groom students into competent engineers and entrepreneurs, by inculcating technical education, ethical and moral values through measurable and continuous improvement methods. Mission of the Department 1. To model students ready for industry by grooming their employability skills using academia and corporate collaboration. 2. To blend theoretical knowledge and practical applications with the aid of trainings, peer learning and sound academic practices. 3. Cultivate leadership skills, social awareness and responsibility among the students through various co-curriculum and extra curriculum activities. 4. To encourage the involvement of faculty in pursuing their own academic excellence through the aid of faculty development programmes, short term training programmes, seminars, workshops etc.
  • 3. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering Program Educational Objectives (PEOs) Three PEO’s have been defined as PEO1: To provide the basic knowledge of engineering concepts and fundamentals to computer graduates by logical and practical approach for problem solving and function effectively as a skilled computer engineer and pursue their higher education or emerge as an entrepreneur. PEO2: To inculcate creative abilities by imparting knowledge and skills for analyze, design, test and implement various software applications. PEO3: To instill leadership capabilities, social-economic sense, commitment, ethics and community services for the protection of environment.
  • 4. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering Program Outcome (POs) PO1: Engineering knowledge: Apply the knowledge of mathematics, science, engineering fundamentals, and an engineering specialization to the solution of complex engineering problems. PO2: Problem analysis: Identify, formulate, review research literature, and analyze complex engineering problems reaching substantiated conclusions using first principles of mathematics, natural sciences, and engineering sciences. PO3: Design/development of solutions: Design solutions for complex engineering problems and design system components or processes that meet the specified needs with appropriate consideration for the public health and safety, and the cultural, societal, and environmental considerations. PO4: Conduct investigations of complex problems: Use research-based knowledge and research methods including design of experiments, analysis and interpretation of data, and synthesis of the information to provide valid conclusions. PO5: Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern engineering and IT tools including prediction and modeling to complex engineering activities with an understanding of the limitations. PO6: The engineer and society: Apply reasoning informed by the contextual knowledge to assess societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to the professional engineering practice. PO7: Environment and sustainability: Understand the impact of the professional engineering solutions in societal and environmental contexts, and demonstrate the knowledge of, and need for sustainable development. PO8: Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms of the engineering practice. PO9: Individual and teamwork: Function effectively as an individual, and as a member or leader in diverse teams, and in multidisciplinary settings. PO10: Communication: Communicate effectively on complex engineering activities with the engineering community and with society at large, such as, being able to comprehend
  • 5. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering and write effective reports and design documentation, make effective presentations, and give and receive clear instructions. PO11: Project management and finance: Demonstrate knowledge and understanding of the engineering and management principles and apply these to one’s own work, as a member and leader in a team, to manage projects and in multidisciplinary environments. PO12: Life-long learning: Recognize the need for, and have the preparation and ability to engage in independent and life-long learning in the broadest context of technological change.
  • 6. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering Program Specific Outcome PSO 1: Problem Solving Ability: Ability to analyze, formulate and develop computer programs and computer-based software’s for real time environment related to database, networking, web development and AI. PSO 2: Software Development: Ability to apply their practical knowledge in software project management and development using suitable programming environments to deliver quality product for the industry and society.
  • 7. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering Mapping of Co’s with Pos Course Name: Artificial Intelligence (BTAIML 502-20) (B.Tech DS-5th) Year of study 2023-2024 Course Outcomes After the course completion, students will be able to: BTAIML 502-20.1 Understand different types of AI agents. BTAIML 502-20.2 Develop different types of various AI search algorithms. BTAIML 502-20.3 Construct simple knowledge-based systems and to apply knowledge representation. BTAIML 502-20.4 Convert intermediate representation in contest to understand learning. BTAIML 502-20.5 Apply for various techniques for Expert Systems. Course Name: Artificial Intelligence (BTAIML 502-20) (B.Tech DS-5th) Year of Study 2023-2024 CO PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 BTAIML 502-20.1 3 3 3 3 2 - - - - - - 2 BTAIML 502-20.1 3 3 3 3 3 - - - - - - 2 BTAIML 502-20.1 3 3 3 3 3 - - - - - - 2 BTAIML 502-20.1 3 3 3 3 3 - - - - - - 2 BTAIML 502-20.1 3 3 3 3 3 - - - - - - 2 Average 3 3 3 3 2.8 0 0 0 0 0 0 2
  • 8. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering Course Name: Artificial Intelligence (BTAIML 502-20) (B.Tech DS-5th) Year of Study 2023-2024 CO PSO1 PSO2 BTAIML 502-20.1 3 3 BTAIML 502-20.1 3 3 BTAIML 502-20.1 3 3 BTAIML 502-20.1 3 3 BTAIML 502-20.1 3 3 Average 3 3
  • 9. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering Name of the program and semester: B.Tech, CSE DS 5th Sem Course Code: BTAIML 502-20 Course Incharge Name: Dr. Sucharu Mahajan Course Name: Artificial Intelligence Course Outcomes (Cos) Course Outcomes After the course completion, students will be able to: C502-20.1 Understand different types of AI agents. C502-20.2 Develop different types of various AI search algorithms C502-20.3 Construct simple knowledge-based systems and to apply knowledge representation. C502-20.4 Convert intermediate representation in contest to understand learning. C502-20.5 Apply for various techniques for Expert Systems. Program Specific Outcome PSO 1:Problem Solving Ability: Ability to analyze, formulate and develop computer programs and computer-based softwares for real time environment related to database, networking, web development and AI. PSO 2:Software Development: Ability to apply their practical knowledge in software project management and development using suitable programming environments to deliver quality product for the industry and society.
  • 10. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CO-PSO Mapping: CO PSO1 PSO2 C502-20.1 3 3 C502-20.2 3 3 C502-20.3 3 3 C502-20.4 3 3 C502-20.5 3 3 Average 3 3 Note: 1. Enter correlations levels 1, 2 or 3 as defined below: 1. Slight (Low) 2. Moderate (Medium) 3. Substantial (High)
  • 11. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering General Guidelines and Rules for Faculty Guidelines: 1. Lab evaluation should be done by the course Instructor during the scheduled lectures on the basis of the file record, Viva-voce and practical task executed in the computer lab. 2. There should be at least 4 lab evaluations in a semester for a particular course. The schedule of Lab Evaluations i.e. topic and date should be intimated to the students well in advance and preferably it should be done in the consecutive lab sessions.
  • 12. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering General Instructions for students DOs and Don’ts in Laboratory: 1. Make entry in the Log Book as soon as you enter the Laboratory. 2. All the students should sit according to their roll numbers starting from their left to right. 3. All the students are supposed to enter the terminal number in the log book. 4. Do not change the terminal on which you are working. 5. All the students are expected to get at least the algorithm of the program/concept to be implemented. 6. Strictly observe the instructions given by the teacher/Lab Instructor. 7. Do not drink or eat in the Lab 8. Don’t use cell phones or any other mobile device unless instructed by the teacher/Instructor
  • 13. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering IKGPTU Syllabus Scheme:
  • 14. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering Syllabus as per IKGPTU: Course Code: BTAIML504-20 Course Title Artificial Intelligence Lab L:0;T:0;P:2 1 Credits Detailed List of Tasks: 1.Write a programme to conduct uninformed and informed search. 2. Write a programme to conduct game search. 3. Write a programme to construct a Bayesian network from given data. 4. Write a programme to infer from the Bayesian network. 5. Write a programme to run value and policy iteration in a grid world. 6. Write a programme to do reinforcement learning in a grid world Lab Outcomes: At the end of the course, the students are able to: 1. Explain artificial intelligence, its characteristics and its application areas. 2. Formulate real-world problems as state space problems, optimization problems or constraint satisfaction problems. 3. Select and apply appropriate algorithms and AI techniques to solve complex problems. 4. Design and develop an expert system by using appropriate tools and techniques.
  • 15. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering Lab Manual PROGRAMME: B.Tech (CSE)DS COURSE: Artificial Intelligence Lab SEMESTER: 5th COURSE CODE: BTAIML504-20 CREDITS: 1 COURSE AREA/ DOMAIN: Programming COURSE TYPE: Compulsory Faculty Incharge: Dr. Sucharu Mahajan CONTACT HOURS: 44hrs Course Description: Artificial intelligence (AI) is wide-ranging branch of computer science concerned with building smart machines capable of performing tasks that typically require human intelligence. AI is an interdisciplinary science with multiple approaches, but advancements in machine learning and deep learning are creating a paradigm shift in virtually every sector of the tech industry. Course Objective: Humanity is at an impasse now. Governments and politicians are struggling to remain on top of a constantly growing set of threat vectors, mountains of data, and fundamental economic and governance issues. Moving well beyond nature’s evolution roadmap, we have created incredible powers of information acquisition, we live longer lives, and we have greater capabilities than our forefathers would have ever believed possible. Additional convergences of biological and digital systems will take us to even higher levels of capabilities, but also increase complexities in society and create even more need for analysis capabilities. AI can assist us here. A vast and growing sector, AI – especially with deep learning - has the ability to process massive amounts of data, whether it is images, text, voice, numbers, etc. Numerous technology websites report on AI developments; for example, TechCrunch, CNET, Futurism, etc. There are daily reports of major advances by AI that go beyond what a human can accomplish. Art forgeries are detected with 99% accuracy from a single brush stroke. Lip reading is done by an AI with greater accuracy than the best humans. Skin cancer is detected by a deep learning trained AI algorithm with greater fidelity than dermatologists. While still considered Narrow AI, potential exists to expand these accomplishments into greater capabilities and thus to handle more complex problem sets. Although progress to mimic a human in General AI is slow presently, some researchers believe we have only begun to tap the full power of AI.
  • 16. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering The challenge before us is to develop AI quickly as our society increases in its economic, political, military and psychological challenges. We have a great future ahead of us, but only if we get help in unraveling the complexities of our modern world. Course Outcomes Student will able to: BTAIML504- 20.1 Apply various uninformed and informed AI search algorithms. BTAIML504- 20.2 Apply AI search algorithms using Heuristic function and select amongst different search or game-based techniques to solve them. BTAIML504- 20.3 Apply knowledge representation and machine learning techniques to real-world problems (production system, search problems of 3 x 3 puzzle)
  • 17. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering Artificial Intelligence Lab P a g e | 10 BTCS605-18 HISTORY OF AI Intelligent robots and artificial beings first appeared in the ancient Greek myths of Antiquity. Aristotle's development of the syllogism and it’s use of deductive reasoning was a key moment in mankind's quest to understand its own intelligence. While the roots are long and deep, the history of artificial intelligence as we think of it today spans less than a century. The following is a quick look at some of the most important events in AI. 1943 1949 1950 1956 1958 1963 1966 1969 1972 1973 ● Warren McCullough and Walter Pitts publish "A Logical Calculus of Ideas Immanent in Nervous Activity." The paper proposed the first mathematic model for building a neural network. ● In his book The Organization of Behavior: A Neuropsychological Theory, Donald Hebb proposes the theory that neural pathways are created from experiences and that connections between neurons become stronger the more frequently they're used. Hebbian learning continues to be an important model in AI. ● Alan Turing publishes "Computing Machinery and Intelligence, proposing what is now known as the Turing Test, a method for determining if a machine is intelligent. ● Harvard undergraduates Marvin Minsky and Dean Edmonds build SNARC, the first neural network computer. ● Claude Shannon publishes the paper "Programming a Computer for Playing Chess." ● Isaac Asimov publishes the "Three Laws of Robotics." ● The phrase artificial intelligence is coined at the "Dartmouth Summer Research ● Allen Newell and Herbert Simon demonstrate Logic Theorist (LT), the first reasoning program. ● John McCarthy develops the AI programming language Lisp and publishes the paper "Programs with Common Sense." ● John McCarthy starts the AI Lab at Stanford. ● The ALPAC report leads to the cancellation of all government-funded MT projects. ● The first successful expert systems are developed in DENDRAL, a XX program, and MYCIN, designed to diagnose blood infections, are created at Stanford. ● The logic programming language PROLOG is created.
  • 18. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering Artificial Intelligence Lab P a g e | 11 BTCS605-18 ● The "Lighthill Report," detailing the disappointments in AI research, is released by the British government and leads to severe cuts in funding for artificial intelligence projects. 1980 1982 ● Digital Equipment Corporation develops R1 (also known as XCON), the first successful commercial expert system. Designed to configure orders for new computer systems, R1 kicks off an investment boom in expert systems that will last for much of the decade, effectively ending the first "AI Winter." ● Japan's Ministry of International Trade and Industry launches the ambitious Fifth Generation Computer Systems project. 1983 ● In response to Japan's FGCS, the U.S. government launches the Strategic Computing Initiative to provide DARPA funded research in advanced computing and artificial intelligence. 1987-1993 ● As computing technology improved, cheaper alternatives emerged and the Lisp machine market collapsed in 1987, ushering in the "Second AI Winter." ● Japan terminates the FGCS project in 1992, citing failure in meeting the ambitious goals outlined a decade earlier. ● DARPA ends the Strategic Computing Initiative in 1993 after spending nearly $1 billion and falling far short of expectations. 1991 2005 2008 2014 2016 ● U.S. forces deploy DART, an automated logistics planning and scheduling tool, during the Gulf War. ● STANLEY, a self-driving car, wins the DARPA Grand Challenge. ● The U.S. military begins investing in autonomous robots like Boston Dynamic's "Big Dog" and iRobot's "PackBot." ● Google makes breakthroughs in speech recognition and introduces the feature in its iPhone app. ● Google makes first self-driving car to pass a state driving test. ● Google DeepMind's AlphaGo defeats world champion Go player Lee Sedol. The complexity of the ancient Chinese game was seen as a major hurdle to clear in AI.
  • 19. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering Artificial Intelligence Lab P a g e | 12 BTCS605-18 Course Name: Artificial Intelligence Lab (BTAIML504-20) (B. Tech CSE-DS 5th) Year of study: 2023-2024 Course Outcomes After the course completion, students will be able to: BTCS605- 18.1 Apply various uninformed and informed AI search algorithms. BTCS605- 18.2 Apply AI search algorithms using Heuristic function and select amongst different search or game based techniques to solve them. BTCS605- 18.3 Apply knowledge representation and machine learning techniques to real- world problems (production system, search problems of 3 x 3 puzzle) CO-PO Mapping: CO PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 BTCS605- 18.1 3 3 3 1 3 1 - - - - - 1 BTCS605- 18.2 3 3 3 1 3 1 - - - - - 1 BTCS605- 18.3 3 3 3 1 3 1 - - - - - 1 Average 3 3 3 1 3 1 - - - - - 1 CO-PSO Mapping: CO PSO1 PSO2 BTCS605-18.1 3 2 BTCS605-18.2 3 3 BTCS605-18.3 3 3 Average 3 2.6 Note: 1. Enter correlations levels 1, 2 or 3 as defined below: 1. Slight (Low) 2. Moderate (Medium) 3. Substantial (High)
  • 20. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering Artificial Intelligence Lab P a g e | 13 BTCS605-18 List of Practical: Task 1. Write a Program for Depth First Search. Task 2. Write a Program for Best First Search. Task 3. Write a Program to Generate the output for A* Algorithm. Task 4. Write a Lisp Program to solve Water Jug Problem Using Heuristic Function. Task 5. Write a Program to Show the Tic Tac Toe Game for 0 and X. Task 6. Write A Program for Expert System by Using Forward Chaining. Task 7. Write a program to implement tower of Hanoi. Task 8. Write a program to implement a heuristic search procedure. Task 9. Write a program to implement a production system. Task 10. Write a program to implement search problems of 3 x 3 puzzle.
  • 21. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering Artificial Intelligence Lab P a g e | 14 BTCS605-18 CO Mapping: Task 1. Write a Program for Depth First Search. - (CO1) Task 2. Write a Program for Best First Search. - (CO1) Task 3. Write a Program to Generate the output for A* Algorithm. - (CO1) Task 4. Write a Lisp Program to solve Water Jug Problem Using Heuristic Function. - (CO2) Task 5. Write a Program to Show the Tic Tac Toe Game for 0 and X. - (CO2) Task 6. Write A Program for Expert System by Using Forward Chaining. - (CO2) Task 7. Write a program to implement tower of Hanoi. - (CO3) Task 8. Write a program to implement a heuristic search procedure. - (CO3) Task 9. Write a program to implement a production system. - (CO3) Task 10. Write a program to implement search problems of 3 x 3 puzzle. - (CO3)
  • 22. Artificial Intelligence Lab P a g e | 15 BTCS605-18 Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering Table of Content: SNo. Name of the Practical Page No. 1 Write A Program for Depth First Search 16 2 Write A Program for Best First Search 22 3 Write A Program to Generate the output for A* Algorithm 28 4 Write a Lisp Program to solve Water Jug Problem Using Heuristic Function 32 5 Write a Program to Show the Tic Tac Toe Game for 0 and X 36 6 Write A Program for Expert System by Using Forward Chaining 43 7 Write a program to implement tower of Hanoi 46 8 Write a program to implement a heuristic search procedure 48 9 Write a program to implement a production system 50 10 Write a program to implement search problems of 3 x 3 puzzle 52
  • 23. Artificial Intelligence Lab P a g e | 16 BTCS605-18 Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 PRACTICAL – 1 WRITE A PROGRAM TO IMPLEMENT DEPTH FIRST SEARCH (DFS) #include<iostream> #define MAX 10 using namespace std; struct stack { int top; int elements[MAX]; }s; void initialise() { s.top=-1; } int IsFull() { if(s.top>=(MAX-1)) { return 1; }
  • 24. Artificial Intelligence Lab P a g e | 17 BTCS605-18 Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 else { return 0; } } int IsEmpty() { if(s.top==-1) { return 1; } else { return 0; } } void Push(int item) { IsFull(); s.top=s.top+1; s.elements[s.top]=item; } int Pop()
  • 25. Artificial Intelligence Lab P a g e | 18 BTCS605-18 Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 { IsEmpty(); int item; item=s.elements[s.top]; s.top=s.top-1; return item; } void DFS(int n,int v,int cost[50][50]) { initialise(); int u,i,visited[50]; int k=1; for(i=1;i<=n;i++) { visited[i]=0; } u=v; visited[v]=1; while(k<n) { for(i=1;i<=n;i++) { if(cost[u][i]==1 && visited[i]==0)
  • 26. Artificial Intelligence Lab P a g e | 19 BTCS605-18 Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 { Push(i); visited[i]=1; } } if(IsEmpty()) { return; } u=Pop(); cout<<u<<"t"; k++; } } int main() { int e,n,cost[50][50],i,j,v; cout<<"Enter the number of vertices="; cin>>n; for(i=1;i<=n;i++) { for(j=1;j<=n;j++) { cost[i][j]=0;
  • 27. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 Artificial Intelligence Lab P a g e | 20 BTCS605-18 } } cout<<"Enter the number of edges="; cin>>e; for(int k=1;k<=e;k++) { cout<<"nInitial vertex for edge "<<k<<" is = "; cin>>i; cout<<"Final vertex for edge "<<k<<" is = "; cin>>j; cost[i][j]=cost[j][i]=1; } cout<<"nEnter the source node = "; cin>>v; cout<<"Result of DFS is - "<<endl; cout<<v<<"t"; DFS(n,v,cost); } OUTPUT:
  • 28. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 Artificial Intelligence Lab P a g e | 21 BTCS605-18
  • 29. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 Artificial Intelligence Lab P a g e | 22 BTCS605-18 PRACTICAL -2 WRITE A PROGRAM TO IMPLEMENT BEST FIRST SEARCH(BFS) #include<iostream.h> #include<conio.h> #define MAX 10 struct queue { int front, rear, item; int elements[MAX]; }s; void initialise() { s.front=-1; s.rear=-1; } int IsFull() { if(s.front==0 || s.rear>=(MAX-1)) { return 1; } else
  • 30. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 Artificial Intelligence Lab P a g e | 23 BTCS605-18 { return 0; } } int IsEmpty() { if(s.front==-1 && s.rear==-1) { return 1; } else { return 0; } } void Enqueue(int item) { IsFull(); if(s.front==-1) { s.front=s.front+1; } s.rear=s.rear+1; s.elements[s.rear]=item; }
  • 31. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 Artificial Intelligence Lab P a g e | 24 BTCS605-18 int Dequeue() { IsEmpty(); s.item=s.elements[s.front]; s.front=s.front+1; return s.item; } void BFS(int n,int v,int cost[50][50]) { initialise(); int u,i,visited[50]; int k=1; for(i#include<iostream.h> #include<conio.h> #define MAX 10 =1;i<=n;i++) { visited[i]=0; } u=v; visited[v]=1; while(k<n) {
  • 32. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 Artificial Intelligence Lab P a g e | 25 BTCS605-18 for(i=1;i<=n;i++) { if(cost[u][i]==1 && visited[i]==0) { Enqueue(i); visited[i]=1; } } if(IsEmpty()) { return; } u=Dequeue(); cout<<u<<”t”; k++; } } void main() { clrscr(); int e,n,cost[50][50],i,j,v; cout<<"Enter the number of vertices="; cin>>n; for(i=1;i<=n;i++)
  • 33. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 Artificial Intelligence Lab P a g e | 26 BTCS605-18 { for(j=1;j<=n;j++) { cost[i][j]=0; } } cout<<"Enter the number of edges="; cin>>e; for(int k=1;k<=e;k++) { cout<<"nInitial vertex for edge "<<k<<" is = "; cin>>i; cout<<"Final vertex for edge "<<k<<" is = "; cin>>j; cost[i][j]=cost[j][i]=1; } cout<<"nEnter the source node = "; cin>>v; cout<<"Result of BFS is- "<<endl; cout<<v<<”t”; BFS(n,v,cost); getch(); }
  • 34. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 Artificial Intelligence Lab P a g e | 27 BTCS605-18 OUTPUT:
  • 35. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 Artificial Intelligence Lab P a g e | 28 BTCS605-18 PRACTICAL-3 WRITE A PROGRAM TO IMPLEMENT A* SEARCH #include<iostream> using namespace std; int main() { int i,j,m,cost[50][50],n,c,v,dist[20],s[20],path[20],p,min,minnode; cout<<"Enter the number of vertices**"; cin>>n; for(i=1;i<=n;i++) { for(j=1;j<=n;j++) { cost[i][j]=100; } } cout<<"Enter the number of edges**"; cin>>m; for(int k=1;k<=m;k++) { cout<<"Enter Edges and Cost**"; cin>>i>>j>>c;
  • 36. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 Artificial Intelligence Lab P a g e | 29 BTCS605-18 cost[i][j]=c; cost[j][i]=c; } cout<<"Adjency matrix for graph is **"<<endl; for(i=1;i<=n;i++) { for(j=1;j<=n;j++) { cout<<cost[i][j]<<"t"; } cout<<endl; } cout<<"Enter the initial vertex**="; cin>>v; for(i=1;i<=n;i++) { s[i]=0; dist[i]=cost[v][i]; } s[v]=1; dist[v]=0; for(i=2;i<=n-1;i++) { min=100; for(j=2;j<=n;j++)
  • 37. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 Artificial Intelligence Lab P a g e | 30 BTCS605-18 { if(dist[j]<min && s[j]!=1) { min=dist[j]; minnode=j; } } cout<<"min="<<minnode<<"t"; s[minnode]=1; for(int w=2;w<=n;w++) { if(cost[minnode][w]!=100 && s[w]==0) { if(dist[w]>=dist[minnode]+cost[minnode][w]) dist[w]=dist[minnode]+cost[minnode][w]; } }} for(i=1;i<=n;i++) { cout<<dist[i]<<"n"; } }
  • 38. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 Artificial Intelligence Lab P a g e | 31 BTCS605-18 OUTPUT:
  • 39. Artificial Intelligence Lab P a g e | 32 BTCS605-18 Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 PRACTICAL – 4 WRITE A LISP PROGRAM TO SOLVE WATER JUG PROBLEM USING HEURISTIC FUNCTION. #include<iostream> using namespace std; class Jug{ int capacity; int value; public: Jug(int n) { capacity = n; value = 0; } void Fill() { value = capacity; } void Empty() { value = 0; } bool isFull() { return value >= capacity; } bool isEmpty() { return value == 0; } //A[B] -> Transfer contents of B to A until A is full void operator[](Jug &B) { int old_value = value; value = value + B.value; value = value > capacity?capacity:value;
  • 40. Artificial Intelligence Lab P a g e | 33 BTCS605-18 Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 B.value = B.value - (value - old_value); } int getValue() { return value; } }; int gcd(int n,int m) { if(m<=n && n%m == 0) return m; if(n < m) return gcd(m,n); else } return gcd(m,n%m); bool check(int a,int b,int c){ //boundary cases if(c>a){ cout<<"A can't hold more water than it's capacity!n"; return false; } //if c is multiple of HCF of a and b, then possible if(c % gcd(a,b) == 0){ return true; } //if c is not multiple of HCF of a and b, then not possible cout<<"Can't reach this state with the given jugsn"; return false; } void solve(Jug A, Jug B, int result) { while(A.getValue() != result) { if(!A.isFull() && B.isEmpty()){ cout<<"Fill Bn"; B.Fill(); cout << "(A, B) = (" << A.getValue() << ", " << B.getValue() << ")n"; }
  • 41. Artificial Intelligence Lab P a g e | 34 BTCS605-18 Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 if(A.isFull()){ cout<<"Empty An"; A.Empty(); cout << "(A, B) = (" << A.getValue() << ", " << B.getValue() << ")n"; } cout<<"Pour from B into An"; A[B]; cout << "(A, B) = (" << A.getValue() << ", " << B.getValue() << ")n"; } } int main() { int a, b, result; cout<<"Enter capacity of An"; cin >> a; cout<<"Enter capacity of Bn"; cin >> b; do{ cout<<"Enter required water in A:n"; cin >> result; } while(!check(a,b,result)); Jug A(a), B(b); cout << "n(A, B) = (" << A.getValue() << ", " << B.getValue() << ")n"; solve(A, B, result); cout<<"Done!"<<endl; #ifdef _WIN32 system("pause"); #endif return 0; }
  • 42. Artificial Intelligence Lab P a g e | 35 BTCS605-18 Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 OUTPUT
  • 43. Artificial Intelligence Lab P a g e | 36 BTCS605-18 Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 PRACTICAL – 5 WRITE A PROGRAM TO IMPLEMENT TIC TAC TOE GAME FOR 0 AND X. #include <iostream> using namespace std; char square[9] = {'0','1','2','3','4','5','6','7','8'}; int checkwin() { if (square[0] == square [1] && square[1] == square[2] ) { if ( square [0] == 'X' ) return 1; else return 2; } else if (square[3] == square [4] && square[4] == square[5] ) { if ( square [3] == 'X' ) return 1; else return 2; } else
  • 44. Artificial Intelligence Lab P a g e | 37 BTCS605-18 Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 if (square[6] == square [7] && square[7] == square[8] ) { if ( square [6] == 'X' ) return 1; else return 2; } else if (square[0] == square [3] && square[3] == square[6] ) { if ( square [0] == 'X' ) return 1; else return 2; } else if (square[1] == square [4] && square[4] == square[7] ) { if ( square [1] == 'X' ) return 1; else return 2; } else if (square[2] == square [5] && square[5] == square[8] ) { if ( square [2] == 'X' ) return 1;
  • 45. Artificial Intelligence Lab P a g e | 38 BTCS605-18 Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 else return 2; } else if (square[0] == square [4] && square[4] == square[8] ) { if ( square [0] == 'X' ) return 1; else return 2; } else if (square[2] == square [4] && square[4] == square[6] ) { if ( square [2] == 'X' ) return 1; else return 2; } else if (square[0] == square [3] && square[3] == square[6] ) { if ( square [0] == 'X' ) return 1; else return 2; }
  • 46. Artificial Intelligence Lab P a g e | 39 BTCS605-18 Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 else return 0; } void mark(int player, int box) { if (player == 1 ) { square[box] = 'X'; } else square[box] = 'Y'; } void display() { for(int i=0;i<9;i++) { cout<< square[i] << "t" ; if (i == 2 || i== 5 || i==8) cout<<"n"; } }
  • 47. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 Artificial Intelligence Lab P a g e | 40 BTCS605-18 int main() { int player1 = 1, player2 =2 ; int box, result = 0, flag = 0; for(int i=1;i<5;i++) { cout<< "n Player " << player1 << "Enter the Box"; cin>> box; mark( player1, box); display(); result =checkwin(); if (result == 1 ) { cout<<"n Congratualtions! player " << player1 << " has Won "; flag = 1; break; } else if (result == 2 ) { cout<<"n Congratualtions! player " << player2 << " has Won "; flag = 1;
  • 48. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 Artificial Intelligence Lab P a g e | 41 BTCS605-18 break; } cout<< "n Player " << player2 << "Enter the Box"; cin>> box; mark ( player2, box); display(); result =checkwin(); if (result == 1 ) { cout<<"n Congratualtions! player " << player1 << " has Won "; flag = 1; break; } else if (result == 2 ) { cout<<"n Congratualtions! player " << player2 << " has Won "; flag = 1; break; } } if (flag == 0 ) cout<<" n Sorry, The game is a draw ";
  • 49. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 Artificial Intelligence Lab P a g e | 42 BTCS605-18 return 0; } OUTPUT:
  • 50. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 Artificial Intelligence Lab P a g e | 43 BTCS605-18 PRACTICAL – 6 WRITE A PROGRAM TO IMPLEMENT FORWARD CHAINING. #include<iostream.h> #include<conio.h> char database[4][10]={"Croaks","EatFlies","Shrimps","Sings"}; charknowbase[4][10]={"Frog","Canary","Green","Yellow"}; int k=0,x=0; void display();//display text void main() { clrscr(); cout<<"*-----Forward--Chaning-----*"; display(); cout<<" n"; if(x==1 || x== 2) { cout<<" Chance Of Frog "; } else if(x==3 || x==4) { cout<<" Chance of Canary "; }
  • 51. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 Artificial Intelligence Lab P a g e | 44 BTCS605-18 else { cout<<"n-------In Valid Option Select --------"; } if(x>=1 && x<=4) { cout<<"n X is "<<database[x-1]; cout<<"n Color Is 1.Green 2.Yellow"; cout<<"n Select Option "; cin>>k; if(k==1 && (x==1 || x==2))//frog0 and green1 cout<<" yes it is "<<knowbase[0]<<" And Color Is "<<knowbase[2]; else if(k==2 &&(x==3 || x==4))//canary1 and yellow3 cout<<" yes it is "<<knowbase[1]<<" And Color Is "<<knowbase[3]; else { cout<<"n---InValid Knowledge Database"; } } getch(); } void display() {
  • 52. Artificial Intelligence Lab P a g e | 45 BTCS605-18 Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 cout<<"n X is n1.Croaks n2.Eat Flies n3.shrimps n4.Sings "; cout<<"n Select One "; cin>>x; } OUTPUT
  • 53. Artificial Intelligence Lab P a g e | 46 BTCS605-18 Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 PRACTICAL – 7 WRITE A PROGRAM TO IMPLEMENT TOWER OF HANOI. #include<iostream> using namespace std; //tower of HANOI function implementation void TOH(int n,char Sour, char Aux,char Des) { if(n==1) { cout<<"Move Disk "<<n<<" from "<<Sour<<" to "<<Des<<endl; return; } TOH(n-1,Sour,Des,Aux); cout<<"Move Disk "<<n<<" from "<<Sour<<" to "<<Des<<endl; TOH(n-1,Aux,Sour,Des); } //main program int main() {
  • 54. Artificial Intelligence Lab P a g e | 47 BTCS605-18 Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 int n; cout<<"Enter no. of disks:"; cin>>n; //calling the TOH TOH(n,'A','B','C'); return 0; } OUTPUT
  • 55. Artificial Intelligence Lab P a g e | 48 BTCS605-18 Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 PRACTICAL – 8 WRITE A PROGRAM TO IMPLEMENT HEURISTIC SEARCH PROCEDURE. #include <iostream> using namespace std; int main() { stringa,b,c,d,e; intt,u,v,w,z,p,q,r; cout<< "Enter the root node"<<endl; cin>> a; cout<<" Enter the value of root node"<<endl; cin>>t; cout<< "Enter child 1"<<endl; cin>>b; cout<< "Enter value from root to child 1"<<endl; cin>>u; cout<< "Enter value from child1 to terminal"<<endl; cin>> p; cout<< "Enter child 2"<<endl; cin>>c; cout<< "Enter value of child 2"<<endl; cin>>v; cout<< "Enter value from child2 to terminal"<<endl; cin>> q; cout<< "Enter child 3"<<endl; cin>>d; cout<< "Enter value of child 3"<<endl; cin>>w; cout<< "Enter value from child3 to terminal"<<endl; cin>> r; cout<< "Enter terminal node"<<endl; cin>> e; if((u+p)<(v+q)&& (u+p)<(w+r)) { cout<< "Heuristic path is from a to b to e"<<endl; cout<< "Total value is"<<t+u+p; } else if((v+q)<(u+p)&&(v+p)<(w+r)) { cout<< "Heuristic path is from a to c to e"<<endl; cout<< "Total value is"<<t+v+p; } else if((w+r)<(u+p)&& (w+r)<(v+q)) {
  • 56. Artificial Intelligence Lab P a g e | 49 BTCS605-18 Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 cout<< "Heuristic path is from a to d to e"<<endl; cout<< "Total value is"<<t+w+r<<endl; } return 0; } OUTPUT
  • 57. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 Artificial Intelligence Lab P a g e | 50 BTCS605-18 PRACTICAL – 9 WRITE A PROGRAM TO IMPLEMENT PRODUCTION SYSTEM. #include<iostream.h> #include<conio.h> int main() { char answer; clrscr(); cout<<"Answer the following question to determine whether JOHN should get scholarship or not?"<<endl; cout<<"Q1) Is John a Student?(y/n)n"; cin>>answer; if(answer=='y') { cout<<"John enjoys Student Life"<<endl; cout<<"John Enjoys Student Life --> John Meets Friends"<<endl; cout<<"John Enjoys Meets Friends --> John Needs Money"<<endl; cout<<"Q2) Does John has a job?(y/n)"; cin>>answer; if(answer=='y') { cout<<"John Has Job --> John Has Free Time"<<endl; cout<<"Since John Works in Free Time--> John Is Not Not Good In Studies "<<endl; cout<<"John should not get the scholarship"; } } else cout<<"John Will not recieve scholarship as he is not a student"<<endl; return 0; }
  • 58. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 Artificial Intelligence Lab P a g e | 51 BTCS605-18 OUTPUT
  • 59. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 Artificial Intelligence Lab P a g e | 52 BTCS605-18 PRACTICAL – 10 WRITE A PROGRAM TO IMPLEMENT SEARCH PROBLEM OF 3*3 PUZZLE. #include <iostream> #include <iomanip> #include <array> using namespace std; void printarray(int num[3][3]) { for(int i = 0;i < 3; i++) { for(int j = 0; j< 3; j++) { cout << num[i][j] << " "; } cout << "n"; } } void swapValues(int (&array)[3][3], int i1,int j1,int i2,int j2) { int temp = array[i1][j1]; array[i1][j1] = array[i2][j2]; array[i2][j2] = temp;
  • 60. Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 Artificial Intelligence Lab P a g e | 53 BTCS605-18 } void moveleft(int (&array)[3][3], int i, int j) { if(i==1&&j==1) { swapValues(array, i, j, i-1, j); swapValues(array, i, j, i+1, j); } else if(i==1&&j==2) { swapValues(array, i, j, i, j-1); swapValues(array, i, j, i, j-2); } else if(i==0&&j==0) { swapValues(array, i, j+2, i, j); swapValues(array, i, j+1, i, j); } else if(i==0&&j==2) { swapValues(array, i, j, i, j); } else swapValues(array, i, j, i-1, j);
  • 61. Artificial Intelligence Lab P a g e | 54 BTCS605-18 Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 swapValues(array, i, j, i+1, j); } void movedown(int (&array)[3][3], int i, int j) { if(i==0&&j==0) } swapValues(array, i, j, i+1, j); swapValues(array, i, j, i+2, j); } else if(i==1&&j==1) { swapValues(array, i+1, j, i, j); swapValues(array, i-1, j, i, j); } else if(i==0&&j==2) { swapValues(array, i, j, i+1, j); } else swapValues(array, i, j, i-1, j); swapValues(array, i, j, i+1, j); } void moveright(int (&array)[3][3], int i, int j) {
  • 62. Artificial Intelligence Lab P a g e | 55 BTCS605-18 Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 if(i==0&&j==0) { swapValues(array, i, j+1, i, j); swapValues(array, i, j+2, i, j); } else if(i==1&&j==1) { swapValues(array, i, j+1, i, j); swapValues(array, i, j-1, i, j); } else if(i==1&&j==2) { swapValues(array, i, j-2, i, j); swapValues(array, i, j-1, i, j); } else swapValues(array, i, j, i-1, j); swapValues(array, i, j, i+1, j); } void moveup(int (&array)[3][3], int i, int j) { if(i==0&&j==0) { swapValues(array, i, j, i+2, j);
  • 63. Artificial Intelligence Lab P a g e | 56 BTCS605-18 Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 swapValues(array, i, j, i+1, j); } else if(i==1&&j==1) { swapValues(array, i, j, i-1, j); swapValues(array, i, j, i+1, j); } else if(i==0&&j==2) { swapValues(array, i, j, i+1, j); swapValues(array, i, j, i+2, j); swapValues(array, i, j, i+1, j); } else swapValues(array, i, j, i-1, j); swapValues(array, i, j, i+2, j); //int coord1d = j * 3 + i; } class Puzzle { public: Puzzle(); void swapValues(int num[3][3], int i1, int j1, int i2, int j2); //void moveleft(int[3][3], int start1, int start2); void moveup(int (&array)[3][3], int i, int j); void moveright(int (&array)[3][3], int i, int j);
  • 64. Artificial Intelligence Lab P a g e | 57 BTCS605-18 Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 void moveleft(int (&array)[3][3], int i, int j); void movedown(int (&array)[3][3], int i, int j); void printarray(int[3][3]); }; int main() { int state1[3][3] = {{2, 8, 3}, {1, 6, 4}, {7, 0, 5}}; int state2[3][3] = {{2, 8, 1}, {4, 6, 3}, {0, 7, 5}}; int gstate[3][3] = {{1, 2, 3}, {8, 0, 4}, {7, 6, 5}}; cout << "this is state 1" << endl; printarray(state1); cout << "nn"; cout << "now this is state 2" << endl; printarray(state2); cout << "nn"; cout << "now this is the goal state" << endl; printarray(gstate); int start1, start2; cout << endl << endl << "please enter your starting point in the states listed above going up or down" << endl; cin >> start1; cout << "now enter the point going left to right" << endl; cin >> start2; //moveleft(state1, start1, start2); cout << "this is moving coordinate (1, 1) upwards" << endl; moveup(state1, start1, start2);
  • 65. Artificial Intelligence Lab P a g e | 58 BTCS605-18 Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023 printarray(state1); cout << endl; cout << "this is moving coordinate (1, 1) to the left" << endl; moveleft(state1, start1, start2); printarray(state1); cout << endl; cout << "this is moving coordinate (1, 1) downwards" << endl; movedown(state1, start1, start2); printarray(state1); cout << endl; cout << "this is moving coordinate (1, 1) to the right" << endl; moveright(state1, start1, start2); printarray(state1); cout << endl; cin.get(); cin.get(); return 0; } OUTPUT
  • 66. Artificial Intelligence Lab P a g e | 59 BTCS605-18 Lyallpur Khalsa College Technical Campus Department of Computer Science & Engineering CAY: 2022-2023