Unit 1
Unit 1
Introduction to Al
Intelligent Agents: Agents and Environment
Agent :An Agent is anything that can be viewed as perceiving environments through
sensors and acting upon that environment through actuators.
Percept: agents perceptual inputs at any given instant.
Percept Sequence : History of everything agent has ever perceived
Agent functions: - Maps given percept sequence to an action /implementation
E
Speed Sensors, Obj Detector
N Eg: Self Driving Car
V
AI Agent Sensors
I Traffic, Lanes
R
Agent O
Function ? N
M
E
Actuator
Break, Accelerator N
T
CONCEPT OF RATIONALITY IN AN AGENT
Rationality
Rationality depends on :- PEAS -> Task Environment
1. Performance Measure
2. Agent’s Prior Knowledge (Environment)
3. Actions that agent can perform (Actuators)
4. Agents percept sequence (Sensors)
Now that we have a definition of rationality, we are almost ready to think about
building rational agents. First, however , we must think about task environments,
which are essentially the “Problems” to which rational agents are the solutions
In our discussion of the rationality of the simple vacuum cleaner agent, we had to
specify the performance measure, the environment, and the agents actuators and
sensors. We will group all these together under the heading of the task
environment. We call this the PAES (Performance, Environment,
Actuators,Sensors)
The Structure of Agents
Problem formulation
● Problem formulation is the process of deciding what actions and states to consider,
given a goal.
● The process of looking for a sequence of actions that reaches the goal is called search.
● A search algorithm takes a problem as input and returns a solution in the form of an
action sequence.
● Once a solution is found, the carrying actions it recommends is called the execution
phase.
● Breadth-first search is a graph traversal algorithm that starts traversing the graph from
the root node and explores all the neighboring nodes. Then, it selects the nearest node
and explores all the unexplored nodes. While using BFS for traversal, any node in the
graph can be considered as the root node.
State space
Formulate production Rules
Breadth First Search
Depth First Search
Depth first search can be implemented using last in first out (LIFO) stack data
structure.
DFS are used for detecting cycles in graph, path finding, topological sorting and
to test if a graph is bipartite.
Informed Search
A* (pronounced ‘A-star’) is a search algorithm that finds the shortest path between
some nodes S and T in a graph.
Example 1
Example 1
Example 1
Example 1
Example 1
Example 1
https://www.youtube.com/watch?v=
https://www.youtube.com/watch?v=h3Zi5NxjVXA&t=15s KJSWqvwTVpw&t=21s
Example 2
Initial state S
Goal Node E
OPEN CLOSED
S 0 10 10
OPEN CLOSED
A 7 9 16 S
B 2 7 9
C 3 8 11
OPEN CLOSED
B 2 7 9 S
C 3 8 11
A 7 9 16
OPEN CLOSED
C 3 8 11 B S
A 7 9 16
SORT
OPEN CLOSED
C 3 8 11 S
A 7 9 16
D 6 8 14
H 3 6 9
OPEN CLOSED
H 3 6 9 S
C 3 8 11 B S
D 6 8 14
A 7 9 16
OPEN CLOSED
C 3 8 11 S
D 6 8 14 B S
A 7 9 16 H B
F 6 6 12
G 5 3 8
SORT
OPEN CLOSED
G 5 3 8 S
C 3 8 11 B S
F 6 6 12 H B
D 6 8 14 G H
A 7 9 16
OPEN CLOSED
G 5 3 8 S
C 3 8 11 B S
F 6 6 12 H B
D 6 8 14
A 7 9 16
E 7 0 7
OPEN CLOSED
C 3 8 11 B S
F 6 6 12 H B
D 6 8 14 G H
A 7 9 16
E 7 0 7
SORT
OPEN CLOSED
E 7 0 7 S
C 3 8 11 B S
F 6 6 12 H B
D 6 8 14 G H
A 7 9 16
SORT
OPEN CLOSED
C 3 8 11 B S
F 6 6 12 H B
D 6 8 14 G H
A 7 9 16 E G
SORT
OPEN CLOSED
C 3 8 11 S
F 6 6 12 B S
D 6 8 14 H B
A 7 9 16 G H
E G
E
GOAL NODE
AO* SEARCH ALGORITHM
Optimal path cost is 12
Example 2
Minimum path is
A->B->D->I
PAYOFF
PAYOFF Matrix
Example: Odds and Evens
Consider the simple game called odds and evens. Suppose
that player 1 takes evens and player 2 takes odds. Then,
each player simultaneously shows either one finger or two
fingers. If the number of fingers matches, then the result is
even, and player 1 wins the bet ($2). If the number of fingers
does not match, then the result is odd, and player 2 wins the
bet ($2). Each player has two possible strategies: show one
finger or show two fingers. The payoff matrix shown below
represents the payoff to player 1.
Value of the Game
Saddle value is 2
B1 B2
SADDLE POINT A1 3 2
A2 4 1
https://www.youtube.com/watch?v=
7HebJs0u8XM
Downloading and installing Open CV
pip install opencv-python
Reading an Image
cv2.imread(path,flag)
Display an Image
cv2.imread(path,flag)