State-space search is the problem-solving method that represents a task as a set of states connected by actions and finds a solution by systematically exploring paths from an initial state to a state that satisfies a goal test. It is one of the foundational techniques of symbolic AI & reasoning, where problems are described with explicit symbols rather than learned numerical patterns.
The idea underlies puzzle solvers, route planners, classical planning systems, theorem provers and game-playing programs. Its strength is generality: once a problem is formulated as states, actions and a goal, the same family of algorithms can solve it. Its central weakness is combinatorial explosion, because the number of reachable states often grows exponentially with the depth of the search.
How a state-space search problem is formulated
A state-space search problem is defined by five formal components that together describe everything an algorithm needs to know. The quality of this formulation usually matters more than the choice of algorithm, because a poor state representation can make an easy problem intractable.
The table below lists the components and what each one contributes to the search.
| Component | Meaning | Example in route finding |
|---|---|---|
| Initial state | The configuration where search begins | The starting city |
| Actions | Operators applicable in a given state | Drive along a road |
| Transition model | The state that results from an action | Arrival at the neighboring city |
| Goal test | Condition that marks a solution | Current city equals destination |
| Path cost | Numeric cost accumulated along a path | Total distance in kilometers |
The states and transitions form an implicit graph that is rarely stored in full. Instead, the algorithm generates successor states on demand through a process called node expansion. A search tree records the paths explored so far, and the frontier (also called the open list) holds the nodes generated but not yet expanded.
Two numbers describe the size of the problem: the branching factor b, which is the average number of successors per state, and the solution depth d. A naive tree search may generate on the order of b to the power of d nodes, which explains why a puzzle with only a few legal moves per step can still produce billions of states.
Uninformed and informed search strategies
A search strategy is the rule that decides which frontier node to expand next, and it determines the completeness, optimality and resource use of the search. Strategies fall into two broad groups. Uninformed search uses only the problem definition, while informed search adds a heuristic function h(n) that estimates the remaining cost to the goal.
The following comparison summarizes the classical algorithms and their properties.
| Algorithm | Frontier order | Complete | Optimal | Memory use |
|---|---|---|---|---|
| Breadth-first search | First in, first out | Yes, if b is finite | Yes, with unit costs | Exponential in depth |
| Depth-first search | Last in, first out | No in infinite spaces | No | Linear in depth |
| Uniform-cost search | Lowest path cost g(n) | Yes, with positive costs | Yes | Exponential |
| Iterative deepening | Repeated depth-limited passes | Yes | Yes, with unit costs | Linear in depth |
| Greedy best-first | Lowest heuristic h(n) | No | No | Exponential |
| A* search | Lowest f(n) = g(n) + h(n) | Yes | Yes, with admissible h | Exponential |
A* search is the most widely taught informed method. It is optimal when the heuristic is admissible, meaning it never overestimates the true remaining cost, and it expands no more nodes than necessary when the heuristic is also consistent. For problems where memory is the binding constraint, IDA* and recursive best-first search trade repeated work for a small memory footprint.
Designing heuristics and controlling the search
A heuristic is an inexpensive estimate of distance to the goal, and its accuracy largely determines search efficiency. A common way to derive admissible heuristics is to solve a relaxed problem in which some constraints are removed, such as allowing tiles in the 8-puzzle to move through one another. Pattern databases precompute exact costs for subproblems and are among the strongest heuristics for permutation puzzles.
Beyond the heuristic, several practical techniques reduce wasted effort. The table below matches typical problems in a search implementation with their usual remedies.
| Symptom | Likely cause | Remedy |
|---|---|---|
| The same state is expanded repeatedly | No duplicate detection | Keep a closed set or hash table of visited states |
| Memory is exhausted early | Breadth-first or A* on a deep problem | Use iterative deepening or IDA* |
| Search never terminates | Infinite paths in depth-first order | Add a depth limit or cycle checking |
| Solutions are found but are poor | Greedy or inadmissible heuristic | Switch to A* with an admissible heuristic |
| Progress is slow from both ends | Very large branching factor | Try bidirectional search |
Another important distinction is between tree search and graph search. Tree search ignores repeated states and can loop or duplicate work; graph search records explored states, which costs memory but avoids exponential redundancy in spaces with many cycles, such as grid maps.
How it relates to planning, games and logic
State-space search is the common engine behind several neighboring techniques in symbolic AI. In classical planning, languages such as STRIPS and PDDL describe states as sets of logical facts and actions as operators with preconditions and effects, and forward or backward search then explores the resulting space. In adversarial search, a game tree is a state space where players alternate, and minimax with alpha-beta pruning replaces the single-agent goal test with an evaluation of outcomes.
The following table shows how the same core idea adapts to different settings.
| Area | What a state represents | Typical search method |
|---|---|---|
| Puzzle solving | A board configuration | A* or IDA* with pattern databases |
| Classical planning | A set of true facts | Forward search with domain-independent heuristics |
| Game playing | A position plus the player to move | Minimax with alpha-beta pruning |
| Theorem proving | A set of derived clauses | Resolution guided by selection strategies |
| Constraint satisfaction | A partial variable assignment | Backtracking with constraint propagation |
Means-ends analysis, used by the General Problem Solver, can also be seen as a goal-directed search strategy that selects actions reducing the difference between the current state and the goal.
Limitations and common misconceptions
The method is powerful but has clear boundaries that experienced practitioners keep in mind when choosing it.
- Exponential growth is unavoidable in general. Good heuristics reduce the effective branching factor but do not remove worst-case explosion.
- Optimality depends on the heuristic. A* with an overestimating heuristic may return a suboptimal path without any warning.
- Classical formulations assume full observability and determinism. Uncertain or partially observable environments need belief-state search or probabilistic planning.
- The state space is not the search tree. A small graph with cycles can unfold into an infinite tree without duplicate detection.
- Search is not obsolete in modern AI. Learned models are increasingly combined with tree search, for example in Monte Carlo tree search guided by neural networks.
Put simply
State-space search is a careful way of trying options. Imagine you are lost in a city with a paper map. Each street corner is a state. Each street you can walk down is an action. Your hotel is the goal.
A simple searcher checks every corner close by before going farther. A smarter searcher uses a hint, such as the straight-line distance to the hotel, and tries the most promising streets first. Both approaches eventually find the way. The difference is how much walking is wasted. The main problem is that the number of possible routes can become enormous very quickly.
In practice
A warehouse operator uses mobile robots to move shelves across a floor divided into a grid of about 5,000 cells. The routing software formulates each robot’s task as a state-space search. A state is the robot’s cell and heading, actions are moving forward or turning, and the path cost combines distance with a penalty for turns, because turning takes extra time.
The engineers use A* search with a Manhattan-distance heuristic, which never overestimates the remaining travel on a grid and therefore guarantees shortest paths. A closed set prevents the robot from revisiting cells. Typical queries expand a few hundred nodes and finish in well under a millisecond. When the team later added time as a state dimension to avoid collisions, the space grew sharply, and they switched to a reservation table and a time-bounded search to keep planning fast enough for dozens of robots.