Evaluation function Cost function g g Evaluation function Cost function � expand vertex minimizing expand vertex minimizing � actual cost from actual cost from s s to to v v along the cheapest path along the cheapest path � � found so far found so far f ( f ( v v ) = ) = g g ( ( s s ~> ~> v v ) + ) + h h ( ( v v ~> ~> r r ) ) � exact cost if exact cost if G G is a tree is a tree � � g g ( ( s s ~> ~> v v ) estimates the minimum cost from the ) estimates the minimum cost from the � � can never underestimate the cost if can never underestimate the cost if G G is a general is a general start vertex to v v � start vertex to graph graph � h h ( ( v v ~> ~> r r ) estimates (heuristically) the cost from ) estimates (heuristically) the cost from v v � � f f ( ( v v ) = ) = g g ( ( s s ~> ~> v v ) and unit cost ) and unit cost � to the goal vertex to the goal vertex → breadth → breadth- -first search first search � if we had exact evaluation function if we had exact evaluation function f f * * , we could , we could � � f f ( ( v v ) = ) = – – g g ( ( s s ~> ~> v v ) and unit cost ) and unit cost � solve the problem without expanding any solve the problem without expanding any → depth → depth- -first search first search unnecessary vertices unnecessary vertices Heuristic function h h Admissibility Heuristic function Admissibility � let Algorithm A be a best let Algorithm A be a best- -first search using the first search using the � carries information from outside the graph carries information from outside the graph � � evaluation function f evaluation function f � defined for the problem domain defined for the problem domain � � search algorithm is search algorithm is admissible admissible if it finds the if it finds the � � the closer to the actual cost, the less superfluous the closer to the actual cost, the less superfluous � minimal path (if it exists) minimal path (if it exists) vertices are expanded vertices are expanded � if if f f = = f f * * , Algorithm A is admissible , Algorithm A is admissible � � f f ( ( v v ) = ) = g g ( ( s s ~> ~> v v ) → cheapest ) → cheapest- -first search first search � � Algorithm A* = Algorithm A using an estimate Algorithm A* = Algorithm A using an estimate � � f f ( ( v v ) = ) = h h ( ( v v ~> ~> r r ) → best ) → best- -first search first search function h h function � � A* is admissible, if A* is admissible, if h h does not overestimate the does not overestimate the � actual cost actual cost Monotonicity Monotonicity Optimality Optimality � h h is locally admissible → is locally admissible → h h is monotonic is monotonic � Optimality theorem: The first path from Optimality theorem: The first path from s s to to r r � � found by A* is optimal. found by A* is optimal. � monotonic heuristic is also admissible monotonic heuristic is also admissible � � Proof: lecture notes pp. 94 Proof: lecture notes pp. 94- -95 95 � actual cost is never less than the heuristic cost actual cost is never less than the heuristic cost � � → f f will never decrease will never decrease → � monotonicity → A* finds the shortest path to monotonicity → A* finds the shortest path to � any vertex the first time it is expanded any vertex the first time it is expanded � if a vertex is rediscovered, path will not be shorter if a vertex is rediscovered, path will not be shorter � � simplifies implementation simplifies implementation � 1
Informedness Algorithm A* Informedness Algorithm A* * , the better � the more closely the more closely h h approximates approximates h h * , the better � because of monotonicity because of monotonicity � � A* performs A* performs � all weights must be positive all weights must be positive � � if A if A 1 using h h 1 will never expand a vertex that is 1 using 1 will never expand a vertex that is � � closed list can be omitted closed list can be omitted � not also expanded by A 2 not also expanded by A 2 using using h h 2 2 , A , A 1 1 is more is more � the path is constructed from the mapping the path is constructed from the mapping π π � informed that A 2 informed that A 2 starting from the goal vertex starting from the goal vertex � informedness → no other search strategy with informedness → no other search strategy with � � s s → … → → … → π π ( ( π π ( ( π π ( ( r r ))) → ))) → π π ( ( π π ( ( r r )) → )) → π π ( ( r r ) → ) → r r � the same amount of outside knowledge can do less the same amount of outside knowledge can do less work than A* and be sure of finding the optimal work than A* and be sure of finding the optimal solution solution Practical considerations Search algorithms Practical considerations Search algorithms � computing computing h h � depth- -first first depth � despite the extra vertices expanded, less informed despite the extra vertices expanded, less informed h h � may yield computationally less intensive may yield computationally less intensive implementation implementation best- best -first first � suboptimal solutions suboptimal solutions � � by allowing overestimation A* becomes by allowing overestimation A* becomes A* A* � inadmissible, but the results may be good enough for inadmissible, but the results may be good enough for practical purposes practical purposes breadth- -first first breadth Realizing the movement Realizing the movement Recapitulation Recapitulation � movement through the waypoints movement through the waypoints discretization of the game world discretization of the game world � 1. 1. � unrealistic: does not follow the game world geometry unrealistic: does not follow the game world geometry � grid, navigation mesh grid, navigation mesh � � � aesthetically displeasing: straight lines and sharp aesthetically displeasing: straight lines and sharp � waypoints, connections, costs waypoints, connections, costs � � turns turns path finding in a graph path finding in a graph 2. 2. � improvements improvements � Algorithm A* Algorithm A* � � � line line- -of of- -sight testing sight testing � realizing the movement realizing the movement � obstacle avoidance obstacle avoidance 3. 3. � � combining path finding to user combining path finding to user- -interface interface geometric corrections geometric corrections � � � aesthetic improvements aesthetic improvements � real real- -time response time response � � � 2
Alternatives? Alternatives? � Although this is the Although this is the de facto de facto approach in approach in � (commercial) computer games, are there (commercial) computer games, are there alternatives? alternatives? � possible answers possible answers � � AI processors (unrealistic?) AI processors (unrealistic?) � � robotics: reactive agents (unintelligent?) robotics: reactive agents (unintelligent?) � � analytical approaches (inaccessible?) analytical approaches (inaccessible?) � 3
Recommend
More recommend