Module3_1 - Copy
Module3_1 - Copy
✓ Class Outline
1 Introduction to Searching
4 Game Playing
Introduction to Searching
Searching
- it is the process of getting appropriate or the required state or
node (goal state) among the possible states.
Problem Formulation
Search problem is defined in terms of ⃝
1 states (initial state and
goal) and ⃝2 operators (transition model).
States (initial and goal states)
is a representation of problem elements at a given instance. it
contains all of the information necessary to predict the effects of
an action and to determine if it is a goal state.
✓ initial state: is the state where the agent starts in. A sequence
of states connected by the sequence of actions is path.
✓ goal state: is a state where the agent may end the search.
Operators
An operator is an action that transforms one state into another
state. In general, not all operators can be applied in all states.
Introduction to Searching...
Search Techniques/Algorithms
⃝
B Solve the problem to find G from S bellow:
⃝
✓ Solution to the problem finding G from S above:
Depth-Limited Search
¬ Breadth-First Search (BFS) algorithm has computational
complexity (space)
¬ whereas Depth-First Search (DFS) has run off down problem
for a very deep rooted data-structure.
Depth-Limited Search
¬ Step#1
✓ VN : [ _ ]
✓ PN : [ _ ]
¬ Step#2 ¬ Step#3
✓ VN : [ Source ] ✓ VN : [ Source, A ]
✓ PN : [ A, B, C ] ✓ PN : [ B, G, C ]
Uninformed Search Techniques...
Cost Uniform Search Problem:
¬ Step#4 ¬ Step#5
✓ VN : [ Source, A, B ] ✓ VN : [ Source, A, B, G ]
✓ PN : [ G, C, F ] ✓ PN : [ C, F ]
Uninformed Search Techniques...
Cost Uniform Search Problem:
¬ Step#6 ¬ Step#7
✓ VN : [ Source, A, B, G, C ] ✓ VN : [ Source, A, B, G, C, E ]
✓ PN : [ E, F ] ✓ PN : [ Dest, F ]
Uninformed Search Techniques...
Cost Uniform Search Problem:
¬ Step#8 ¬ Step#9
✓ VN : [ Source, A, B, G, C, E, F ] ✓ VN : [ Source, A, B, G, C, E,
✓ PN : [ Dest ] F, Dest ] ✓ PN : [ _ ], Cost: 8
Uninformed Search Techniques...
Solution:
- With the use of bidirectional search, or by moving in
different directions, we can improve this problem.
Informed Search Techniques
Simulated Annealing
- A hill-climbing algorithm which never makes a move
towards a lower value guaranteed to be incomplete because it
can get stuck on a local maximum.
- if algorithm applies a random walk, by moving a successor,
then it may complete but not efficient.
- Simulated Annealing is an algorithm which yields both
efficiency and completeness.
Informed Search Techniques
Simulated Annealing...
- Mechanically, annealing is a process of hardening a metal or
glass to a high temperature then cooling gradually,
- This allows the metal to reach a low-energy crystalline state.
- The similar method is applied in simulated annealing where
the search algorithm picks a random move, instead of picking
the best move.
- If the random move improves the state with higher value, then
it follows the same path.
- Otherwise, the algorithm follows the path which has a
probability of less than 1 or it moves downhill and chooses
another path.
Informed Search Techniques
N@C
↓
N@J
↓
N@K
↓
N@M
Informed Search Techniques
A* Search/Algorithm
- It is the most commonly known form of best-first search.
- It uses heuristic function – h(n), and cost to reach the node n
from the start state – g(n).
- It has combined features of UCS and greedy best-first search,
by which it solve the problem efficiently.
- A* search algorithm finds the shortest path through the
search space using the heuristic function.
- This search algorithm expands less search tree and provides
optimal result consuming lesser time.
- A* algorithm is similar to UCS except that it uses g(n) + h(n)
instead of g(n).
Informed Search Techniques
A* Search/Algorithm...
- In A* search algorithm, we use search heuristic as well as the
cost to reach the node.
- Hence we can combine both costs as following, and this sum
is called as a fitness number.
- It defines the evaluation function f (n) = g(n) + h(n) where,
h(n) is heuristics function and g(n) is the past knowledge
acquired while searching.
Informed Search Techniques
Steps in A* Search/Algorithm...
Step#1: Place the starting node in the OPEN list.
Step#2: Check if the OPEN list is empty or not, if the list is
empty then return failure and stops.
Step#3: Select the node from the OPEN list which has the
smallest value of evaluation function (g + h), if node n
is goal node then return success and stop, otherwise.
Step#4: Expand node n and generate all of its successors, and
put n into the closed list. For each successor n’, check
whether n’ is already in the OPEN or CLOSED list, if
not then compute evaluation function for n’ and place
into Open list.
Step#5: Else if node n’ is already in OPEN and CLOSED, then
it should be attached to the back pointer which reflects
the lowest g(n′ ) value.
Step#6: Return to Step 2.
Informed Search Techniques
A* Search Algorithm: Problem
¬ Solve the problem start node:N@C and goal node:N@M
Informed Search Techniques
A* Algorithm: Solution
Adversarial Search
- Previously studied search strategies are associated with only
one single agent to find the solution – which often expressed
in the form of a sequential actions.
- However, it might have some situations where more than one
agent is searching for the solution in same search space, and
this situation usually occurs in game playing.
- The environment with more than one agent is termed as
multi-agent environment, in which each agent is an opponent
of other agent and playing against each other.
Game Playing
Adversarial Search
- Each agent needs to consider the action of other agent and
effect of that action on their performance.
- So, searches in which two or more players with conflicting
goals are trying to explore the same search space for solution
– called adversarial searches – often known as Games.
- Games are modeled as a Search Problem and heuristic
evaluation function, and
- These are the two main factors which help to model and solve
games in AI.
Game Playing
Mini-Max Algorithm
- Mini-Max algorithm is a recursive or backtracking algorithm
used in decision-making and game theory.
- It provides an optimal move for the player assuming that
opponent is also playing optimally.
- The algorithm uses recursion to search through the game-tree.
- Mostly used for game playing in AI; like Chess, Checkers,
tic-tac-toe, go, and various two-players game.
- The algorithm computes minimax decision for current state.
- In two-player game, one is called MAX Node (your move) and
other is called MIN Node (opponent’s move).
Game Playing
Min-Max Algorithm
- Max node: ¬ □ △ and Min node: ¬ ⃝
OR ▽
OR
- Both the players fight as opponent player gets the minimum
benefit while themselves get the maximum benefit.
- Both are opponent of each other; MAX will select the
maximized value, and MIN will select the minimized value.
- Mini-Max algorithm performs a depth-first search (DFS) to
explore the complete game tree.
- Mini-Max algorithm proceeds all the way down to the terminal
node of the tree, then backtrack the tree as recursion.
Game Playing
Step#1
- Firstly, the algorithm generates the entire game-tree and apply
utility function to get utility values for terminal states.
- let’s take A is the initial state of the tree diagram.
- Suppose maximizer takes first turn which has worst-case initial
value = - ∞, and minimizer will take next turn which has
worst-case initial value = + ∞.
Game Playing
Min-Max Algorithm: Example
Game Playing
Alpha-Beta Pruning
- it is a modified version of the mini-max algorithm.
- It is an optimization technique for the mini-max algorithm.
- As seen in the mini-max search algorithm, the number of
game states it has to explore is exponential with depth of the
tree – limitation of Mini-max Algorithm.
- exponent can’t be eliminated, but we can cut it to half.
- Hence there is a technique by which without checking each
node of the game tree we can compute the correct mini-max
decision, and this technique is called Alpha-Beta Pruning.
Game Playing
Alpha-Beta Pruning...
- This involves two threshold parameter Alpha and Beta for
future expansion, so it is called alpha-beta pruning.
- It is also called as Alpha-Beta Algorithm.
- Alpha-Beta pruning can be applied at any depth of a tree, and
often it is not only prune the tree leaves but entire sub-tree.
- The two-parameter can be defined as:
✓ Alpha: The best (highest-value) choice we have found so far at
any point along the path of Maximizer.
The initial value of alpha is −∞.
✓ Beta: The best (lowest-value) choice we have found so far at
any point along the path of Minimizer.
The initial value of beta is +∞.
Game Playing
Alpha-Beta Pruning...
- The Alpha-beta pruning to a standard mini-max algorithm,
- returns the same move as the standard algorithm does;
- but it removes all the nodes which are not really affecting the
final decision but making algorithm slow.
- Hence by pruning these nodes, it makes the algorithm fast.
Alpha-Beta Pruning...
step#2:
- At Node D, the value of α will be calculated (turn for Max).
- The value of α is compared with firstly 2 and then 3, and the
max (2, 3) = 3 will be the value of α at node D and node
value will also 3.
Game Playing