artificial intelligence for games uninformed search patrick olivier [email protected]
TRANSCRIPT
Artificial Intelligence for Games
Uninformed search
Patrick Olivier
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
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
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