Initial State and Goal States
What you'll learn: How to formally define where a search problem starts and how to recognize when you've reached a valid solution.
The Starting Line and the Finish Line
In any search or AI problem, you need two critical anchors: where you begin and what counts as success. The initial state is your problem's starting configuration—the exact snapshot of the world before you've made any moves. The goal state (or goal states, plural) defines the criteria that, when met, signal you've solved the problem.
Think of a GPS navigation system: your initial state is "currently at 123 Main St," and your goal state is "arrived at 456 Oak Ave." Without both clearly defined, the search algorithm has no direction.
Why These Matter
In the state space you learned about previously—that graph of all possible configurations—these two concepts provide:
- Initial State: The single node where your search algorithm begins exploring
- Goal States: The target node(s) you're trying to reach; sometimes it's one specific state, other times any state satisfying certain conditions (e.g., "any configuration where the chess king is checkmated")
Defining Them Precisely
For a sliding puzzle:
- Initial state: The scrambled tile positions at the start
- Goal state: Tiles arranged in numerical order with the blank in the bottom-right
For pathfinding:
- Initial state: Current coordinates
(x₀, y₀) - Goal state: Target coordinates
(xₙ, yₙ)or "any location with resource type X"
The goal can be explicit (one exact configuration) or implicit (a test function that returns true for any valid solution).
Key Takeaway: Initial and goal states are the boundary conditions of your search problem—the starting point that anchors your exploration and the success criteria that determine when to stop searching.