Try it
Change where things start or what the goal is, and the plan redraws. Each action only happens if its needs are met, so the planner has to set things up in the right order.
Starting state
Goal
What the character can do
How it works
The world is a short list of numbers: where someone is, how much energy they have, how many slices of bread are in the fridge. An action has needs, like being at the market with at least 3 coins, and effects, like setting a value, adding to it or taking from it. If an effect would take a number below zero, the action can’t happen.
The planner tries actions from the starting state, keeps track of every situation it has already reached, and stops at the shortest list of steps that meets the goal. To decide what to try first, it uses his scoring rule: an action earns a point for touching something the goal cares about, and another for pushing it the right way.
The world states, the six kinds of needs, the three kinds of effects, the action list and the scoring rule are his, along with Jon’s sandwich scenario from his test file. His planning step was still marked unfinished in his code, so the search that strings actions into a full plan was finished here, following the way he had set it up.