0% found this document useful (0 votes)
41 views226 pages

Unit 1

Unit 1 provides an introduction to intelligent agents and rational agents. It defines key concepts like agents, environments, percepts, and rationality. An agent is anything that can perceive its environment and take actions. A rational agent is one that takes the action expected to maximize its performance given its knowledge and sensors/actuators. Rationality depends on the performance measure and the agent's PEAS - its environment, possible actions, and sensors.

Uploaded by

nadritzy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views226 pages

Unit 1

Unit 1 provides an introduction to intelligent agents and rational agents. It defines key concepts like agents, environments, percepts, and rationality. An agent is anything that can perceive its environment and take actions. A rational agent is one that takes the action expected to maximize its performance given its knowledge and sensors/actuators. Rationality depends on the performance measure and the agent's PEAS - its environment, possible actions, and sensors.

Uploaded by

nadritzy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 226

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

A rational agent is one that does the right thing.

1. Performance Measure
2. Agent’s Prior Knowledge (Environment)
3. Actions that agent can perform (Actuators)
4. Agents percept sequence (Sensors)

If an agent follows the above 4 points then it is called as rational agent


1. Performance Measure

Performance measures of rational agent is the criteria, which determines how


successful agent is.

Performance measure of an agent includes the following factors.

1. Agent has to take initiative to perceive information from the environment


2. Agent has to generate a sequence of actions according to the percepts it
receives
3. This sequence of actions causes the environment to go through a sequence
of states
4. If the sequence is desirable then the agent has performed well.
Rational Agent
For each possible percept sequence , a rational agent should select an
action that is expected to maximize its performance measure, given percept
sequence and prior-knowledge.
The nature of environment

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

Specifying the task environment

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.

A problem can be defined by five components:


• initial state, actions, transition model, goal test, path cost.
Problem-solving agents
● A problem-solving agent is a goal-based agent and use atomic
representations.
● In atomic representations, states of the world are considered as wholes, with
no internal structure visible to the problem solving algorithms.

A problem-solving agent has three phases:


• Problem formulation, Searching solution and Executing actions in the solution.
Search Algorithm
Search Algorithms in Artificial Intelligence
● Search forms the core component of many intelligent processes
● Search is a systematic approach to find path from the start / root state to the
goal state
● Many traditional search algorithms are used in AI Applications.
● For complex problems, the traditional algorithms are unable to find the
solution within some practical time and space limit.
● Consequently,many special techniques are developed using heuristic
functions.
Requirements of Search Algorithms in Artificial
Intelligence

1. The first requirement is that it should cause motion


2. The second requirement is that it should be systematic
Types of Search Algorithms
Based on the search problems we can classify the search algorithm into two :

1. Uninformed Search (Blind Search)


2. Informed Search (Heuristic Search)
Uninformed Search - Blind Search
● Which is also called as Blind Search/ brute force search
● It uses no information about the problem to guide search and therefore may
not be very efficient.

Uninformed Search
Breadth-first search

● 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.

The use of stack is for keeping track of all visited nodes

DFS are used for detecting cycles in graph, path finding, topological sorting and
to test if a graph is bipartite.
Informed Search

● Best First Search


● A* search
● AO* search
Best First Search
Examine C first
C is pushed into the Open DS.
Place the nodes marked in green to open according to ascending order.
● Successors of C is pushed into the open list based on ascending order - >
T,O,E,B,P and then T is examined
● T is gone into the open list and there is no successors
● Next let's examine O
O is examined and its successors I and N will be pushed into the open
list based on the ascending order
Examine Z and it is the Goal node.
Example 2
Path is : S->B->H->G->E
A* Search Algorithm

● A* Algorithm The Best First algorithm is a simplified form of the A* algorithm.


● The A* search algorithm (pronounced "Ay-star") is a tree search algorithm that
finds a path from a given initial node to a given goal node (or one passing a
given goal test).
● It employs a "heuristic estimate" which ranks each node by an estimate of the
best route that goes through that node.
● It visits the nodes in order of this heuristic estimate.
● Similar to greedy best-first search but is more accurate because A* takes into
account the nodes that have already been traversed.
A* Search Algorithm

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

NODE G(N) H(N) F(N) NODE PARENT

S 0 10 10
OPEN CLOSED

NODE G(N) H(N) F(N) NODE PARENT

A 7 9 16 S

B 2 7 9

C 3 8 11

S IS NOT THE GOAL NODE


SO ADD THE SUCCESSORS INTO THE OPEN LIST
SORT

OPEN CLOSED

NODE G(N) H(N) F(N) NODE PARENT

B 2 7 9 S

C 3 8 11

A 7 9 16

OPEN CLOSED

NODE G(N) H(N) F(N) NODE PARENT

C 3 8 11 B S

A 7 9 16
SORT

OPEN CLOSED

NODE G(N) H(N) F(N) NODE PARENT

C 3 8 11 S

A 7 9 16

D 6 8 14

H 3 6 9
OPEN CLOSED

NODE G(N) H(N) F(N) NODE PARENT

H 3 6 9 S

C 3 8 11 B S

D 6 8 14

A 7 9 16
OPEN CLOSED

NODE G(N) H(N) F(N) NODE PARENT

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

NODE G(N) H(N) F(N) NODE PARENT

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

NODE G(N) H(N) F(N) NODE PARENT

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

NODE G(N) H(N) F(N) NODE PARENT

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

NODE G(N) H(N) F(N) NODE PARENT

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

NODE G(N) H(N) F(N) NODE PARENT

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

NODE G(N) H(N) F(N) NODE PARENT

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

Pip install numpy

Reading an Image
cv2.imread(path,flag)

Display an Image
cv2.imread(path,flag)

You might also like