AI - Lab - Manual - C-Scheme Jan 2025
AI - Lab - Manual - C-Scheme Jan 2025
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:
Note: Also describe task environment properties for wumpus world
problem
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
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
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,
AI Lab/ VI 6
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
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.
Program:
Output:
AI Lab/ VI 7
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
Experiment Number: 3
Aim:
Theory:
Characteristics of BFS:
AI Lab/ VI 8
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
However, it simply retains the set of attained states that permit an early
goal test, rather than saving all obtained states. As soon as the newly
created node is formed, this test verifies that it satisfies the objective
requirements.
3. Cost-optimal: When BFS creates nodes at a given depth d, it has
previously examined and created every node at the previous depth d-1.
It always seeks to find a solution with the lowest cost, giving priority
to the shortest path. As a result, BFS can find a solution as soon as it
reaches a certain depth level in a search area. BFS is therefore seen as
a cost-effective approach.
Performance Comparison:
Algorithm:
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:
Characteristics of DFS:
1. Since DFS cannot ensure that the shortest pathways will be found, it is
not cost-optimal.
2. DFS tracks visited nodes using a straightforward principle: it employs
a stack to record nodes visited thus far, which aids with graph
backtracking. The DFS adds a new node to the stack in order to
investigate its neighbors. It backtracks, for example, by popping nodes
off the stack to investigate alternate routes, if it encounters a node with
no successors (leaf node).
3. Backtracking search: Compared to the conventional depth-first search,
this DFS variation utilizes less memory. The backtracking search
allows the DFS to create only one successor at a time instead of all the
AI Lab/ VI 11
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
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.
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).
AI Lab/ VI 13
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
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.
4. Consider its children if any, and add them to queue in
ascending order of evaluation function f(n).
5. If queue is not empty then goto step 2.
6. If queue is empty then goto step 6
7. Print ‘success’ and stop
8. Print ‘failure’ and stop.
Performance Comparison:
Completeness: yes
Optimality: yes
Limitation:
It generate same node again and again
Large Memory is required
AI Lab/ VI 14
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]
[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
AI Lab/ VI 15
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
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
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
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
Program:
Output:
Conclusion: Thus, the program for Tic-Tac-Toe game has been executed
successfully
AI Lab/ VI 18
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.
* Note: Solve water jug problem
Algorithm:
AI Lab/ VI 19
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
AI Lab/ VI 20
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 21
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.
“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 23
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
AI Lab/ VI 24
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
All the four operations have certain preconditions which need to be satisfied to
perform the same. These preconditions are represented in the form of
predicates.
The effect of these operations is represented using two
lists ADD and DELETE. DELETE List contains the predicates which will
cease to be true once the operation is performed. ADD List on the other hand
contains the predicates which will become true once the operation is
performed.
The Precondition, Add and Delete List for each operation is rather intuitive
and have been listed below.
Table 8.1 Operations
Program:
Output:
Conclusion: Thus, the program for Block world problem has been executed
successfully.
AI Lab/ VI 26
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 27
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
AI Lab/ VI 28
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 29
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
Experiment Number: 10
Aim:
Properties of Forward-Chaining:
Example:
"As per the law, it is a crime for an American to sell weapons to hostile
nations. Country A, an enemy of America, has some missiles, and all the
missiles were sold to it by Robert, who is an American citizen."
AI Lab/ VI 30
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
To solve the above problem, first, we will convert all the above facts into first-
order definite clauses, and then we will use a forward-chaining algorithm to
reach the goal.
o Robert is American
American(Robert). ..........(8)
AI Lab/ VI 31
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
Proof:
Step-1:
In the first step we will start with the known facts and will choose the
sentences which do not have implications, such as: American(Robert),
Enemy(A, America), Owns(A, T1), and Missile(T1). All these facts will be
represented as below.
Step-2:
At the second step, we will see those facts which infer from available facts and
with satisfied premises.
Rule-(1) does not satisfy premises, so it will not be added in the first iteration.
Step-3:
AI Lab/ VI 32
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
Backward Chaining:
AI Lab/ VI 33
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
Example:
In backward-chaining, we will use the same above example, and will rewrite
all the rules.
o Missile(T1)
o American(Robert). ..........(8)
Proofs:
Step-1:
AI Lab/ VI 34
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
At the first step, we will take the goal fact. And from the goal fact, we will
infer other facts, and at last, we will prove those facts true. So our goal fact is
"Robert is Criminal," so following is the predicate of it.
Step-2:
At the second step, we will infer other facts form goal fact which satisfies the
rules. So as we can see in Rule-1, the goal predicate Criminal (Robert) is
present with substitution {Robert/P}. So we will add all the conjunctive facts
below the first level and will replace p with Robert.
Step-3:t At step-3, we will extract further fact Missile(q) which infer from
Weapon(q), as it satisfies Rule-(5). Weapon (q) is also true with the
substitution of a constant T1 at q.
AI Lab/ VI 35
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
Step-4:
At step-4, we can infer facts Missile(T1) and Owns(A, T1) form Sells(Robert,
T1, r) which satisfies the Rule- 4, with the substitution of A in place of r. So
these two statements are proved here.
AI Lab/ VI 36
Shivajirao S Jondhale College of Engineering, Dombivli (E)
Department of Computer Engineering
Step-5:
At step-5, we can infer the fact Enemy(A, America) from Hostile(A) which
satisfies Rule- 6. And hence all the statements are proved true using backward
chaining.
Conclusion: Thus, the program for Forward Chaining and Backward Chaining
has been executed successfully.
AI Lab/ VI 37