CO2301 Games Development 1 Week 9 Bestfirst Search, Dijkstra's Algorithm - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

CO2301 Games Development 1 Week 9 Bestfirst Search, Dijkstra's Algorithm

Description:

A heuristic evaluation function which uses the information gathered by the ... A heuristic that attempts to predict how close the end of a path is to a solution. ... – PowerPoint PPT presentation

Number of Views:55
Avg rating:3.0/5.0
Slides: 20
Provided by: gjbel
Category:

less

Transcript and Presenter's Notes

Title: CO2301 Games Development 1 Week 9 Bestfirst Search, Dijkstra's Algorithm


1
CO2301 - Games Development 1Week 9Best-first
Search,Dijkstra's Algorithm
  • Gareth Bellaby

2
  • Topic 1
  • Introduction to best-first searches

3
Reminder about Heuristic
  • Heuristic a rule of thumb.
  • A directed search which should help to reduce the
    size of the search tree.
  • Need an evaluation function which generates a
    numerical value.
  • Manhattan Distance. The Manhattan Distance is the
    absolute distance from a location to the goal,
    measured square by square.

4
Best first searches and best-first search
  • A bit confusing but...
  • Used to refer to a particular search algorithm.
  • Used by some to refer to the class of algorithms
    that direct the search by some notion of the best
    node.

5
Best first searches
  • Two considerations
  • A heuristic evaluation function which uses the
    information gathered by the search up to that
    point.
  • Cost to get to the current node.
  • A heuristic that attempts to predict how close
    the end of a path is to a solution.
  • Estimation of the distance from the
  • current node to the goal.

6
Best first searches
  • Examples include
  • Best first (estimate of distance to goal)
  • Dijkstra's algorithm (cost)
  • A algorithm (cost estimate)

7
  • Topic 2
  • The Best-first Algorithm

8
Best first search algorithm
  • Order the search on the basis of the most
    preferred nodes.
  • Keep a record of all moves.
  • Select the current best state.
  • Similar to hill climbing but always selects the
    best available move.
  • Open is a priority queue.

9
Best first search algorithm
  • 1) Create OpenList and ClosedList
  • 2) Push the initial state (start) on to OpenList,
    set its parent to 0 and calculate its score
    using the heuristic value.
  • 3) Until a goal state is found or OpenList is
    empty do
  • (a) Pop the first (best) element from OpenList
    and call it 'current'.
  • (b) If OpenList was empty, return failure and
    quit.
  • (c) If 'current' is the goal state, return
    success, construct the path and quit.
  • (d) For each rule that can match 'current' do
  • i) Apply the rule to generate a new state and
    calculate its heuristic value.
  • ii) If the new state has not already been
    visited, set its parent to 'current' and push the
    new state on to OpenList (using the heuristic
    value to order the list)
  • (e) Add 'current' to ClosedList

10
  • Topic 3
  • Dijkstra's algorithm

11
Dijkstra's algorithm
  • See "algorithms.doc" on the web site for the
    actual algorithm. It's too long to put up in
    PowerPoint presentation.
  • However, it's not difficult to explain.
  • Note that the of open list is a priority queue.

12
Dijkstra's algorithm
  • Draw out the graph and all the costs.
  • (You can calculate costs as you generate the
    tree but must ensure alternative paths are
    explored unless demonstrable higher cost)
  • Set current to the start position.
  • While current is not the goal
  • Expand current and calculate cost to all of the
    immediately succeeding nodes (i.e. the children
    of current).
  • Set current to the best node that hasn't already
    been visited.

13
Shortest road distance
3
7, 8
4
2
6
3
3
5
13,12
4
9,8
5
3
2
4
10
4
14
Map
15
Layout the waypoints
16
Turn into graph
17
Add costs (the distances)
4
8
4
4
4
5
5
1
3
4
3
18
Solve
4
8
4
4
4
5
5
1
3
4
3
19
Dijkstra's algorithm
  • Use a priority queue for the open list.
  • The node popped from the list is the one which
    currently the best, i.e. the node with the lowest
    cost.
  • If a lower cost is found to a node, then set the
    cost to the node to this lower value.
  • Can't revisit nodes.
Write a Comment
User Comments (0)
About PowerShow.com