A search problem has three parts.
- States. Every situation you could be in. On a map, a state is a place. In this unit, a state is a node name such as S, P, or G.
- Actions. For each state, the legal moves out of it. In this unit, each neighbor listed for a node is one action. If the list says
Q: [R, G], then from Q you can move to R or to G, and nothing else.
- Goal test. A yes or no question you ask about a state: "Is this the goal?" In this unit the goal test is true only at G.
You also need a start state, the place the search begins. Here it is always S.

A drawing alone is not a problem yet. Two people can trace different routes through the same picture of a maze if one thinks a diagonal step is allowed. Writing out the states, actions, and goal test removes that argument.
The order of a neighbor list matters. S: [P, Q] means the search tries P first and Q second. If the list were S: [Q, P], the search could visit nodes in a different order and even return a different path. When a problem gives you a list, you follow the written order exactly. You do not sort it, and you do not skip ahead to the neighbor that "looks closer" to G.

There are no costs on the edges yet. Every move counts as one step, so the length of a path is the number of edges in it. The path S-Q-G has 3 nodes and 2 edges. Always count edges, not nodes.
Quick check 1. In the street map above, what is the start state, what is the goal test, and which actions are available at the bakery, in order? Answers are at the end of the lesson.
Write the street map as a neighbor list, using S for School, B for Bakery, C for Corner store, P for Park, M for Museum, and G for Gym:
S: [B]
B: [C, P]
C: [P]
P: [M]
M: [G]
G: []
List every simple path (a path that never repeats a node) from S to G, with its length.
- From S the only action is B. Every path starts S-B.
- From B there are two actions. Follow C first: S-B-C. From C the only action is P: S-B-C-P. Then P to M to G: S-B-C-P-M-G. That path has 6 nodes, so 5 edges.
- Go back to B and take its second action, P: S-B-P. Then P to M to G: S-B-P-M-G. That path has 5 nodes, so 4 edges.
- There are no other branches, so these are the only two simple paths.
The shortest one is S-B-P-M-G with 4 edges.
Check: read each consecutive pair and confirm it is a listed action. For S-B-P-M-G: S lists B, B lists P, P lists M, M lists G. Every step is legal, and the edge count is one less than the 5 nodes.