290 likes | 409 Vues
This overview explores uninformed search strategies used in artificial intelligence, specifically within the context of game problem-solving. It delves into various algorithms, such as breadth-first search, depth-first search, and other techniques to find optimal pathways, analyze time complexity, and evaluate space complexity. Through practical examples, including holiday planning in Romania and puzzle solving, we illustrate the application of these algorithms in state-space exploration. The content emphasizes the strengths and weaknesses of each strategy, offering insights into their implementation and effectiveness.
E N D
Artificial Intelligence for GamesUninformed search Patrick Olivier p.l.olivier@ncl.ac.uk
Example: Romanian holiday • On holiday in Romania (currently in Arad) • Flight leaves tomorrow from Bucharest • Formulate goal: • be in Bucharest • Formulate problem: • states: various cities • actions: drive between cities • Find solution: • sequence of cities, e.g., Arad, Sibiu, Fagaras…
Example: 8 puzzle • states? • locations of tiles • actions? • move blank left, right, up, down • goal test? • goal state (given) • path cost? • 1 per move
Example: robot assembly • states? • joint angles + parts • actions? • joint motions • goal test? • complete assembly • path cost? • time to execute
Example: NPC path planning • states? • discretised world • actions? • character motions • goal test? • destination reached • path cost? • cumulative motion cost
Tree search algorithms • simulated (offline) exploration of state space • generating successors of already-explored states
Search strategies • strategy defined by order of node expansion • strategies evaluated according to: • completeness: always find a solution if one exists? • time complexity: number of nodes generated • space complexity: maximum nodes in memory • optimality: always finds a least-cost solution? • time & space complexity measured in terms of: • b: maximum branching factor of the search tree • d: depth of the least-cost solution • m: maximum depth of the state space (may be ∞)
Uninformed search strategies • only use information in the problem definition (uninformed): • breadth-first search • uniform-cost search • depth-first search • depth-limited search • iterative deepening search • improve using informed search (next week)
Breadth-first search • Expand shallowest unexpanded node • Implementation: fringe is a FIFO queue • add newly expanded nodes to back of queue • expand nodes at the front of the queue
Old queue: [ ] New queue: [A]
Old queue: [A] New queue: [B C]
Old queue: [B C] New queue: [C D E]
Old queue: [C D E] New queue: [D E F G]
Properties of breadth-first search • Complete? • Yes (if b is finite) • Time: • b+b2+b3+… +bd + (bd+1-b) = O(bd+1) • Space: • O(bd+1) …keeps every node in memory • Optimal? • If the cost is the same per step • Space is the problem (more than time)
Depth-first search • Expand deepest unexpanded node • Implementation: fringe is a LIFO queue • add newly expanded nodes to front of queue • expand node at the front of queue
Old queue: [ ] New queue: [A]
Old queue: [A] New queue: [B C]
Old queue: [B C] New queue: [D E C]
Old queue: [D E C] New queue: [H I E C]
Old queue: [H I E C] New queue: [I E C]
Old queue: [I E C] New queue: [E C]
Old queue: [E C] New queue: [J K C]
Old queue: [J K C] New queue: [K C]
Old queue: [K C] New queue: [C]
Properties of depth-first search • Complete? • No – fails in infinite-depth spaces (or with loops) • modify to avoid repeated states along path • complete in finite spaces • Time: • O(bm): bad if m much larger than d of shallowest goal • if solutions are dense, much faster than breadth-first • Space: • O(bm), i.e. linear space • Optimal? • No