Symbolic Task Planning
Task planning works with facts, not geometry: "A is on the table", "the hand is empty". Each action lists what must be true before it, its preconditions, and what it changes, its effects. A planner searches for a sequence of actions that turns the starting facts into the goal facts. This is the STRIPS style, still the basis of PDDL planners.
Actions with preconditions and effects
Two actions are enough here. pick(X, Y) needs X clear, X on Y, and the hand empty, then the hand holds X and Y becomes clear. put(X, Y) needs the hand holding X and Y clear, then X is on Y and the hand is empty. The planner searches over states, sets of facts, with breadth-first search, so the first plan it finds is the shortest:
What to notice
To build A on top of a tower, the planner must first take apart what is in the way, so the plan can be longer than it looks. The readout shows how many states it explored. With more blocks, the number of states grows explosively, which is why real planners use heuristics, like A* does. The planner has no idea about geometry: it would happily plan to put a block somewhere it cannot physically reach. Connecting these plans to real motions is the job of task and motion planning, next.