0% found this document useful (0 votes)
186 views147 pages

Bcs515b - PPT - Dr. SBL

Uploaded by

gagannag306
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)
186 views147 pages

Bcs515b - PPT - Dr. SBL

Uploaded by

gagannag306
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/ 147

ATME COLLEGE OF ENGINEERING

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

Module -1

Subject: ARTIFICIAL INTELLIGENCE


Subject Code: BCS515B
Prepared By:
Dr. Shilpa B L
Associate Professor
Dept. of CSE, ATMECE
INTRODUCTION

• We call ourselves Homo sapiens—man the wise—because our intelligence is so


important to us. For thousands of years, we have tried to understand how we think;
that is, how a mere handful of matter can perceive, understand, predict, and
manipulate a world far larger and more complicated than itself.
• The field of artificial intelligence, or AI, goes further still: it attempts not just to
understand but also to build intelligent entities.
INTRODUCTION => WHAT IS AI?
• In Figure 1.1 we see eight definitions
of AI, laid out along two dimensions.
• The definitions on top are concerned
with THOUGHT PROCESSES and
REASONING, whereas the ones on
the bottom address BEHAVIOR.
• The definitions on the left measure
success in terms of fidelity to
HUMAN performance, whereas the
ones on the right measure against an
ideal performance measure, called
RATIONALITY.
• A system is rational if it does the
“right thing,” given what it knows.
INTRODUCTION ➔ WHAT IS AI? ➔ Acting humanly: The Turing Test approach
The Turing Test, proposed by Alan Turing (1950), was designed to provide a satisfactory operational definition of intelligence. A
computer passes the test if a human interrogator, after posing some written questions, cannot tell whether the written responses
come from a person or from a computer
The computer would need to possess the following capabilities:
• Natural Language Processing to enable it to communicate
successfully in English.
• Knowledge Representation to store what it knows or hears;
• Automated Reasoning to use the stored information to answer
questions and to draw new conclusions;
• Machine Learning to adapt to new circumstances and to detect and
extrapolate patterns.

Total Turing Test includes a video signal so that the


interrogator can test the subject’s perceptual abilities, as well as
the opportunity for the interrogator to pass physical objects
“through the hatch.” To pass the total Turing Test, the computer
will need
• Computer Vision to perceive objects, and
• Robotics to manipulate objects and move about.
INTRODUCTION ➔ WHAT IS AI? ➔ Thinking humanly: The cognitive modeling approach

If we are going to say that a given program thinks like a human, we must have some way of
determining how humans think. We need to get inside the actual workings of human minds.
There are three ways to do this:
1. Through introspection—trying to catch our own thoughts as they go by;
2. Through psychological experiments—observing a person in action; and
3. Through brain imaging—observing the brain in action.

The interdisciplinary field of cognitive science brings


together computer models from AI and experimental
techniques from psychology to construct precise and
testable theories of the human mind.
INTRODUCTION ➔ WHAT IS AI? ➔ Thinking rationally: The “laws of thought” approach

• The Greek philosopher Aristotle was one of the first to attempt to codify “right thinking,” that
is, irrefutable reasoning processes. His syllogisms provided patterns for argument structures
that always yielded correct conclusions when given correct premises.
• For example, “Socrates is a man; all men are mortal; therefore, Socrates is mortal.”
• These laws of thought were supposed to govern the operation of the mind; their study initiated
the field called logic.
• The so-called logicist tradition within artificial intelligence hopes to build on such programs to
create intelligent systems.

• There are two main obstacles to this approach:


1. First, it is not easy to take informal knowledge and state it in the formal terms required
by logical notation, particularly when the knowledge is less than 100% certain.
2. Second, there is a big difference between solving a problem “in principle” and solving it
in practice.
INTRODUCTION ➔ WHAT IS AI? ➔ Acting rationally: The rational agent approach
• An agent is just something that acts (agent comes from the Latin agere, to do).
• Computer agents are expected to do:
➢ operate autonomously,
➢ perceive their environment,
➢ persist over a prolonged time period,
➢ adapt to change,
➢ create and pursue goals.
• A rational agent is one that acts so as to achieve the best outcome or, when there is uncertainty, the best expected
outcome.
• In the “laws of thought” approach to AI, the emphasis was on correct inferences (conclusions).
• Making correct inferences is sometimes part of being a rational agent, because one way to act rationally is to
reason logically to the conclusion that a given action will achieve one’s goals and then to act on that conclusion.
• On the other hand, correct inference is not all of rationality; in some situations, there is no provably correct thing
to do, but something must still be done.
• There are also ways of acting rationally that cannot be said to involve inference.
THE STATE OF ART
• What can AI do today? A concise answer is difficult because
there are so many activities in so many subfields. Here we
sample a few applications:
– Robotic vehicles
– Speech recognition
– Autonomous planning and scheduling
– Game playing
– Spam fighting
– Logistics planning
– Robotics
– Machine Translation
Robotic Vehicles
• A driverless robotic car named STANLEY sped through the rough terrain
of the Mojave dessert at 22 mph, finishing the 132-mile course first to
win the 2005 DARPA Grand Challenge. STANLEY is a Volkswagen
Touareg outfitted with cameras, radar, and laser rangefinders to sense
the environment and onboard software to command the steering,
braking, and acceleration (Thrun, 2006). The following year CMU’s
BOSS won the Urban Challenge, safely driving in traffic through the
streets of a closed Air Force base, obeying traffic rules and avoiding
pedestrians and other vehicles.
Speech Recognition
• A traveler calling United Airlines to book a flight can have the entire
conversation guided by an automated speech recognition and dialog
management system.
Autonomous planning and scheduling
• A hundred million miles from Earth, NASA’s Remote
Agent program became the first on-board autonomous
planning program to control the scheduling of
operations for a spacecraft (Jonsson et al., 2000).
REMOTE AGENT generated plans from high-level goals
specified from the ground and monitored the
execution of those plans—detecting, diagnosing, and
recovering from problems as they occurred. Successor
program MAPGEN (Al-Chang et al., 2004) plans the
daily operations for NASA’s Mars Exploration Rovers,
and MEXAR2 (Cesta et al., 2007) did mission
planning—both logistics and science planning—for the
European Space Agency’s Mars Express mission in 2008
Game Playing
• IBM’s DEEP BLUE became the first computer
program to defeat the world champion in a chess
match when it bested Garry Kasparov by a score of
3.5 to 2.5 in an exhibition match (Goodman and
Keene, 1997). Kasparov said that he felt a “new
kind of intelligence” across the board from him.
Newsweek magazine described the match as “The
brain’s last stand.” The value of IBM’s stock
increased by $18 billion. Human champions
studied Kasparov’s loss and were able to draw a
few matches in subsequent years, but the most
recent human-computer matches have been won
convincingly by the computer
Spam fighting
• Each day, learning algorithms classify over a billion
messages as spam, saving the recipient from having
to waste time deleting what, for many users, could
comprise 80% or 90% of all messages, if not
classified away by algorithms. Because the
spammers are continually updating their tactics, it is
difficult for a static programmed approach to keep
up, and learning algorithms work best (Sahami et al.,
1998; Goodman and Heckerman, 2004).
Logistics planning
• During the Persian Gulf crisis of 1991, U.S. forces
deployed a Dynamic Analysis and Replanning Tool,
DART (Cross and Walker, 1994), to do automated
logistics planning and scheduling for transportation.
This involved up to 50,000 vehicles, cargo, and people
at a time, and had to account for starting points,
destinations, routes, and conflict resolution among all
parameters. The AI planning techniques generated in
hours a plan that would have taken weeks with older
methods. The Defense Advanced Research Project
Agency (DARPA) stated that this single application
more than paid back DARPA’s 30-year investment in AI.
Robotics
• The iRobot Corporation has sold over two
million Roomba robotic vacuum cleaners for
home use. The company also deploys the
more rugged PackBot to Iraq and Afghanistan,
where it is used to handle hazardous
materials, clear explosives, and identify the
location of snipers.
Machine Translation
• A computer program automatically translates
from Arabic to English, allowing an English
speaker to see the headline “Ardogan Confirms
That Turkey Would Not Accept Any Pressure,
Urging Them to Recognize Cyprus.” The program
uses a statistical model built from examples of
Arabic-to-English translations and from examples
of English text totaling two trillion words (Brants
et al., 2007). None of the computer scientists on
the team speak Arabic, but they do understand
statistics and machine learning algorithms
Chapter 2
Intelligent Agents
Agents and Environment
An agent is anything that can be viewed as
perceiving its environment through sensors and
SENSOR acting upon that environment through
actuators. This simple idea is illustrated in Figure
2.1. ACTUATOR A human agent has eyes, ears, and
other organs for sensors and hands, legs, vocal
tract, and so on for actuators.

We use the term percept to refer to the agent’s


perceptual inputs at any given instant. An
PERCEPT SEQUENCE agent’s percept sequence is
the complete history of everything the agent has
ever perceived.
Agents and Environment
• Mathematically speaking, we say that an agent’s behavior is AGENT FUNCTION
described by the agent function that maps any given percept sequence to an
action.
• We can imagine tabulating the agent function that describes any given agent;
• Given an agent to experiment with, we can, in principle, construct this table by
trying out all possible percept sequences and recording which actions the
agent does in response. The table is, of course, an external characterization of
the agent. Internally, the agent function for an artificial agent will be
implemented by an AGENT PROGRAM agent program.
• It is important to keep these two ideas distinct. The agent function is an
abstract mathematical description; the agent program is a concrete
implementation, running within some physical system.
The Vacuum-Cleaner World
• This world is so simple that we can describe
everything that happens; it’s also a made-up
world, so we can invent many variations. This
particular world has just two locations: squares A
and B. The vacuum agent perceives which square
it is in and whether there is dirt in the square. It
can choose to move left, move right, suck up the
dirt, or do nothing. One very simple agent
function is the following: if the current square is
dirty, then suck; otherwise, move to the other
square.
The Vacuum-Cleaner World
Program implements the agent function
tabulated in Fig. 2.3

Function Reflex-Vacuum-Agent([location,status]) return an action


If status = Dirty then return Suck
else if location = A then return Right
else if location = B then return left
Concept of Rationality
Rational agent
⚫ One that does the right thing
⚫ = every entry in the table for the
agent function is correct (rational).
What is correct?
⚫ The actions that cause the agent to
be most successful
⚫ So we need ways to measure success.
Performance measure
Performance measure
⚫ An objective function that determines
⚫ How the agent does successfully
⚫ E.g., 90% or 30% ?
An agent, based on its percepts
⚫→ action sequence :
if desirable, it is said to be performing well.
⚫ No universal performance measure for all
agents
Performance measure
A general rule:
⚫ Design performance measures according to
⚫ What one actually wants in the environment
⚫ Rather than how one thinks the agent should
behave
E.g., in vacuum-cleaner world
⚫ We want the floor clean, no matter how the
agent behave
⚫ We don’t restrict how the agent behaves
Rationality
What is rational at any given time
depends on four things:
⚫ The performance measure defining the
criterion of success
⚫ The agent’s prior knowledge of the
environment
⚫ The actions that the agent can perform
⚫ The agents’s percept sequence up to now
Rational agent
For each possible percept sequence,
⚫ an rational agent should select
⚫ an action expected to maximize its
performance measure, given the evidence
provided by the percept sequence and
whatever built-in knowledge the agent has
E.g., an exam
⚫ Maximize marks, based on
the questions on the paper & your
knowledge
Example of a rational agent
Performance measure
⚫ Awards one point for each clean square
⚫ at each time step, over 10000 time steps
Prior knowledge about the
environment
⚫ The geography of the environment
⚫ Only two squares
⚫ The effect of the actions
Example of a rational agent
Actions that can perform
⚫ Left, Right, Suck and NoOp
Percept sequences
⚫ Where is the agent?
⚫ Whether the location contains dirt?

Under this circumstance, the agent is


rational.
Omniscience
An omniscient agent
⚫ Knows the actual outcome of its actions in
advance
⚫ No other possible outcomes

⚫ However, impossible in real world

An example
⚫ crossing a street but died of the fallen
cargo door from 33,000ft → irrational?
Omniscience
Based on the circumstance, it is rational.
As rationality maximizes
⚫ Expected performance
Perfection maximizes
⚫ Actual performance
Hence rational agents are not omniscient.
Learning
Does a rational agent depend on
only current percept?
⚫ No, the past percept sequence should
also be used
⚫ This is called learning
⚫ After experiencing an episode, the
agent
⚫ should adjust its behaviors to perform
better for the same job next time.
Autonomy
If an agent just relies on the prior knowledge of
its designer rather than its own percepts then the
agent lacks autonomy
A rational agent should be autonomous- it should
learn what it can to compensate for partial or
incorrect prior knowledge.
E.g., a clock
⚫ No input (percepts)
⚫ Run only but its own algorithm (prior knowledge)
⚫ No learning, no experience, etc.
Software Agents
Sometimes, the environment may not be the
real world
⚫ E.g., flight simulator, video games, Internet
⚫ They are all artificial but very complex
environments
⚫ Those agents working in these environments
are called
⚫Softwareagent (softbots)
⚫Because all parts of the agent are software
Task environments
Task environments are the problems
⚫ While the rational agents are the solutions
Specifying the task environment
⚫ PEAS description as fully as possible
⚫ Performance
⚫ Environment
⚫ Actuators
⚫ Sensors
In designing an agent, the first step must always be
to specify the task environment as fully as possible.
Use automated taxi driver as an example
Task environments
Performance measure
⚫ How can we judge the automated
driver?
⚫ Which factors are considered?
⚫ getting to the correct destination
⚫ minimizing fuel consumption
⚫ minimizing the trip time and/or cost
⚫ minimizing the violations of traffic laws
⚫ maximizing the safety and comfort, etc.
Task environments
Environment
⚫ A taxi must deal with a variety of roads
⚫ Traffic lights, other vehicles, pedestrians,
stray animals, road works, police cars, etc.
⚫ Interact with the customer
Task environments
Actuators (for outputs)
⚫ Control over the accelerator, steering, gear
shifting and braking
⚫ A display to communicate with the
customers
Sensors (for inputs)
⚫ Detect other vehicles, road situations
⚫ GPS (Global Positioning System) to know
where the taxi is
⚫ Many more devices are necessary
Task environments
A sketch of automated taxi driver
Properties of task environments
Fully observable vs. Partially
observable
⚫ Ifan agent’s sensors give it access to
the complete state of the environment
at each point in time then the
environment is effectively and fully
observable
⚫ if the sensors detect all aspects
⚫ That are relevant to the choice of action
Partially observable
An environment might be Partially observable because of noisy
and inaccurate sensors or because parts of the state are simply
missing from the sensor data.
Example:
⚫ A local dirt sensor of the cleaner cannot tell
⚫ Whether other squares are clean or not
Properties of task environments
Deterministic vs. stochastic
⚫ next state of the environment Completely determined by the current
state and the actions executed by the agent, then the environment
is deterministic, otherwise, it is Stochastic.
⚫ Strategic environment: deterministic except for actions of other
agents
-Cleaner and taxi driver are:
⚫Stochastic because of some unobservable aspects → noise or unknown
Properties of task environments
Episodic vs. sequential
⚫ An episode = agent’s single pair of perception & action
⚫ The quality of the agent’s action does not depend on other
episodes
⚫Every episode is independent of each other
⚫ Episodic environment is simpler
⚫The agent does not need to think ahead
Sequential
⚫ Current action may affect all future decisions
-Ex. Taxi driving and chess.
Properties of task environments
Static vs. dynamic
⚫ A dynamic environment is always changing over time
⚫E.g., the number of people in the street
⚫ While static environment
⚫E.g., the destination
Semidynamic
⚫ environment is not changed over time
⚫ but the agent’s performance score does
Properties of task environments

Discrete vs. continuous


⚫ If there are a limited number of distinct
states, clearly defined percepts and actions,
the environment is discrete
⚫ E.g., Chess game

⚫ Continuous: Taxi driving


Properties of task environments

Single agent VS. multiagent


⚫ Playing a crossword puzzle – single agent
⚫ Chess playing – two agents

⚫ Competitive multiagent environment


⚫Chess playing
⚫ Cooperative multiagent environment
⚫Automated taxi driver
⚫Avoiding collision
Properties of task environments

Known vs. unknown


This distinction refers not to the environment itslef but to
the agent’s (or designer’s) state of knowledge about the
environment.
-In known environment, the outcomes for all actions are
given. ( example: solitaire card games).
- If the environment is unknown, the agent will have to learn
how it works in order to make good decisions.( example:
new video game).
Examples of task environments
Structure of agents
Structure of agents
Agent = architecture + program
⚫ Architecture = some sort of
computing device (sensors +
actuators)
⚫ (Agent) Program = some function that
implements the agent mapping = “?”
⚫ Agent Program = Job of AI
Agent programs
Input for Agent Program
⚫ Only the current percept
Input for Agent Function
⚫ The entire percept sequence
⚫ The agent must remember all of them
Implement the agent program as
⚫A look up table (agent function)
Agent Programs
Skeleton design of an agent
program
Agent Programs
P = the set of possible percepts
T= lifetime of the agent
⚫ The total number of percepts it receives
Size of the look up table Tt=1 P t
Consider playing chess
⚫P =10, T=150
⚫ Will require a table of at least 10150
entries
Agent Programs
Despite of huge size, look up table does
what we want.
The key challenge of AI
⚫ Find out how to write programs that, to the
extent possible, produce rational behavior
⚫ From a small amount of code
⚫ Rather than a large amount of table entries
⚫ E.g., a five-line program of Newton’s Method
⚫ V.s. huge tables of square roots, sine, cosine, …
Types of agent programs
Four types
⚫ Simple reflex agents
⚫ Model-based reflex agents

⚫ Goal-based agents

⚫ Utility-based agents
Simple reflex agents
It uses just condition-action rules
⚫ The rules are like the form “if … then …”
⚫ efficient but have narrow range of
applicability
⚫ Because knowledge sometimes cannot
be stated explicitly
⚫ Work only
⚫ if the environment is fully observable
Simple reflex agents
Simple reflex agents (2)
A Simple Reflex Agent in Nature
percepts
(size, motion)

RULES:
(1) If small moving object,
then activate SNAP
(2) If large moving object,
then activate AVOID and inhibit SNAP
ELSE (not moving) then NOOP
needed for
completeness Action: SNAP or AVOID or NOOP
Model-based Reflex Agents
For the world that is partially observable
⚫ the agent has to keep track of an internal
state
⚫ That depends on the percept history
⚫ Reflecting some of the unobserved aspects
⚫ E.g., driving a car and changing lane
Requiring two types of knowledge
⚫ How the world evolves independently of the
agent
⚫ How the agent’s actions affect the world
Example Table Agent
With Internal State
IF THEN
Saw an object ahead, Go straight
and turned right, and
it’s now clear ahead
Saw an object Ahead, Halt
turned right, and object
ahead again
See no objects ahead Go straight

See an object ahead Turn randomly


Example Reflex Agent With Internal State:
Wall-Following

start

Actions: left, right, straight, open-door


Rules:
1. If open(left) & open(right) and open(straight) then
choose randomly between right and left
2. If wall(left) and open(right) and open(straight) then straight
3. If wall(right) and open(left) and open(straight) then straight
4. If wall(right) and open(left) and wall(straight) then left
5. If wall(left) and open(right) and wall(straight) then right
6. If wall(left) and door(right) and wall(straight) then open-door
7. If wall(right) and wall(left) and open(straight) then straight.
8. (Default) Move randomly
Model-based Reflex Agents

The agent is with memory


Model-based Reflex Agents
Goal-based agents
Current state of the environment is
always not enough
The goal is another issue to achieve
⚫ Judgment of rationality / correctness
Actions chosen → goals, based on
⚫ the current state
⚫ the current percept
Goal-based agents
Conclusion
⚫ Goal-based agents are less efficient
⚫ but more flexible
⚫ Agent  Different goals  different tasks
⚫ Search and planning
⚫ two other sub-fields in AI
⚫ to find out the action sequences to achieve
its goal
Goal-based agents
Utility-based agents
Goals alone are not enough
⚫ to generate high-quality behavior
⚫ E.g. meals in Canteen, good or not ?

Many action sequences → the goals


⚫ some are better and some worse
⚫ If goal means success,
⚫ then utility means the degree of success
(how successful it is)
Utility-based agents
Utility-based agents
it is said state A has higher utility
⚫ Ifstate A is more preferred than
others
Utility is therefore a function
⚫ that maps a state onto a real number
⚫ the degree of success
Utility-based agents
Utility has several advantages:
⚫ When there are conflicting goals,
⚫ Only some of the goals but not all can be
achieved
⚫ utility describes the appropriate trade-off
⚫ When there are several goals
⚫ None of them are achieved certainly
⚫ utility provides a way for the decision-
making
Learning Agents
After an agent is programmed, can it
work immediately?
⚫ No, it still need teaching
In AI,
⚫ Once an agent is done
⚫ We teach it by giving it a set of examples
⚫ Test it by using another set of examples
We then say the agent learns
⚫ A learning agent
Learning Agents
Four conceptual components
⚫ Learning element
⚫ Making improvement
⚫ Performance element
⚫ Selecting external actions
⚫ Critic
⚫ Tells the Learning element how well the agent is doing
with respect to fixed performance standard.
(Feedback from user or examples, good or not?)
⚫ Problem generator
⚫ Suggest actions that will lead to new and informative
experiences.
Learning Agents
How the components of agent
programs work
THANK YOU
ATME COLLEGE OF ENGINEERING
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

Module -2

Subject: ARTIFICIAL INTELLIGENCE


Subject Code: BCS515B
Prepared By:
Dr. Shilpa B L
Associate Professor
Dept. of CSE, ATMECE
PROBLEM SOLVING ➔ PROBLEM-SOLVING AGENTS

• Intelligent agents are supposed to maximize their performance measure.

• Achieving this is sometimes simplified if the agent can adopt a goal and aim at satisfying it.
• Goals help organize behaviour by limiting the objectives that the agent is trying to achieve and hence the
actions it needs to consider.

• Goal formulation, based on the current situation and the agent’s performance measure, is the first step in
problem solving.

• 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 actions it recommends can be carried out. This is called the execution phase.
PROBLEM SOLVING ➔ PROBLEM-SOLVING AGENTS
• Thus, we have a simple “formulate,
search, execute” design for the agent, as
shown in Figure 1.
• After formulating a goal and a problem
to solve, the agent calls a search
procedure to solve it.
• It then uses the solution to guide its
actions, doing whatever the solution
recommends as the next thing to do—
typically, the first action of the
sequence—and then removing that step
from the sequence. Figure 1 A simple problem-solving agent.
It first formulates a goal and a problem, searches for a
• Once the solution has been executed, the sequence of actions that would solve the problem, and then
agent will formulate a new goal. executes the actions one at a time. When this is complete, it
formulates another goal and starts over.
PROBLEM SOLVING ➔ PROBLEM-SOLVING AGENTS ➔ Well-defined Problems and Solutions
A problem can be defined formally by five components:
1. The initial state that the agent starts in. For example, the initial state for our agent in Romania might be described as
In(Arad).

2. A description of the possible actions available to the agent. Given a particular state s, ACTIONS(s) returns the set of
actions that can be executed in s. We say that each of these actions is applicable in s. For example, from the state In(Arad),
the applicable actions are {Go(Sibiu), Go(Timisoara), Go(Zerind)}.

3. A description of what each action does; the formal name for this is the transition model, specified by a function
RESULT(s, a) that returns the state that results from doing action a in state s. We also use the term successor to refer to
any state reachable from a given state by a single action. For example, we have
RESULT(In(Arad), Go(Zerind)) = In(Zerind)

Together, the initial state, actions, and transition model implicitly define the state space of the problem—the set of all
states reachable from the initial state by any sequence of actions. The state space forms a directed network or graph in
which the nodes are states and the links between nodes are actions. (The map of Romania shown in Figure 2 can be
interpreted as a state-space graph if we view each road as standing for two driving actions, one in each direction) A path
in the state space is a sequence of states connected by a sequence of actions.
PROBLEM SOLVING ➔ PROBLEM-SOLVING AGENTS ➔ Well-defined Problems and Solutions
4. The goal test, which determines whether a
given state is a goal state. Sometimes there
is an explicit set of possible goal states, and
the test simply checks whether the given
state is one of them. The agent’s goal in
Romania is the singleton set
{In(Bucharest)}.
5. A path cost function that assigns a numeric
cost to each path. The problem-solving
agent chooses a cost function that reflects
its own performance measure. For the agent
trying to get to Bucharest, time is of the
essence, so the cost of a path might be its
length in kilometers. The step cost of taking
action a in state s to reach state s` is denoted
by c(s, a, s`). The step costs for Romania Figure 1.2 A simplified road map of part of Romania.
are shown in Figure 2 as route distances.
We assume that step costs are nonnegative.
PROBLEM SOLVING ➔ EXAMPLE PROBLEMS

• The problem-solving approach has been applied to a vast array of task


environments.
• We list some of the best known here, distinguishing between toy and real-
world problems.
• A toy problem is intended to illustrate or exercise various problem-solving
methods. It can be given a concise, exact description and hence is usable by
different researchers to compare the performance of algorithms.
• A real-world problem is one whose solutions people actually care about.
PROBLEM SOLVING ➔ EXAMPLE PROBLEMS ➔ Toy Problem
The first example we examine is the vacuum world. (See Figure 3) This can be formulated as a problem as follows:
• States: The state is determined by both the agent location and the dirt locations. The agent is in one of two
locations, each of which might or might not contain dirt. Thus, there are 2 × 22 = 8 possible world states. A larger
environment with n locations has n * 2n states.
• Initial state: Any state can be designated
as the initial state.
• Actions: In this simple environment,
each state has just three actions: Left,
Right, and Suck. Larger environments
might also include Up and Down.
• Transition model: The actions have
their expected effects, except that
moving Left in the leftmost square,
moving Right in the rightmost square,
and Sucking in a clean square have no
effect. The complete state space is shown
in Figure 3.
• Goal test: This checks whether all the Figure 3 The state space for the vacuum world. Links denote
squares are clean. actions: L = Left, R = Right, S = Suck.
• Path cost: Each step costs 1, so the path
cost is the number of steps in the path.
PROBLEM SOLVING ➔ EXAMPLE PROBLEMS ➔ Toy Problem
The 8-puzzle, an instance of which is shown in Figure 4, consists of a 3×3 board with eight numbered tiles and a
blank space. A tile adjacent to the blank space can slide into the space. The object is to reach a specified goal state,
such as the one shown on the right of the figure. The standard formulation is as follows:
• States: A state description specifies the location of each of the eight tiles and the blank in one of the nine
squares.
• Initial state: Any state can be designated as the initial state. Note that any given goal can be reached from
exactly half of the possible initial states.
• Actions: The simplest formulation defines the
actions as movements of the blank space Left, Right,
Up, or Down.
• Transition model: Given a state and action, this
returns the resulting state; for example, if we apply
Left to the start state, the resulting state has the 5 and
the blank switched.
• Goal test: This checks whether the state matches the Figure 4 A typical instance of the 8-puzzle.
goal state.
• Path cost: Each step costs 1, so the path cost is the number of steps in the path.
PROBLEM SOLVING ➔ EXAMPLE PROBLEMS ➔ Toy Problem
The goal of the 8-queens problem is to place eight queens on a chessboard such that no queen attacks any other.
(A queen attacks any piece in the same row, column or diagonal.) Figure 5 shows an attempted solution that fails:
the queen in the rightmost column is attacked by the queen at the top left.
There are two main kinds of formulation:
❑ An incremental formulation involves operators that
augment the state description, starting with an empty state; for
the 8-queens problem, this means that each action adds a
queen to the state.
❑ A complete-state formulation starts with all 8 queens on the
board and moves them around. In either case, the path cost is
of no interest because only the final state counts. The first
incremental formulation one might try is the following:
• States: Any arrangement of 0 to 8 queens on the board is
a state.
• Initial state: No queens on the board. Figure 5 Almost a solution to the 8-queens problem.
• Actions: Add a queen to any empty square.
• Transition model: Returns the board with a queen added to the specified square.
• Goal test: 8 queens are on the board, none attacked.
PROBLEM SOLVING ➔ EXAMPLE PROBLEMS ➔ Real-world Problems
• Route-finding problem is defined in terms of specified locations and transitions along links between them.
Route-finding algorithms are used in a variety of applications. Some, such as Web sites and in-car systems that
provide driving directions, are relatively straightforward extensions of the Romania example.
• Touring problems are closely related to route-finding problems, but with an important difference. As with
route finding, the actions correspond to trips between adjacent cities. The state space, however, is quite
different. Each state must include not just the current location but also the set of cities the agent has visited.
• The traveling salesperson problem (TSP) is a touring problem in which each city must be visited exactly
once. The aim is to find the shortest tour. The problem is known to be NP-hard, but an enormous amount of
effort has been expended to improve the capabilities of TSP algorithms.
• A VLSI layout problem requires positioning millions of components and connections on a chip to minimize
area, minimize circuit delays, minimize stray capacitances, and maximize manufacturing yield. The layout
problem comes after the logical design phase and is usually split into two parts: cell layout and channel
routing. In cell layout, the primitive components of the circuit are grouped into cells, each of which performs
some recognized function. Channel routing finds a specific route for each wire through the gaps between the
cells. These search problems are extremely complex, but definitely worth solving.
• Robot navigation is a generalization of the route-finding problem described earlier. Rather than following a
discrete set of routes, a robot can move in a continuous space with an infinite set of possible actions and states.
When the robot has arms and legs or wheels that must also be controlled, the search space becomes many-
dimensional. Advanced techniques are required just to make the search space finite.
PROBLEM SOLVING ➔ SEARCHING FOR SOLUTIONS
• Having formulated some problems, we now need to solve them. A solution is an action sequence, so search algorithms work
by considering various possible action sequences. The possible action sequences starting at the initial state form a search
tree with the initial state at the root; the branches are actions and the nodes correspond to states in the state space of the
problem.
• Figure 6 shows the first few steps in growing the search
tree for finding a route from Arad to Bucharest. The root
node of the tree corresponds to the initial state, In(Arad).
• The first step is to test whether this is a goal state, if not,
then we need to consider taking various actions. We do
this by expanding the current state; that is, applying
each legal action to the current state, thereby generating
a new set of states.
• In this case, we add three branches from the parent
node In(Arad) leading to three new child nodes:
In(Sibiu), In(Timisoara), and In(Zerind).
• Now we must choose which of these three possibilities
to consider further.
• Each of these six nodes is a leaf node, that is, a node
with no children in the tree.
• The set of all leaf nodes available for expansion at any
Figure 6 Partial search trees for finding a route from Arad to
given point is called the frontier/open list. Bucharest.
PROBLEM SOLVING ➔ SEARCHING FOR SOLUTIONS
• The process of expanding nodes on the frontier continues until either a solution is found or there are no more states to
expand. The general TREE-SEARCH algorithm is shown informally in the Figure 7.
• Search algorithms all share this basic structure; they vary primarily according to how they choose which state to expand
next—the so-called search strategy.
• Can be noticed one peculiar thing about the search tree
shown in Figure 6, it includes the path from Arad to Sibiu
and back to Arad again! We say that In(Arad) is a repeated
state in the search tree, generated in this case by a loopy
path.
• Loopy paths are a special case of the more general concept
of redundant paths, which exist whenever there is more
than one way to get from one state to another.
o Consider the paths Arad–Sibiu (140 km long) and
Arad–Zerind–Oradea–Sibiu (297 km long). Obviously,
the second path is redundant—it’s just a worse way to
get to the same state.
• The way to avoid exploring redundant paths is to remember Figure 7 An informal description of the general tree-search and
where one has been. To do this, we augment the TREE- graph-search algorithms. The parts of GRAPH-SEARCH marked in
SEARCH algorithm with a data structure called the bold italic are the additions needed to handle repeated states.
set (also known as the closed list), which remembers every expanded node. Newly generated nodes that match previously
explored
generated nodes—ones in the explored set or the frontier—can be discarded instead of being added to the frontier.
PROBLEM SOLVING ➔ SEARCHING FOR SOLUTIONS

• The search tree constructed by the GRAPH-


SEARCH algorithm contains at most one copy of
each state, so we can think of it as growing a tree
directly on the state-space graph, as shown in 8
Figure 8.
• The algorithm has another nice property: the
frontier separates the state-space graph into the
explored region and the unexplored region, so that
every path from the initial state to an unexplored
state has to pass through a state in the frontier.
• This property is illustrated in Figure 9. As every
step moves a state from the frontier into the
explored region while moving some states from
9
the unexplored region into the frontier, we see that
the algorithm is systematically examining the
states in the state space, one by one, until it finds a
solution.
PROBLEM SOLVING ➔ SEARCHING FOR SOLUTIONS ➔ Infrastructure for Search Algorithms
• Search algorithms require a data structure to keep track of the search tree that is being constructed. For each
node n of the tree, we have a structure that contains four components:
o n.STATE: the state in the state space to which the node corresponds;
o n.PARENT: the node in the search tree that generated this node;
o n.ACTION: the action that was applied to the parent to generate the node;
o n.PATH-COST: the cost, traditionally denoted by g(n), of the path from the initial state to the node, as
indicated by the parent pointers.
• Given the components for a parent node, it is easy to see how to compute the necessary components for a child
node. The function CHILD-NODE takes a parent node and an action and returns the resulting child node:

• The node data structure is depicted in Figure 10.

Figure 10 Nodes are the data structures from which the search tree is
constructed. Each has a parent, a state, and various bookkeeping fields.
Arrows point from child to parent.
PROBLEM SOLVING ➔ SEARCHING FOR SOLUTIONS ➔ Infrastructure for Search Algorithms

• Now that we have nodes, we need somewhere to put them.


• The frontier needs to be stored in such a way that the search algorithm can easily choose the next node to
expand according to its preferred strategy.
• The appropriate data structure for this is a queue.
• The operations on a queue are as follows:
o EMPTY?(queue) returns true only if there are no more elements in the queue.
o POP(queue) removes the first element of the queue and returns it.
o INSERT(element, queue) inserts an element and returns the resulting queue.
• Three common variants are the first-in, first-out FIFO QUEUE or FIFO queue, which pops the oldest element
of the queue; the last-in, first-out or LIFO queue (also known as a stack), which pops the newest element of
the queue; and the priority queue, which pops the element of the queue with the highest priority according to
some ordering function.
PROBLEM SOLVING ➔ SEARCHING FOR SOLUTIONS ➔ Measuring Problem-solving Performance

We can evaluate an algorithm’s performance in four ways:


1. Completeness: Is the algorithm guaranteed to find a solution when there is one?
2. Optimality: Does the strategy find the optimal solution?
3. Time complexity: How long does it take to find a solution?
4. Space complexity: How much memory is needed to perform the search?
In AI, the graph is often represented implicitly by the initial state, actions, and transition model
and is frequently infinite. For these reasons, complexity is expressed in terms of three
quantities:
1. b, the branching factor or maximum number of successors of any node;
2. d, the depth of the shallowest goal node (i.e., the number of steps along the path from
the root); and
3. m, the maximum length of any path in the state space.
PROBLEM SOLVING ➔ UNINFORMED SEARCH STRATEGIES
This section covers several search strategies that come under the heading of uninformed search (also called
blind search).
▪ The term means that the strategies have no additional information about states beyond that provided in the
problem definition. All they can do is generate successors and distinguish a goal state from a non-goal
state.

Breadth-first Search:
• Breadth-first search is a simple strategy in which the root node is expanded first, then all the successors of
the root node are expanded next, then their successors, and so on.
• In general, all the nodes are expanded at a given depth in the search tree before any nodes at the next level are
expanded.
• Breadth-first search is an instance of the general graph-search algorithm inwhich the shallowest unexpanded
node is chosen for expansion.
• This is achieved very simply by using a FIFO queue for the frontier. Thus, new nodes (which are always
deeper than their parents) go to the back of the queue, and old nodes, which are shallower than the new nodes,
get expanded first.
• Pseudocode is given in Figure 11 and Figure 12 shows the progress of the search on a simple binary tree.
• The time complexity of BFS is 𝑂 𝑏𝑑 , and space complexity is also𝑂 𝑏𝑑 , where b is a branching factor and d
is a depth.
PROBLEM SOLVING ➔ UNINFORMED SEARCH STRATEGIES

Figure 12 Breadth-first search


on a simple binary tree. At each
stage, the node to be expanded
next is indicated by a marker.

Figure 11 Breadth-first search on a graph.


PROBLEM SOLVING ➔ UNINFORMED SEARCH STRATEGIES
Depth-first search:
• Depth-first search always expands the deepest node in the
current frontier of the search tree.
• The progress of the search is illustrated in Figure 13.
• The search proceeds immediately to the deepest level of the
search tree, where the nodes have no successors.
• As those nodes are expanded, they are dropped from the
frontier, so then the search “backs up” to the next deepest
node that still has unexplored successors.
• The depth-first search algorithm is an instance of the graph-
search algorithm; whereas breadth-first-search uses a FIFO
queue, depth-first search uses a LIFO queue.
o A LIFO queue means that the most recently generated
node is chosen for expansion.
o Thismust be the deepest unexpanded node because it is
one deeper than its parent.
• The time complexity of DFS is 𝑂 𝑏𝑚 , and space
Figure 13 Depth-first search on a binary tree. The unexplored region is
complexity is 𝑂 𝑏𝑚 , where b is a branching factor and m
shown in light gray. Explored nodes with no descendants in the frontier
is a maximum depth. are removed from memory. Nodes at depth 3 have no successors and M
is the only goal node.
Breadth First search
Depth First search
Depth-first search is an algorithm for traversing or searching tree or graph data structures. The algorithm starts at the
root node (selecting some arbitrary node as the root node in the case of a graph) and explores as far as possible along
each branch before backtracking.
Algorithm
Step 1: SET STATUS = 1 (ready state) for each node in G
Step 2: Push the starting node A on the stack and set its
STATUS = 2 (waiting state)
Step 3: Repeat Steps 4 and 5 until STACK is empty
Step 4: Pop the top node N. Process it and set its STATUS =
3 (processed state)
Step 5: Push on the stack all the neighbors of N that are in
the ready state (whose STATUS = 1) and set their STATUS =
2 (waiting state)
[END OF LOOP]
The step by step process to the DFS traversal is given as
follows -
First, create a stack with the total number of vertices in the
graph.
Now, choose any vertex as the starting point of traversal, and
push that vertex into the stack.
After that, push a non-visited vertex (adjacent to the vertex on
the top of the stack) to the top of the stack.
Now, repeat steps 3 and 4 until no vertices are left to visit from
the vertex on the stack's top.
If no vertex is left, go back and pop a vertex from the stack.
Repeat steps 2, 3, and 4 until the stack is empty.
Example of DFS algorithm
example given below, there is a directed graph having 7 vertices.
Now, all the graph nodes have been traversed, and the stack is empty.
Sample examples
Comparing uninformed search
strategies
THANK YOU
ATME COLLEGE OF ENGINEERING
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

Module -3

Subject: ARTIFICIAL INTELLIGENCE


Subject Code: BCS515B
Prepared By:
Dr. Shilpa B L
Associate Professor
Dept. of CSE, ATMECE
INFORMED (HEURISTIC) SEARCH STRATEGIES
• This section shows how an informed search strategy—one that uses problem-specific
knowledge beyond the definition of the problem itself—can find solutions more efficiently
than can an uninformed strategy.
• The general approach we consider is called best-first search.
o Best-first search is an instance of the general TREE-SEARCH or GRAPH-SEARCH
algorithm in which a node is selected for expansion based on an evaluation function,
f(n).
• The evaluation function is construed as a cost estimate, so the node with the lowest
evaluation is expanded first.
• The choice of f determines the search strategy.
• Most best-first algorithms include as a component of f a heuristic function, denoted h(n):
h(n) = estimated cost of the cheapest path from the state at node n to a goal state
INFORMED (HEURISTIC) SEARCH STRATEGIES ➔ Greedy best-first search
• Greedy best-first search tries to expand the node that is closest to the goal, on the grounds that this is likely
to lead to a solution quickly. Thus, it evaluates nodes by using just the heuristic function; that is, f(n) = h(n).
• Let us see how this works for route-finding problems in Romania; we use the straight line distance heuristic,
which we will call hSLD.
• If the goal is Bucharest, we need to know the straight-line
distances to Bucharest, which are shown in Figure 2.1. For
example, hSLD(In(Arad))=366.
• Figure 2.2 shows the progress of a greedy best-first search using
hSLD to find a path from Arad to Bucharest.
• The first node to be expanded from Arad will be Sibiu because it Figure 2.1 Values of hSLD—straight-line distances
is closer to Bucharest than either Zerind or Timisoara. to Bucharest.

• The next node to be expanded will be Fagaras because it is closest. Fagaras in turn generates Bucharest, which
is the goal.
• For this particular problem, greedy best-first search using hSLD finds a solution without ever expanding a node
that is not on the solution path; hence, its search cost is minimal.
INFORMED (HEURISTIC) SEARCH STRATEGIES ➔ Greedy best-first search

Figure 2.2 Stages in a greedy best-first tree


search for Bucharest with the straight-line
distance heuristic hSLD. Nodes are labeled with
their h-values.
INFORMED (HEURISTIC) SEARCH STRATEGIES ➔ A* search: Minimizing the total estimated solution cost
• The most widely known form of best-first search is called A* search.
• It evaluates nodes by combining g(n), the cost to reach the node, and h(n), the cost to get from the node to the
goal:
f(n) = g(n) + h(n)
• Since g(n) gives the path cost from the start node to node n, and h(n) is the estimated cost of the cheapest path
from n to the goal, we have
f(n) = estimated cost of the cheapest solution through n
• Thus, if we are trying to find the cheapest solution, a reasonable thing to try first is the node with the lowest
value of g(n) + h(n).

Conditions for optimality: Admissibility and Consistency


• The first condition we require for optimality is that h(n) be an admissible heuristic. An admissible heuristic is
one that never overestimates the cost to reach the goal.
• Admissible heuristics are by nature optimistic because they think the cost of solving the problem is less than it
actually is. An obvious example of an admissible heuristic is the straight-line distance hSLD that we used in
getting to Bucharest.
• In Figure 2.3, we show the progress of an A* tree search for Bucharest. The values of g are computed from the
step costs in Figure 1.2, and the values of hSLD are given in Figure 2.1. Notice in particular that Bucharest first
appears on the frontier at step (e), but it is not selected for expansion because its f-cost (450) is higher than that
of Pitesti (417).
INFORMED (HEURISTIC) SEARCH STRATEGIES ➔ A* search: Minimizing the total estimated solution cost

Figure 2.3 Stages in an A* search for Bucharest. Nodes are labeled with f = g +h. The h values are the
straight-line distances to Bucharest taken from Figure 2.1.
INFORMED (HEURISTIC) SEARCH STRATEGIES ➔ A* search: Minimizing the total estimated solution cost

• A second, slightly stronger condition called consistency (or sometimes monotonicity) is


required only for applications of A* to graph search.
• A heuristic h(n) is consistent if, for every node n and every successor n` of n generated by
any action a, the estimated cost of reaching the goal from n is no greater than the step cost
of getting to n` plus the estimated cost of reaching the goal from n:
INFORMED (HEURISTIC) SEARCH STRATEGIES ➔ HEURISTIC FUNCTIONS
• Here, we look at heuristics for the 8-puzzle, in order to shed light on the nature of heuristics in general.
• The 8-puzzle was one of the earliest heuristic search problems. The
object of the puzzle is to slide the tiles horizontally or vertically into
the empty space until the configuration matches the goal
configuration (Figure 2.4).
• The average solution cost for a randomly generated 8-puzzle instance
is about 22 steps.
• The branching factor is about 3 (When the empty tile is in the middle,
four moves are possible; when it is in a corner, two; and when it is Figure 2.4 A typical instance of the 8-puzzle.
along an edge, three.) This means that an exhaustive tree search to The solution is 26 steps long.
22
depth 22 would look at about 3 states.
• If we want to find the shortest solutions by using A*, we need a heuristic function that never overestimates the
number of steps to the goal.
• There is a long history of such heuristics for the 8-puzzle; here are two commonly used candidates:
❑ h1 = the number of misplaced tiles. For Figure 2.4, all of the eight tiles are out of position, so the start
state would have h1 = 8. h1 is an admissible heuristic because it is clear that any tile that is out of place
must be moved at least once.
INFORMED (HEURISTIC) SEARCH STRATEGIES ➔ HEURISTIC FUNCTIONS
❑ h2 = the sum of the distances of the tiles from their goal positions. Because tiles cannot move along
diagonals, the distance we will count is the sum of the horizontal and vertical distances. This is sometimes
called the city block distance or Manhattan distance. h2 is also admissible because all any move can do
is move one tile one step closer to the goal. Tiles 1 to 8 in the start state give a Manhattan distance of
h2 = 3+1 + 2 + 2+ 2 + 3+ 3 + 2 = 18
• As expected, neither of these overestimates the true solution cost, which is 26.

The effect of heuristic accuracy on performance:


• One way to characterize the quality of a heuristic is the effective branching factorb*. If thetotal number of
nodes generated by A* for a particular problem is N and the solution depth is d, then b* is the branching factor
that a uniform tree of depth d would have to have in order to contain N + 1 nodes. Thus,
𝑁 + 1 = 1 + 𝑏∗ + (𝑏∗ )2 + ⋯ + (𝑏 ∗ )𝑑

Generating admissible heuristics from relaxed problems:


• We have seen that both h1 (misplaced tiles) and h2 (Manhattan distance) are fairly good heuristics for the 8-
puzzle and that h2 is better. How might one have come up with h2? Is it possible for a computer to invent such
a heuristic mechanically?
• h1 and h2 are estimates of the remaining path length for the 8-puzzle, but they are also perfectly accurate path
lengths for simplified versions of the puzzle. If the rules of the puzzle
INFORMED (HEURISTIC) SEARCH STRATEGIES ➔ HEURISTIC FUNCTIONS
• If the rules of the puzzle were changed so that a tile could move anywhere instead of just to
the adjacent empty square, then h1 would give the exact number of steps in the shortest
solution.
• Similarly, if a tile could move one square in any direction, even onto an occupied square,
then h2 would give the exact number of steps in the shortest solution.
• A problem with fewer restrictions on the actions is called a relaxed problem.
• The state-space graph of the relaxed problem is a supergraph of the original state space
because the removal of restrictions creates added edges in the graph.
Chapter- 7
Logical Agents
Knowledge–based agents
• The central component of a knowledge-based agent is its
knowledge base, or KB. A knowledge base is a set of sentences.
• Each sentence is expressed in a language called a knowledge
representation language and represents some KNOWLEDGE
REPRESENTATION LANGUAGE AXIOM assertion about the world.
Sometimes we dignify a sentence with the name axiom, when
the sentence is taken as given without being derived from other
sentences.
• Figure 7.1 shows the outline of a knowledge-based agent
program. Like all our agents, it takes a percept as input and
returns an action. The agent maintains a knowledge base, KB,
which may initially contain some background knowledge.
Knowledge–based agents
Knowledge–based agents
• Each time the agent program is called, it does three
things.
• First, it TELLs the knowledge base what it perceives.
• Second, it ASKs the knowledge base what action it
should perform. In the process of answering this query,
extensive reasoning may be done about the current
state of the world, about the outcomes of possible
action sequences, and so on.
• Third, the agent program TELLs the knowledge base
which action was chosen, and the agent executes the
action.
WUMPUS WORLD
▪ The Wumpus world is a simple world example to illustrate the worth of a knowledge-based
agent and to represent knowledge representation..
▪ It was inspired by a video game Hunt the Wumpus by Gregory yob in 1973.
▪ 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.

Following is a sample diagram for representing the Wumpus world. It is showing some
rooms with Pits, one room with Wumpus and one agent at (1, 1) square location of the
world.
There are also some components which
can help the agent to navigate the cave. • The rooms adjacent to the Wumpus room are
These components are given as follows: smelly, so that it would have some stench.
WUMPUS WORLD • The room adjacent to PITs has a breeze, so if
the agent reaches near to PIT, then he will
perceive the breeze.
• There will be glitter in the room if and only if
the room has gold.
• The Wumpus can be killed by the agent if the
agent is facing to it, and Wumpus will emit a
horrible scream which can be heard anywhere
in the cave.
PEAS description of Wumpus world:
PERFORMANCE MEASURE ENVIRONMENT

• +1000 reward points if the agent comes • A 4*4 grid of rooms.


out of the cave with the gold. • The agent initially in room square [1,
• -1000 points penalty for being eaten by 1], facing toward the right.
the Wumpus or falling into the pit. • Location of Wumpus and gold are
• -1 for each action, and -10 for using an chosen randomly except the first square
arrow. [1,1].
• The game ends if either agent dies or • Each square of the cave can be a pit
came out of the cave. with probability 0.2 except the first
square.
ACTUATORS SENSORS
• Left turn, • The agent will perceive the stench if he is in
• Right turn the room adjacent to the Wumpus. (Not
• Move forward diagonally).
• Grab • The agent will perceive breeze if he is in the
• Release room directly adjacent to the Pit.
• Shoot. • The agent will perceive the glitter in the
room where the gold is present.
• The agent will perceive the bump if he walks
into a wall.
• When the Wumpus is shot, it emits a
horrible scream which can be perceived
anywhere in the cave.
• These percepts can be represented as five
element list, in which we will have different
indicators for each sensor.
• 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].
THE WUMPUS WORLD PROPERTIES
• The Wumpus world Properties:
• Partially observable: The Wumpus world is partially observable because the agent can
only perceive the close environment such as an adjacent room.
• Deterministic: It is deterministic, as the result and outcome of the world are already
known.
• Sequential: The order is important, so it is sequential.
• Static: It is static as Wumpus and Pits are not moving.
• Discrete: The environment is discrete.
• One agent: The environment is a single agent as we have one agent only and
Wumpus is not considered as an agent.
EXPLORING THE WUMPUS WORLD:

Now we will explore the Wumpus world and will determine how the agent will
find its goal by applying logical reasoning.

Agent's First step:


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.
Agent's second Step:
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.
AGENT'S THIRD STEP:

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, 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].
Agent's fourth step:
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.
Wumpus-world using propositional.
As in the previous topic we have learned about the wumpus world and how a knowledge-based
agent evolves the world. Now in this topic, we will create a knowledge base for the wumpus world,
and will derive some proves for the Wumpus-world using propositional.
The agent starts visiting from first square [1, 1], and
we already know that this room is safe for the agent.
To build a knowledge base for wumpus world, we will
use some rules and atomic propositions. We need
symbol [i, j] for each location in the wumpus world,
where i is for the location of rows, and j for column
location.
• Atomic proposition variable for Wumpus world:
• Let Pi,j be true if there is a Pit in the room [i, j].
• Let Bi,j be true if agent perceives breeze in [i, j],
(dead or alive).
• Let Wi,j be true if there is wumpus in the
square[i, j].
• Let Si,j be true if agent perceives stench in the
square [i, j].
• Let Vi,j be true if that square[i, j] is visited.
• Let Gi,j be true if there is gold (and glitter) in the
square [i, j].
• Let OKi,j be true if the room is safe.
Some Propositional Rules for the wumpus world:
Representation of Knowledgebase for Wumpus world:
• Following is the Simple KB for wumpus world
when an agent moves from room [1, 1], to
room [2,1]:
➢ Here in the first row, we have mentioned propositional variables for room[1,1], which is showing that
room does not have wumpus(¬ W11), no stench (¬S11), no Pit(¬P11), no breeze(¬B11), no gold (¬G11), visited
(V11), and the room is Safe(OK11).

➢ In the second row, we have mentioned propositional variables for room [1,2], which is showing that there
is no wumpus, stench and breeze are unknown as an agent has not visited room [1,2], no Pit, not visited
yet, and the room is safe.

➢ In the third row we have mentioned propositional variable for room[2,1], which is showing that there is
no wumpus(¬ W21), no stench (¬S21), no Pit (¬P21), Perceives breeze(B21), no glitter(¬G21), visited (V21),
and room is safe (OK21).
Prove that Wumpus is in the room (1, 3)
We can prove that wumpus is in the room (1, 3) using propositional rules which we
have derived for the wumpus world and using inference rule.
Apply Modus Ponens with ¬S11 and R1:
We will firstly apply MP rule with R1 which is ¬S11 → ¬ W11 ^ ¬ W12 ^ ¬ W21,
and ¬S11 which will give the output ¬ W11 ^ W12 ^ W12.
•Apply And-Elimination Rule:
After applying And-elimination rule to ¬ W11 ∧ ¬ W12 ∧ ¬ W21,
we will get three statements:
¬ W11, ¬ W12, and ¬W21.
•Apply Modus Ponens to ¬S21, and R2:
Now we will apply Modus Ponens to ¬S21 and R2 which is
¬S21 → ¬ W21 ∧¬ W22 ∧ ¬ W31, which will give the Output as ¬
W21 ∧ ¬ W22 ∧¬ W31
•Apply And -Elimination rule:
Now again apply And-elimination rule to ¬ W21 ∧ ¬ W22 ∧¬ W31, We will get three
statements:
¬ W21, ¬ W22, and ¬ W31.
•Apply MP to S12 and R4:
Apply Modus Ponens to S12 and R4 which is S12 → W13 ∨. W12 ∨. W22 ∨.W11, we will
get the output as W13∨ W12 ∨ W22 ∨.W11.
•Apply Unit resolution on W13 ∨ W12 ∨ W22 and ¬ W22 :
After applying Unit resolution on W13 ∨ W12 ∨ W22, and ¬W22, we will get W13 ∨ W12 as
output.
•Apply Unit Resolution on W13 ∨ W12 and ¬ W12 :
After Applying Unit resolution on W13 ∨ W12 and ¬ W12, we will get W13 as an output, hence it
is proved that the Wumpus is in the room [1, 3].
THANK YOU

You might also like