AI - C-Scheme - Lab Manual
AI - C-Scheme - Lab Manual
Semester – VI
Prepared by
Prof. Poonam Narkhede
Prof. Pallavi Bharambe
VISION
To impart quality technical education for creating competent and ethically strong
professionals with capabilities of accepting new challenges.
MISSION
Our efforts are dedicated to impart quality technical education based on a balanced
program of instructions and practical experiences.
Our strength is to provide value based technical education to develop core competencies
and ethics for overall personality development.
Our endeavor is to impart in depth knowledge and versatility to meet the global
challenges.
Shivajirao S Jondhale College of Engineering, Dombivli (E)
VISION
To impart quality technical education in the department of Computer Engineering for
creating competent and ethically strong engineers with capabilities of accepting new
challenges.
MISSION
Our efforts are dedicated to impart quality technical education to prepare engineering
graduates who excel in programming skills.
Our strength is to serve society by producing globally competent professionals.
Our endeavor is to provide all possible support to build strong teaching environment to
provide quality education in Computer Engineering.
Ability to use software methodology and various software tools for developing system
programs, high quality web apps and solutions to complex real world problems.
Ability to identify and use suitable data structure and analyze the various algorithm for
given problem from different domains
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
Course Objectives:
1. To conceptualize the basic ideas and techniques underlying the design of intelligent
systems.
2. To make students understand and Explore the mechanism of mind that enables
intelligentthought and action.
3. To make students understand advanced representation formalism and search techniques.
4. To make students understand how to deal with uncertain and incomplete information.
Course Outcomes:
Learner will be able to…
Semester – VI
List of experiment
Experiments to CO Mapping
Experiment Number: 1
Aim:
Theory:
Students can find the research papers based on the artificial neural network,
hybrid systems, genetic algorithm, fuzzy system, fuzzy logic, fuzzy inference
system etc. Students should write technology used, algorithm and survey.
Students need to search recent papers on any of the above mentioned topics,
study it and prepare report on the same
Conclusion:
Thus, we have understood the recent advancements and applications of
various sub-domains of Artificial Intelligence
AI Lab/ VI 1
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
Experiment Number: 2
Aim:
Theory:
The Wumpus world is a cave which has 4/4 rooms connected with
passageways. So there are total 16 rooms which are connected with each other.
We have a knowledge-based agent who will go forward in this world. The
cave has a room with a beast which is called Wumpus, who eats anyone who
enters the room. The Wumpus can be shot by the agent, but the agent has a
single arrow. In the Wumpus world, there are some Pits rooms which are
bottomless, and if agent falls in Pits, then he will be stuck there forever. The
exciting thing with this cave is that in one room there is a possibility of finding
a heap of gold. So the agent goal is to find the gold and climb out the cave
without fallen into Pits or eaten by Wumpus. The agent will get a reward if he
comes out with gold, and he will get a penalty if eaten by Wumpus or falls in
the pit.
AI Lab/ VI 2
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
Procedure:
Performance measure:
o +1000 reward points if the agent comes out of the cave with the gold.
o -1000 points penalty for being eaten by the Wumpus or falling into the
pit.
o -1 for each action, and -10 for using an arrow.
o The game ends if either agent dies or came out of the cave.
Environment:
AI Lab/ VI 3
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
o Each square of the cave can be a pit with probability 0.2 except the
first square.
Actuators:
o Left turn,
o Right turn
o Move forward
o Grab
o Release
o Shoot.
Sensors:
o The agent will perceive the stench if he is in the room adjacent to the
Wumpus. (Not diagonally).
o The agent will perceive breeze if he is in the room directly adjacent to
the Pit.
o The agent will perceive the glitter in the room where the gold is
present.
o The agent will perceive the bump if he walks into a wall.
o When the Wumpus is shot, it emits a horrible scream which can be
perceived anywhere in the cave.
o These percepts can be represented as five element list, in which we
will have different indicators for each sensor.
o Example if agent perceives stench, breeze, but no glitter, no bump, and
no scream then it can be represented as:
[Stench, Breeze, None, None, None].
AI Lab/ VI 4
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
Now we will explore the Wumpus world and will determine how the agent
will find its goal by applying logical reasoning.
Initially, the agent is in the first room or on the square [1,1], and we already
know that this room is safe for the agent, so to represent on the below diagram
(a) that room is safe we will add symbol OK. Symbol A is used to represent
agent, symbol B for the breeze, G for Glitter or gold, V for the visited room, P
for pits, W for Wumpus.
At Room [1,1] agent does not feel any breeze or any Stench which means the
adjacent squares are also OK.
AI Lab/ VI 5
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
Now agent needs to move forward, so it will either move to [1, 2], or [2,1].
Let's suppose agent moves to the room [2, 1], at this room agent perceives
some breeze which means Pit is around this room. The pit can be in [3, 1], or
[2,2], so we will add symbol P? to say that, is this Pit room?
Now agent will stop and think and will not make any harmful move. The agent
will go back to the [1, 1] room. The room [1,1], and [2,1] are visited by the
agent, so we will use symbol V to represent the visited squares.
At the third step, now agent will move to the room [1,2] which is OK. In the
room [1,2] agent perceives a stench which means there must be a Wumpus
AI Lab/ VI 6
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
nearby. But Wumpus cannot be in the room [1,1] as by rules of the game, and
also not in [2,2] (Agent had not detected any stench when he was at [2,1]).
Therefore agent infers that Wumpus is in the room [1,3], and in current state,
there is no breeze which means in [2,2] there is no Pit and no Wumpus. So it is
safe, and we will mark it OK, and the agent moves further in [2,2].
At room [2,2], here no stench and no breezes present so let's suppose agent
decides to move to [2,3]. At room [2,3] agent perceives glitter, so it should
grab the gold and climb out of the cave.
AI Lab/ VI 7
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
Program:
Output:
AI Lab/ VI 8
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
Experiment Number: 3
Aim:
Theory:
Performance Comparison:
Algorithm:
AI Lab/ VI 9
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
4. If queue is not empty then goto Step 2, If queue is empty then goto
Step 6
Program:
Output:
Conclusion: Thus, the program of Breadth first search has been executed
successfully.
.
AI Lab/ VI 10
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
Experiment Number: 4
Aim:
Theory:
The DFS algorithm is a recursive algorithm that uses the idea of backtracking.
It involves exhaustive searches of all the nodes by going ahead, if possible,
else by backtracking. Here, the word backtrack means that when you are
moving forward and there are no more nodes along the current path, you move
backwards on the same path to find nodes to traverse. All the nodes will be
visited on the current path till all the unvisited nodes have been traversed after
which the next path will be selected.
Performance Analysis: Depth-first search visits every vertex once and checks
every edge in the graph once. Therefore, DFS complexity is O(V + E)O(V+E).
This assumes that the graph is represented as an adjacency list.
Algorithm:
Loop.
AI Lab/ VI 11
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
Program:
Output:
Conclusion: Thus, the program of Depth first search has been executed
successfully.
AI Lab/ VI 12
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
Experiment Number: 5
Aim:
Theory:
A* Search technique
It is informed search technique. It uses additional information beyond
problem formulation and tree. Search is based on Evaluation function
f(n).Evaluation function is based on both heuristic function h(n) and g(n).
f(n)=g(n) + h(n)
It uses two queues for its implementation: open, close Queue. Open queue is
a priority queue which is arranged in ascending order of f(n).
Algorithm:
1. Create a single member queue comprising of Root node
2. If FIRST member of queue is goal then goto step 5
3. If first member of queue is not goal then remove it from
queue and add to close queue.
AI Lab/ VI 13
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
Fig.5.1. Example of A*
OPEN/FRINGE CLOSE
[A] [ ]
[C,B] [A]
[D,B,E,A] [A,C]
AI Lab/ VI 14
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
[F,E,B,C,A] [A,C,D]
[G,E,B,C,A,D] [A,C,D,F]
SUCCESS
Node A:
f(B)=g(B) + h(B)=3+5=8
f(C) =g(C) + h(C)=1 + 6=7
Node C:
f(A) = g(A) + h(A)=2+7=10
f(D) = g(D) + h(D)=3+4=7
f(E) = g(E) + h(E)=7+1=8
Node D:
f(F) = g(F) + h(F)=6+1=7
f(C) = g(C) + h(C)= 5+6=11
f(B) = g(B) + h(B)=4+5=9
Node F:
f(E) = g(E) + h(E)=7+1=8
f(D) = g(D) + h(D)= 9+4=13
f(G) = g(G) + h(G)=7+0=7
AI Lab/ VI 15
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
Program:
Output:
AI Lab/ VI 16
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
Experiment Number: 6
Aim:
Theory:
The min-max algorithm computes the min-max decision from the
current state. It uses a simple recursive computation of the min-max values of
each successor state, directly implementing the defining equations. The
recursion process all the way down to the leaves of the tree, and then the min-
max values are backed up through the tree as the recursion unwinds.
The min-max algorithm performs a complete depth-first exploration of the
game tree. If the maximum depth of the tree is m, and there are b legal moves
at each point, then the time complexity of the min-max algorithm is O(bm).
The space complexity is O(bm) for an algorithm that generates all successors
at once, or O(m) for an algorithm that generates successors one at a time. For
real games, of course, the time cost is totally impractical, but this algorithm
serves as the basis for the mathematical analysis of games and for more
practical algorithms.
Algorithm:
function MINIMAX-DECISION(state)returns an action
inputs: state, current state in game
v MAX-VALUE(state)
return the action in SUCCESSORS(state) v
AI Lab/ VI 17
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
v -infinity
for a, s in SUCCESSORS(state)do
v MAX(V, MIN-VALUE(S))
return v
function MIN-VALUE
if TERMINAL-TEST(state) then return UTILITY(state)
V infinity
for a , s in SUCCESSORS(state)do
v MIN(V, MAX-VALUE(S))
return v
Fig.6.1. Tic-Tac-Toe
AI Lab/ VI 18
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
Program:
Output:
Conclusion: Thus, the program for Tic-Tac-Toe game has been executed
successfully
AI Lab/ VI 19
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
Experiment Number: 7
Aim:
Theory:
This is the jug problem using simple depth-first search of a graph. The
modified water-jug problem is as follows: Jug A holds 4 liters, and jug B
holds 3 liters. There is a pump, which can be used to fill either Jug. How
can you get exactly 2 liters of water into the 4-liter jug?
Assumptions:
We can fill a jug from the pump
We can pour water out of the jug onto the ground
We can pour water from one jug to another
There are no other measuring devices available
To solve the water jug problem, apart from problem statement we also need a
control structure that loops through a simple cycle in which some rule whose
left side matches the current state is chosen, the appropriate change to state is
made as described in corresponding right side and the resulting state is
checked to see if it corresponds to a goal state. As long as it does not the cycle
continues.
Algorithm:
AI Lab/ VI 20
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
AI Lab/ VI 21
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
Program:
Output:
Conclusion: Thus, the program of water jug problem has been executed
successfully.
AI Lab/ VI 22
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
Experiment Number: 8
Aim:
Theory:
This is how the problem goes — There is a table on which some blocks are
placed. Some blocks may or may not be stacked on other blocks. We have a
robot arm to pick up or put down the blocks. The robot arm can move only
one block at a time, and no other block should be stacked on top of the block
which is to be moved by the robot arm.
Our aim is to change the configuration of the blocks from the Initial State to
the Goal State, both of which have been specified in the diagram above.
AI Lab/ VI 23
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
We start at the goal state and we try fulfilling the preconditions required to
achieve the initial state. These preconditions in turn have their own set of
preconditions, which are required to be satisfied first. We keep solving these
“goals” and “sub-goals” until we finally arrive at the Initial State. We make
use of a stack to hold these goals that need to be fulfilled as well the
actions that we need to perform for the same.
Apart from the “Initial State” and the “Goal State”, we maintain a “World
State” configuration as well. Goal Stack uses this world state to work its way
from Goal State to Initial State. World State on the other hand starts off as the
Initial State and ends up being transformed into the Goal state.
At the end of this algorithm we are left with an empty stack and a set of
actions which helps us navigate from the Initial State to the World State.
AI Lab/ VI 24
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
AI Lab/ VI 25
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
AI Lab/ VI 26
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
Once the operation is performed, these predicates will cease to be true, thus
they are included in DELETE List as well. (Note : It is not necessary for the
Precondition and DELETE List to be the exact same).
On the other hand, once the operation is performed, The robot arm will be free
(ARMEMPTY) and the block X will be on top of Y (ON(X,Y)).
Program:
Output:
Conclusion: Thus, the program for Block world problem has been executed
successfully.
AI Lab/ VI 27
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
Experiment Number: 9
Aim:
Theory:
Bayesian belief network is key computer technology for dealing with
probabilistic events and to solve a problem which has uncertainty. We can
define a Bayesian network as:
"A Bayesian network is a probabilistic graphical model which represents a set
of variables and their conditional dependencies using a directed acyclic
graph."
It is also called a Bayes network, belief network, decision network,
or Bayesian model. Bayesian networks are probabilistic, because these
networks are built from a probability distribution, and also use probability
theory for prediction and anomaly detection.
Real world applications are probabilistic in nature, and to represent the
relationship between multiple events, we need a Bayesian network. It can also
be used in various tasks including prediction, anomaly detection, diagnostics,
automated insight, reasoning, time series prediction, and decision making
under uncertainty.
Bayesian Network can be used for building models from data and
experts opinions, and it consists of two parts: Directed Acyclic Graph and
Table of conditional probabilities.
The generalized form of Bayesian network that represents and solve
decision problems under uncertain knowledge is known as an Influence
diagram.
AI Lab/ VI 28
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
AI Lab/ VI 29
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
P[x1, x2, x3,....., xn], it can be written as the following way in terms of the joint
probability distribution.
P[x1| x2, x3,....., xn]P[x2, x3,....., xn]
P[x1| x2, x3,....., xn]P[x2|x3,....., xn]....P[xn-1|xn]P[xn].
In general for each variable Xi, we can write the equation as:
P(Xi|Xi-1,........., X1) = P(Xi |Parents(Xi ))
AI Lab/ VI 30