0% found this document useful (0 votes)
11 views

AI Tut Lab2 Search Slides

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)
11 views

AI Tut Lab2 Search Slides

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/ 27

RMIT Classification: Trusted


Artificial Intelligence

Tut/Lab week 2

COSC2129
RMIT Classification: Trusted

Outline

• Search
– Blind search
– Informed search
– Hands-on examples

• Assignment 1 part 1

• Q&A
RMIT Classification: Trusted

Course material

• Book: Artificial Intelligence: A Modern Approach


• Book - TOC of Artificial Intelligence: A Modern
Approach, 4th Global ed.
• AIMA: Pseudo code
• Good practices Python
RMIT Classification: Trusted

Activity 1

• What is Search?
– Search is an exploration of possibilities
RMIT Classification: Trusted

Activity 1

• Give some examples of applications of problem


solving by search.
RMIT Classification: Trusted

Why search?

• Path finding problem


RMIT Classification: Trusted

Why search?

• Path finding problem


RMIT Classification: Trusted

Why search

• 8 puzzle problem
RMIT Classification: Trusted

Problem solving by search

https://www.mdpi.com/1424-8220/18/9/3170
RMIT Classification: Trusted

Search Problems

• A search problem is defined by:


– Possible states (search space)
– Initial state
– Actions
– Transition model
– Goal test
– Path cost
RMIT Classification: Trusted

Activity 2

• What is a state for each of the example above?


• How to represent a state?

• What is a state space?


• How to represent it?
RMIT Classification: Trusted

Search Algorithms

Search Algorithms
RMIT Classification: Trusted

Performance of Search Strategies

• Completeness: Is it guaranteed to find a solution if one exists?


• Optimality: Will it find an optimal solution?
• Time complexity: How many nodes get expanded?
• Space complexity: How much memory is needed?

• Time and space complexity is calculated based on:


– b: Branching factor
– d: Depth of the shallowest goal node
– m: Maximum length of any path in the state space
RMIT Classification: Trusted

Activity 3: Hand-on Practice

• Hand-on slides
RMIT Classification: Trusted

Practice

• Recap Greedy Search: Use heuristics to guide the


search
• Heuristic:
– A heuristic h is defined as h(x) = Estimate of distance
of node x from the goal node.
– Lower the value of h(x), closer is the node from the
goal.
• Strategy: Expand the node closest to the goal state, i.e.
expand the node with a lower h value.
RMIT Classification: Trusted

Practice

• Greedy Search example


Find the path from S to G using greedy search. The heuristic
values h of each node below the name of the node.

https://www.geeksforgeeks.org/search-algorithms-in-ai/
RMIT Classification: Trusted

Practice

• Solution
– Start from S, we can traverse to
A(h=9) or D(h=5). We choose D,
as it has the lower heuristic cost.
– From D, we can move to B(h=4)
or E(h=3). We choose E with a
lower heuristic cost.
– From E, we go to G(h=0). This
entire traversal is shown in the
search tree below.
RMIT Classification: Trusted

Practice

• A* Tree Search
– Heuristic: f(x) = g(x) + h(x)
• Here, h(x), the forward cost, is an estimate of the distance of
the current node from the goal node.
• And, g(x), the backward cost, is the cumulative cost of a
node from the root node.
• Admissibility:

• Strategy: Choose the node with the lowest f(x) value.


RMIT Classification: Trusted

Practice

• A* search: f(x) = g(x) + h(x)

https://www.geeksforgeeks.org/search-algorithms-in-ai/
RMIT Classification: Trusted

Practice

• Solution
RMIT Classification: Trusted

Recap

Search Algorithms
RMIT Classification: Trusted

Project 0

• CS188 Intro to AI - Course Materials


• Tutorial: http://ai.berkeley.edu/tutorial.html
RMIT Classification: Trusted

Activity 4

• PACMAN and Assignment 1 part 1

The game remains one of the highest-


grossing and best-selling games,
generating more than $14 billion in
revenue (as of 2016) and 43 million units in
sales combined, and has an enduring
commercial and cultural legacy, commonly
listed as one of the greatest video games
of all time.

https://en.wikipedia.org/wiki/Pac-Man
RMIT Classification: Trusted

Assignment 1-1: Pacman game

• Pacman in A1-1
– Question 1
– Question 2
– Question 3
– Question 4
– Question 5
– Question 6
– Question 7
– Question 8

http://ai.berkeley.edu/search.html
RMIT Classification: Trusted

Notes
RMIT Classification: Trusted

Notes

• Hint: Each algorithm is very similar. Algorithms for DFS, BFS,


UCS, and A* differ only in the details of how the fringe is
managed.
– Concentrate on DFS, the rest should be relatively
straightforward.
– Implement the depth-first search (DFS) algorithm in the
depthFirstSearch function in search.py.
– To make your algorithm complete, write the graph search
version of DFS, which avoids expanding any already
visited states.
RMIT Classification: Trusted

Question?

You might also like