AI Programming Lecture 5 Heuristic Search - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

AI Programming Lecture 5 Heuristic Search

Description:

DFS with a depth limit. If solution is not found: Restarts search. ... As DFS needs little memory this is fine. Often the uniformed algorithm of choice. ... – PowerPoint PPT presentation

Number of Views:44
Avg rating:3.0/5.0
Slides: 11
Provided by: richar487
Category:

less

Transcript and Presenter's Notes

Title: AI Programming Lecture 5 Heuristic Search


1
AI ProgrammingLecture 5Heuristic Search
  • Richard Price Simon Worgan
  • School Of Computer Science University Of
    Birmingham
  • msc59rmp, msc74sxw_at_cs.bham.ac.uk

2
Last Week
  • Search with an agenda.
  • Considerations.
  • Potential Problems.

3
Introduction
  • Iterative Deepening
  • Large search spaces.
  • Guided search strategies.

4
Iterative Deepening
  • An extension of Depth First Search (DFS).
  • Uninformed search algorithm.
  • DFS with a depth limit.
  • If solution is not found
  • Restarts search.
  • Increments the limit.
  • Visits nodes repeatedly.
  • As DFS needs little memory this is fine.
  • Often the uniformed algorithm of choice.

5
Large Search Spaces
  • All algorithms discussed so far are uninformed
    search algorithms.
  • Exhaustive search is time expensive.
  • Search spaces can be large
  • 8 puzzle (3 x 3 grid).
  • Chess (8 x 8 board).
  • Go (19 x 19 board).

6
Generating Successors
  • Storing all possible states is unnecessary.
  • Instead generate possible states from the current
    state.
  • Row by row representation.
  • State 1 2 3 4 5 h 7 8 6

1
2
3
4
5
6
7
8
7
Vertical Movements
  • Upward and Downward movement is simple.
  • Simply swap h with the number appearing 3 items
    to the left or right (respectively).
  • define up(state) -gt new
  • lvars a, b, c, d, x
  • if state matches !??a h ?b ?c ?x ??d then
  • a x b c h d -gt new
  • else false -gt new
  • endif
  • enddefine

1
2
3
1
2
3
1 2 3 4 5 6 7 h 8
1 2 3 4 h 6 7 5 8
4
5
6
4
6
8
7
8
7
5
8
Horizontal Movements
  • Moving left or right (legally) is more difficult.
  • Currently our representation is row by row.
  • In a column by column representation moving
    horizontally is easy but vertical movement is
    difficult.
  • We can temporarily switch representations.
  • define exchange(state) -gt newState
  • lvars a, b, c, d, e, f, g, h, i
  • state --gt !?a ?b ?c ?d ?e ?f ?g ?h ?i
  • a d g b e h c f i -gt newState
  • enddefine

1
2
3
1 2 3 4 5 6 7 h 8
1 4 7 2 5 6 3 h 8
4
5
6
8
7
9
Horizontal Movements
  • Using moving upwards and downwards is equivalent
    to moving left and right respectively.

1
2
3
1
4
7
Key C Convert D Draw M Move
1 4 7 2 5 h 3 6 8
4
5
6
C
D
2
5
8
7
8
3
6
M
1
1
2
3
4
1 2 3 4 5 6 h 7 8
C
D
2
7
4
6
5
5
8
3
6
8
7
10
Successor Code
  • define successors4(state) -gt result
  • lvars newState, turnedState
  • down(state) -gt newState try down move
  • if newState then if it works, add to
    successors list
  • newState
  • endif
  • up(state) -gt newState try up move
  • if newState then if it works, add to
    successors list
  • newState
  • endif
  • exchange(state) -gt turnedState switch rows
    and columns
  • down(turnedState) -gt newState try down
    move
  • if newState then
  • if it works, switch rows and columns back and
    add to successors list
  • exchange(newState)
  • endif
  • up(turnedState) -gt newState try up move
  • if newState then
  • if it works, switch rows and columns back and
    add to successors list
Write a Comment
User Comments (0)
About PowerShow.com