Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
5 views53 pages

Chapter 02

Chapter 02 of the document discusses various problem-solving strategies in Artificial Intelligence, including uninformed search strategies like breadth-first and depth-first search, as well as informed search strategies such as A* search. It also covers optimization techniques like hill-climbing and adversarial search methods used in games, including minimax and alpha-beta pruning. The chapter emphasizes the importance of state-space problems and the formulation of effective heuristics for achieving optimal solutions.
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)
5 views53 pages

Chapter 02

Chapter 02 of the document discusses various problem-solving strategies in Artificial Intelligence, including uninformed search strategies like breadth-first and depth-first search, as well as informed search strategies such as A* search. It also covers optimization techniques like hill-climbing and adversarial search methods used in games, including minimax and alpha-beta pruning. The chapter emphasizes the importance of state-space problems and the formulation of effective heuristics for achieving optimal solutions.
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/ 53

ARTIFICIAL INTELLIGENCE

Chapter 02:
Solving problems by searching

Outcome: Apply the basic principles, models, and algorithms of Artificial Intelligence to solve problems;
Chapter 02
2.1 Uninformed search strategies
2.1.1 Breadth-first search
2.1.2 Depth-first search
2.2 Informed (Heuristic) search strategies
2.2.1 A* search
2.3 Optimization
2.3.1 Generate and Test
2.3.2 Simple Hill-Climbing
2.3.3 Steepest-Ascent Hill-Climbing
2.4 Adversarial Search
2.4.1 Games
2.4.2 Optimal Decisions in Games
2.4.3 Alpha-Beta Pruning.
state-space problem
A state-space problem consists of
• a set of states;
• a distinguished set of states called the start states;
• a set of actions available to the agent in each state;
• an action function that, given a state and an action, returns a new state;
• a set of goal states, often specified as a Boolean function, goal(s), that is true when s is a goal state; and
• a criterion that specifies the quality of an acceptable solution. For example, any sequence of actions that gets
the agent to the goal state may be acceptable, or there may be costs associated with actions and the agent may
be required to find a sequence that has minimal total cost. This is called an optimal solution. Alternatively, it may
be satisfied with any solution that is within 10% of optimal.
Well-defined problems and solutions

• 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.
• Actions: The simplest formulation defines the actions as movements of the blank space Left, Right, Up, or Down. Different
subsets of these are possible depending on where the blank is.
• Transition model: Given a state and action, this returns the resulting state; for example, if we apply Left to the start state
in Figure, the resulting state has the 5 and the blank switched.
• Goal test: This checks whether the state matches the goal configuration shown in Figure. (Other goal configurations are
possible.)
• Path cost: Each step costs 1, so the path cost is the number of steps in the path.
2.1 Uninformed search strategies
• Breadth-first search
• Depth-first search
• State Representation and Initial State – we will represent a state of the problem as a tuple (x, y) where x
represents the amount of water in the 4-gallon jug and y represents the amount of water in the 3-gallon jug.
Note 0 ≤ x ≤ 4, and 0 ≤ y ≤ 3. Our initial state: (0,0)
• Goal Predicate – state = (2,y) where 0 ≤ y ≤ 3.
Farmer Fox Cabbage Goat- State
Representation
• State description:( <side for farmer>, <side for wolf>, <side for goat>, <side for cabbage> )

• Initial state: ( w, w, w, w ) – All participants begin on the west bank of the river.

• Final (goal) state: ( e, e, e, e ) – All participants end on the east bank of the river.

• Loss (dead) states:


• ( e, w, w, e ) – The wolf eats the goat.
• ( w, e, e, w ) – The wolf eats the goat.
• ( e, e, w, w ) – The goat eats the cabbage.
• ( w, w, e, e ) – The goat eats the cabbage.
• ( e, w, w, w ) – The goat eats the cabbage and the wolf eats the goat.
• ( w, e, e, e ) – The goat eats the cabbage and the wolf eats the goat.
2.2 Informed (Heuristic) search strategies

• A heuristic is a function that estimates how close a state is to a goal


state.

Example: The Travelling Salesman Problem


Informed (Heuristic) search strategies
Consider the problem of the delivery robot finding a path from location o103 to location r123 in the
domain. The figure shows the resulting graph where the nodes represent locations and the arcs represent
possible single steps between locations. In this figure, each arc is shown with the associated cost of
getting from one location to the next.
Informed (Heuristic) search strategies

There are three paths from o103 to r123:

If o103 were a start node and r123 were a goal node, each of these three paths would be a solution to
the graph-searching problem.
⟨o103, o109, o119, o123, r123⟩
⟨o103, b3, b4, o109, o119, o123, r123⟩
⟨o103, b3, b1, b2, b4, o109, o119, o123, r123⟩
Informed (Heuristic) search strategies

h(mail) = 26 h(ts) = 23 h(o103) = 21


h(o109) = 24 h(o111) = 27 h(o119) = 11
h(o123) = 4 h(o125) = 6 h(r123) = 0
h(b1) = 13 h(b2) = 15 h(b3) = 17
h(b4) = 18 h(c1) = 6 h(c2) = 10
h(c3) = 12 h(storage) = 12
Consider using A* search
• The frontier is initially [o10321], because h(o103)=21 and the cost of
the path is zero. It is replaced by its neighbors, forming the frontier
• [b321, ts31,o10936].
• Next b3 is selected and replaced by its neighbors, forming the
frontier
• [b121, b429, ts31, o10936].
• Then the path to b1 is selected and replaced by its neighbors, forming
the frontier
• ……….
A* applications
• Pathing/routing problems
• Video games
• Robot motion planning
• Machine translation
• Speech recognition
2.3 Optimization
2.3.1 Generate and Test
2.3.2 Simple Hill-Climbing
2.3.3 Steepest-Ascent Hill-Climbing
Generate and Test
1. Generate a possible solution
2. Test whether it is actually a solution by comparing to the set of
acceptable states.
3. If a solution found quit else go to step1.
Simple Hill Climbing
• It examines the neighboring nodes one by one and selects the first neighboring node
which optimizes the current cost as next node.
• Step 1 : Evaluate the initial state. If it is a goal state then stop and return success.
Otherwise, make initial state as current state.
• Step 2 : Loop until the solution state is found or there are no new operators present
which can be applied to current state.
a) Select a state that has not been yet applied to the current state and apply it
to produce a new state.
b)Perform these to evaluate new state
i. If the current state is a goal state, then stop and return success.
ii. If it is better than the current state, then make it current state and proceed further.
iii. If it is not better than the current state, then continue in the loop until a solution is found.
• Step 3 : Exit.
Steepest-Ascent Hill climbing
• It first examines all the neighboring nodes and then selects the node closest to the
solution state as next node.

• Step 1 : Evaluate the initial state. If it is goal state then exit else make the current state as
initial state
Step 2 : Repeat these steps until a solution is found or current state does not change
• i. Let ‘target’ be a state such that any successor of the current state will be better than it;
• ii. for each operator that applies to the current state
a. apply the new operator and create a new state
b. evaluate the new state
c. if this state is goal state then quit else compare with ‘target’
d. if this state is better than ‘target’, set this state as ‘target’
e. if target is better than current state set current state to Target
• Step 3 : Exit
Hill Climbing: Disadvantages
• Localmaximum
A state that is better than all of its neighbours, but not better than
some other states far away.
Hill Climbing: Disadvantages
• Plateau
A flat area of the search space in which all neighbouring states have
the same value.
Hill Climbing: Disadvantages
• Ridge
The orientation of the high region, compared to the set of available
moves, makes it impossible to climb up. However, two moves
executed serially may increase the height.
Example

Global heuristic: For each block that has the


correct support structure: +1to every block in
the support structure. For each block that has
a wrong support structure: −1to every block in
the support structure

Local heuristic: +1for each block that is resting on the thing it is


supposed to be resting on. −1for each block that is resting on a
wrong thing.
Example
Propose a heuristic function h for solving this
problem.
• A heuristic is a function that estimates how close a state is to a goal
state.
• Specify the form of state descriptions, the starting state, and the goal state for this problem.

• 2. Propose a heuristic function h for solving this problem.


• City-block/Manhattan distance: sum of the absolute i and j distances of all tiles from their goal positions
• 3. Use the A ∗ algorithm to find a solution path
2.4 Adversarial Search
2.4.1 Games
2.4.2 Optimal Decisions in Games
2.4.3 Alpha-Beta Pruning.
Games

Kinds of Games

• Deterministic
• Turn-taking
• 2-player
• Zero-sum
• Perfect information
Games vs. search problems
• "Unpredictable" opponent → specifying a move for every
possible opponent reply

• Time limits → unlikely to find goal, must approximate


Game as Search Problem
• Initial State: board position and player to move
• Successor Function: returns a list of legal (move, state) pairs
• Terminal Test: determines when the game is over
• Utility function: Gives a numeric value for the terminal state
Game Trees
• Game trees are used to represent two-player games.
• Alternate moves in the game are represented by alternate
levels in the tree (plies).
• Nodes in the tree represent positions.
• Edges between nodes represent moves.
• Leaf nodes represent won, lost or drawn positions.
Assumptions
• In talking about game playing systems, we make a number of
assumptions:
• The opponent is rational – will play to win.
• The game is zero-sum – if one player wins, the other loses.
• Usually, the two players have complete knowledge of the game.
Minimax
• Minimax is a method used to evaluate game trees.
• A static evaluator is applied to leaf nodes, and values are passed back
up the tree to determine the best score the computer can obtain
against a rational opponent.
Minimax Function
• MINIMAX-VALUE(n) =
• UTILITY(n) if n is a terminal state
• maxs  Successors(n) MINIMAX-VALUE(s) if n is a MAX node
• mins  Successors(n) MINIMAX-VALUE(s) if n is a MIN node
Minimax example
• Perfect play for deterministic games
• Minimax Decision at root: choose the action that lead to a maximal
minimax value
• MAX is guaranteed for a utility which is at least the minimax value
– if he plays rationally.
Minimax algorithm
Searching Game Trees
• Exhaustively searching a game tree is not usually a good idea.
• Even for a game as simple as tic-tac-toe there are over 350,000
nodes in the complete game tree.
• An additional problem is that the computer only gets to choose
every other path through the tree – the opponent chooses the
others.
Game tree (2-player, deterministic, turns)
α-β Pruning
• Can we improve search by reducing the size of the game tree to be
examined?

→ Yes!!! Using alpha-beta pruning

Principle
– If a move is determined worse than another move already examined, then there is
no need for further examination of the node.
α-β Pruning Example
Alpha-Beta Pruning Example

3 0 <=2

α α

3 >=5 0 2

β
Example
Example
5
5 3

5 3

5 6 3 7
α

5 6 3
5 0 6 1 3 2 4 7
β
• α = the value of the best (highest-value) choice we have found
so far at any choice point along the path for MAX
• β = the value of the best (lowest-value) choice we have found
so far at any choice point along the path for MIN
State-of-the-Art
Checkers: Tinsley vs. Chinook

World champion for over 40


years

Mr. Tinsley suffered his 4th and 5th losses against Chinook
Chess: Kasparov vs. Deep Blue
Kasparov Deep Blue

5’10” Height 6’ 5”
176 lbs Weight 2,400 lbs
34 years Age 4 years
50 billion neurons Computers 32 RISC processors
+ 256 VLSI chess engines
2 pos/sec Speed 200,000,000 pos/sec
Extensive Knowledge Primitive
Electrical/chemical Power Source Electrical
Enormous Ego None

1997: Deep Blue wins by 3 wins, 1 loss, and 2 draws


Chess: Kasparov vs. Deep Junior

Deep Junior

8 CPU, 8 GB RAM, Win 2000


2,000,000 pos/sec
Available at $100

August 2, 2003: Match ends in a 3/3 tie!


Othello: Murakami vs. Logistello

Takeshi Murakami
World Othello Champion

1997: The Logistello software crushed Murakami


by 6 games to 0
• Developed by Google DeepMind in London to play the board
game Go.
• Plays full 19x19 games
• October 2015: the distributed version of AlphaGo defeated the
European Go champion Fan Hui - five to zero
• March 2016 AlphaGo played South Korean professional Go player Lee
Sedol, ranked 9-dan, one of the best Go players – four to one.
• A significant breakthrough in AI research!!!

You might also like