Skip to content

Planning Patterns

nick_tsaizer edited this page Apr 25, 2026 · 2 revisions

This page uses small tasks only to show the API shape. The important idea is the planning pattern: the same model scales to domains with many object types, many actions, and many possible valid sequences.

Simple task shape

Use Tensor Planner when you can describe a problem as:

current facts + action rules + goal facts => ordered plan

For a tiny task, the domain might have one relation and one action:

action do_step(actor, from, to)
requires:
  at(actor, from)
  connected(from, to)
removes:
  at(actor, from)
adds:
  at(actor, to)

The state supplies concrete objects and current facts:

at(actor_a, state_a)
connected(state_a, state_b)
goal at(actor_a, state_b)

The result is a plan step with real typed arguments, so your application can execute it in its own runtime.

Undirected relation helper

Wrappers provide an edge helper for common two-way relationships:

edge(connected, state_a, state_b)

This means both facts are true:

connected(state_a, state_b)
connected(state_b, state_a)

Use a normal fact for one-way relationships.

Larger task shape

For larger domains, define actions as reusable rules instead of writing scripts for every possible sequence:

action acquire(actor, item, place)
requires:
  at(actor, place)
  available_at(item, place)
adds:
  has(actor, item)

action produce(actor, output, input_a, input_b)
requires:
  has(actor, input_a)
  has(actor, input_b)
  recipe(output, input_a, input_b)
adds:
  has(actor, output)

Then ask for a goal:

goal has(actor, target_item)

The planner searches through available actions and current facts to discover the needed intermediate steps. If the world changes, you update facts and solve again instead of rewriting procedural logic.

What this buys you

  • You can add new objects and facts without rewriting control flow.
  • You can add new action rules and let the solver combine them.
  • You can ask whether a goal is reachable from the current state.
  • You can inspect or execute the returned plan step by step.
  • You can export tensor-shaped planner data for scoring or analysis.

The snippets are deliberately small so the API is easy to read. Real value comes from using the same model in domains where the number of possible action sequences is too large or too dynamic to hard-code safely.

Clone this wiki locally