Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 35

Introduction to Artificial

Intelligence

Lecture 02
Amna Iftikhar Fall' 2021 1
Today’s Agenda
• Rational Agents
• Types of Agents
• Problem solving as search
• Puzzle Solving

Amna Iftikhar Fall' 2021 2


What’s an Agent?
•  An (intelligent) agent perceives it environment via sensors and acts
rationally upon that environment with its actuators. Hence, an agent
gets percepts one at a time, and maps this percept sequence to actions.
• Possible properties of agents:
– Agents are autonomous – they act on behalf of the user
– Agents can adapt to changes in the environment
– Agents don't only act reactively, but sometimes also proactively
– Agents have social ability – they communicate with the user, the system, and
other agents as required
– Agents also cooperate with other agents to carry out more complex tasks than
they themselves can handle
– Agents migrate from one system to another to access remote resources or
even to meet other agents

Amna Iftikhar Fall' 2021 3


Rational Agent
• Rational = “Does the right thing” in a
particular situation
• In other words
– “For each possible percept sequence, an ideal
rational agent should do whatever action is
expected to maximize its performance measure,
on the basis of the evidence provided by the
percept sequence and whatever built-in
knowledge the agent has.”

Amna Iftikhar Fall' 2021 4


The Right Thing = The Rational Action
• Rational Action: The action that maximizes the expected
value of the performance measure given the percept
sequence to date

– Rational = Best ?
– Rational = Optimal ?
– Rational = Omniscience ?
– Rational = Clairvoyant ?
– Rational = Successful ?

Amna Iftikhar Fall' 2021 5


The Right Thing = The Rational Action
• Rational Action: The action that maximizes the expected
value of the performance measure given the percept
sequence to date

– Rational = Best Yes, to the best of its knowledge


– Rational = Optimal Yes, to the best of its abilities (incl.
– Rational  Omniscience its constraints)
– Rational  Clairvoyant
– Rational  Successful

Amna Iftikhar Fall' 2021 6


Rational Agent
• So a rational agent does the “right” thing (at
least tries to)
– Maximizes the likelihood of success, given its
information
– How is “the right thing” chosen?
• Possible actions (from which to choose)
• Percept sequence (current and past)
• Knowledge (static or modifiable)
• Performance measure (wrt goals – defines success)

Amna Iftikhar Fall' 2021 7


Amna Iftikhar Fall' 2021 8
The Vacuum World

Performance measure, Environment, Actuators, Sensors

Amna Iftikhar Fall' 2021 9


The Vacuum World
• Performance (P)
– Keep world clean
– Possible performance measures
• Environment (E)
– Location
– Cleanliness
• Three actions (A)
– Move right
– Move left
– Remove dirt
• Sensed information (percepts) of environment (S)
– Two locations
• Left
• Right
– Two states
• Dirty
• Clean

Amna Iftikhar Fall' 2021 10


PEAS Descriptions

Amna Iftikhar Fall' 2021 11


Basic Types Of Agent Programs
• Simple reflex agent
• Model-based reflex agent
• Goal-based agent
• Utility-based agent
• Learning agent

Amna Iftikhar Fall' 2021 12


Simple Reflex Agents

• The simplest kind of agent is the simple reflex agent.


• This type of agents are admirably simple but they have
very limited intelligence.
• Their actions are based on the current percept.
• They only looks at the current state and decides what to
do. Neither they hold nor consider any part of the history
during their decision process.
Amna Iftikhar Fall' 2021 13
Simple Reflex Agent

• Condition-action rule: “If-then” rule (production rule)


– If condition then action (if in a certain state, do this)

Amna Iftikhar Fall' 2021 14


Model-based Reflex Agents
• This type of agents is little bit more complicated than the reflex based
agents.
• A model based agent holds an internal state based on the percept
history.
• This internal state helps agent to handle a partially observable
environment.
• It consider both internal state and current percept to take an action. 
• Also, each step it updates the internal state.

Amna Iftikhar Fall' 2021 15


Model-Based Agent

• Internal state – keeps track of the world, models the world

Amna Iftikhar Fall' 2021 16


Goal-based Agents
• For some tasks, its not always enough to know
how the world works.
• In some cases, its desirable to define
a goal information to describe desirable
situations.
• A goal-based agent combines model-based
agent’s model with a goal. To reach its goal. it
often uses Search and Planning algorithms.

Amna Iftikhar Fall' 2021 17


Goal Based Agent

• Search and planning – finding action sequences that achieve the agent’s goals

Amna Iftikhar Fall' 2021 18


Utility-based Agents
• When there are multiple possible alternatives, then to decide which one is
best, utility based agents are used.
• Sometimes achieving the desired goal is not enough.
– We may look for quicker, safer, cheaper trip to reach a destination.
– Agent happiness should be taken into consideration.

• Utility describes how “happy” the agent is. Because of the uncertainty in the


world, a utility agent chooses the action that maximizes the expected utility.
• A utility function maps a state onto a real number which describes the
associated degree of happiness.

Amna Iftikhar Fall' 2021 19


Utility Based Agent

• Utility function: Specifies degree of usefulness (happiness)


– Maps a state onto a real number
• Conflicting goals; ordering of goals

Amna Iftikhar Fall' 2021 20


Agents
• The simple reflex agents base their actions on
a direct mapping from states to actions.
– Such agents cannot operate well in environments
for which this mapping would be too large to store
and would take too long to learn.
• Goal-based agents, on the other hand,
consider future actions and the desirability of
their outcomes.

Amna Iftikhar Fall' 2021 21


Problem Solving as Search
• problem-solving agent is a kind of goal-based
agent
• Search is the process of looking for a sequence of
actions that reaches the goal.
• 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 actions it
recommends can be carried out.
Amna Iftikhar Fall' 2021 22
Let’s Play some game
• Missionaries and Cannibals
– Three missionaries and three cannibals are on one side of a river,
with a canoe.
– They all want to get to the other side of the river.
– The canoe can only hold one or two people at a time.
– At no time should there be more cannibals than missionaries on
either side of the river, as this would probably result in the
missionaries being eaten

Amna Iftikhar Fall' 2021 23


Missionaries and Cannibals

• The following operators are available:

– 1.Move one cannibal to the other side

– 2.Move two cannibals to the other side

– 3.Move one missionary to the other side

– 4.Move two missionaries to the other side

– 5.Move one cannibal and one missionary to the other side

Amna Iftikhar Fall' 2021 24


Missionaries and Cannibals(contd)
• https://www.learn4good.com/games/puzzle/b
oat.htm

Amna Iftikhar Fall' 2021 25


Missionaries and Cannibals(contd)

Amna Iftikhar Fall' 2021 26


Missionaries and Cannibals(contd)
• Let a state (mcb)be given by the ‘m’ numbers
of missionaries, ‘c’ cannibals and ‘b’ boats on
the initial bank of the river. The initial situation
is represented by (331) and the goal situation
by(000).
• Most AI texts that mention the problem
accept this formulation and give us the
solution:
331→310→321→300→311→110→221→ 020→031→010→021→ 000

Amna Iftikhar Fall' 2021 27


Problem Solving as Search
• Problem solving is an important aspect of Artificial
Intelligence.
• A problem can be considered to consist of a goal and a
set of actions that can be taken to lead to the goal.
• Search can be defined as a problem solving technique
that enumerates a problem space from an initial
position in search of a goal position (or solution).
• At any given time, we consider the state of the search
space to represent where we have reached as a result
of the actions we have applied so far.
Amna Iftikhar Fall' 2021 28
Problem Solving as Search
• State Space
– Set of all states reachable from the initial state by any
sequence of actions
– Initial state, actions, and transition model implicitly define
the state space of the problem
• Solution to the problem is a sequence of actions that
lead from the initial state to a goal state
• Quality of Solution – measured by cost function
• Optimal solution has the lowest path cost among all
solutions
Amna Iftikhar Fall' 2021 29
Graph-Recap
• Graph
– Nodes
– Edges
– Directed vs Undirected
– Weighted graph
• Tree-Connected graph with no cycles

Amna Iftikhar Fall' 2021 30


The Towers of Hanoi
• We have three pegs and a number of disks of
different sizes.
• The aim is to move from the starting state where
all the disks are on the first peg, in size order
(smallest at the top) to the goal state where all
the pegs are on the third peg, also in size order.
• We are allowed to move one disk at a time, as
long as there are no disks on top of it, and as
long as we do not move it on top of a peg that is
smaller than it.
Amna Iftikhar Fall' 2021 31
The Towers of Hanoi
(From Wikipedia)
• The puzzle was invented by the French mathematician Édouard
Lucas in 1883. There is a legend about an Indian temple which
contains a large room with three time-worn posts in it surrounded
by 64 golden disks.
– The priests of Brahma, acting out the command of an ancient prophecy, have
been moving these disks, in accordance with the rules of the puzzle.
– According to the legend, when the last move of the puzzle is completed, the
world will end. The puzzle is therefore also known as the Tower of Brahma
puzzle.
• If the legend were true, and if the priests were able to move disks at
a rate of one per second, using the smallest number of moves, it
would take them 2^64−1 seconds or roughly 584.542 billion years
– 2^64/60/60/24/365.25/1000000000
– In context, the universe is currently about 13.7 billion years old.

Amna Iftikhar Fall' 2021 32


General State Space Search

• http://www.coolmath-games.com/0-tower-of-hanoi
Amna Iftikhar Fall' 2021 33
The Towers of Hanoi (Partial Search Tree)

Amna Iftikhar Fall' 2021 34


General State Space Search
Maze Traversing

Amna Iftikhar Fall' 2021 35

You might also like