Artificial Intelligence: A Visual Learner's Series
Part 2: Search
Many AI problems are about finding a route from where you are to where you want to be.
Problems as maps of states
In one line: Describe every situation the problem can be in and every move between situations, then look for a route to the goal.
[scrambled puzzle] ─slide─▶ [one tile moved] ─slide─▶ … ─▶ [solved]
initial state action → new state goal test
Key terms: states, initial state, actions, transition model, goal test, path cost. Together the states and moves form the state space.
Watch out: State spaces explode. The 8-tile puzzle has about 181,000 reachable states; the 15-tile one about 10 trillion.
Searching without hints
In one line: With no clue where the goal is, the only choice is the order in which you explore.
Breadth-first checks everything one step away, then two, so it finds the shortest route when steps cost the same.
Depth-first dives down one branch before backing up, using little memory.
Uniform-cost search expands the cheapest path so far; iterative deepening reruns depth-first with growing depth limits.
Watch out: Track visited states, or search can bounce between the same two forever.
Searching with a hint: A*
In one line: If you can estimate how far each state is from the goal, explore the promising ones first.
A heuristic is admissible if it never overestimates. Straight-line distance is admissible because no road is shorter than a straight line.
With an admissible heuristic, A* is guaranteed to find the cheapest path.
Watch out: Set h = 0 and A* becomes uniform-cost search. All the speedup comes from the hint.
Improving step by step: local search
In one line: When only the final answer matters, start somewhere and keep making small improvements.
Hill climbing moves to the best neighbor until none is better.
Random restarts and simulated annealing are two ways to escape a false peak.
Used for scheduling, layout and tuning. Training neural networks (Part 7) works the same way, stepping downhill on error.
Playing against an opponent
In one line: Assume your opponent will make the move that's worst for you, and pick the move whose worst case is best.
You (max) pick the highest of
/ | \
Opp Opp Opp each picks the lowest of
3 12 2 4 14 1 final scores
↓ ↓ ↓
3 2 1 → you pick 3
Key terms: minimax; alpha-beta pruning skips branches that can't change the decision; evaluation functions estimate who's winning when you can't search to the end; Monte Carlo tree search estimates positions by simulating many games.
Watch out: Minimax assumes a perfect opponent; the evaluation function is usually the weak spot.
Self-test
Redraw the seven-node tree and number it for breadth-first and depth-first order.
Draw the A* diagram and explain why an overestimating h breaks the guarantee.
Sketch a landscape with three peaks and show where hill climbing could get stuck.