1 State Space Search

Download as pdf or txt
Download as pdf or txt
You are on page 1of 18

State Space Search

DR. SHWETA SHARMA


State Space Search
Artificial Intelligence (AI) has a major application i.e., PROBLEM SOLVING
How to solve a particular problem? (with Agents)
Eg, Chess game, Tic-Tac-Toe game, Water Jug Problem, 8-Puzzle

AI is the study of building agents that act rationally

Most of the time, these agents perform some kind of search algorithm in
the background in order to achieve their tasks

DR. SHWETA SHARMA, DEPT. OF CSE, PEC CHANDIGARH 2


State Space Search
A search problem consists of:

A State Space. Set of all possible states where you can be.
A Start State. The state from where the search begins.
A Goal Test. A function that looks at the current state returns whether or not it is the
goal state.

The Solution to a search problem is a sequence of actions, called the plan that
transforms the start state to the goal state.
This plan is achieved through search algorithms.

DR. SHWETA SHARMA, DEPT. OF CSE, PEC CHANDIGARH 3


State Space Search
Tuple
T: {S, A, Action (s), Result (s,a), Cost(s,a)}

S- Total number of states (Start, Goal, Intermediate)


3X3 3X3
A- Set of all possible actions
(legal and illegal moves)
(All rules)

Action(s)- selected action


Result(s,a)- Resultant state
Cost(s,a)- e.g., 1 for every move
Searching should be with Minimum cost (best solution)
DR. SHWETA SHARMA, DEPT. OF CSE, PEC CHANDIGARH 4
State Space Search
A state-space defined as a set of all possible states of a problem

A State Space Search representation allows for the formal definition of a


problem that makes the move from the initial state to the goal state

DR. SHWETA SHARMA, DEPT. OF CSE, PEC CHANDIGARH 5


Elements in State Space Search
1. A (possibly infinite) set of states

1.1. Out of the possible states, one state represents the start state that is
the initial state of the problem.

1.2. Each state represents some configuration reachable from the start
state

1.3. Out of the possible states, some states may be goal states (solutions)
DR. SHWETA SHARMA, DEPT. OF CSE, PEC CHANDIGARH 6
Elements in State Space Search
2. A set of rules

2.1. Applying a rule to the current state, transforms it to another or a


new state in the state space

2.2 All operators may not be applicable to all states in the state space
Move space left, right, upward, downward in 8-Puzzle

DR. SHWETA SHARMA, DEPT. OF CSE, PEC CHANDIGARH 7


8-Puzzle

DR. SHWETA SHARMA, DEPT. OF CSE, PEC CHANDIGARH 8


DR. SHWETA SHARMA, DEPT. OF CSE, PEC CHANDIGARH 9
Example 1: Maze

A maze problem can be represented as a state-space

Each state represents “where you are” that is the


current position in the maze

The start state or initial state represents your starting


position
The goal state represents the exit from the maze

DR. SHWETA SHARMA, DEPT. OF CSE, PEC CHANDIGARH 10


Example 1: Maze

Rules (for a rectangular maze) are: move


north, move south, move east, and move west

Each rule takes you to a new state (maze


location)
Rules may not always apply, because of walls
in the maze

DR. SHWETA SHARMA, DEPT. OF CSE, PEC CHANDIGARH 11


Example 2: 15-Puzzle
The start state is some (almost) random
configuration of the tiles and the goal state is as
shown.

State Space Search Rules are:

Move empty space up


Move empty space down
Move empty space right
Move empty space left

These Rules apply if empty space is not against the edge.


DR. SHWETA SHARMA, DEPT. OF CSE, PEC CHANDIGARH 12
General Process followed in solving
problem using State Space Search
1. First, select some way to represent states in the given problem in an
unambiguous way
2. Next, formulate all actions or operators that can be performed in states,
including their preconditions and effects. Actions or operators are called
PRODUCTION RULES
3. Represent the initial state or states of the problem
4. Formulate precisely when a state satisfies the goal of our problem
5. Activate the production rules on the initial state and its descendants, until a
goal state is reached
DR. SHWETA SHARMA, DEPT. OF CSE, PEC CHANDIGARH 13
Types of search algorithms

Blind Search Heuristic Search

Known: Start and goal state only,


Explore and match each state, To quickly solve the problem
Exponentially grow
DR. SHWETA SHARMA, DEPT. OF CSE, PEC CHANDIGARH 14
Uninformed Search (Blind Search)
 Brute force method
 Having no information about the number of steps from the current
state to the goal
 No guidance
– Depth-first
– Breadth-first
– Uniform-cost search
– Iterative deepening
– Bi-directional search

DR. SHWETA SHARMA, DEPT. OF CSE, PEC CHANDIGARH 15


Informed Search (Heuristic Search)

 Use information (i.e., heuristic)


 There is a direction given about the solution
 More efficient than uninformed search

– Best First Search Algorithm (Greedy search)


– A* Search Algorithm

DR. SHWETA SHARMA, DEPT. OF CSE, PEC CHANDIGARH 16


Difference
UNINFORMED INFORMED
Searching without Information Searching with Information
No knowledge about domain/problem Use knowledge to find steps to solution
Time Consuming Consumes less time because of Quick Solution
More Complexity (Time and Space) Less Complexity (Time and Space)
Breadth First Search, Depth First Search A* search, Heuristic, Hill climbing, Best First Search

DR. SHWETA SHARMA, DEPT. OF CSE, PEC CHANDIGARH 17


Thank you!

DR. SHWETA SHARMA, DEPT. OF CSE, PEC CHANDIGARH 18

You might also like