Closed pipex closed 1 year ago
This allows to visualize the planning process as a decision tree for debugging.
For example, the following task definition
import { Planner } from '@mahler/planner'; import { mermaid } from '@mahler/testing'; const inc = Task.of({ condition: (state: number, { target }) => state < target, effect: (state: number) => state + 1, action: async (state: number) => state + 1, description: '+1', }); const byTwo = Task.of({ condition: (state: number, { target }) => target - state > 1, method: (_: number, { target }) => [inc({ target }), inc({ target })], description: '+2', }); const trace = mermaid("find a plan"); const planner = Planner.of<number>({ tasks: [byTwo, inc], config: { trace }, }); // Find a plan to increase from 0 to 3 planner.findPlan(0, 3); // Print diagram console.log(trace.build())
Will print the code to generate the following diagram of the decision tree. The nodes in green joined by the solid arrows are the final plan.
Change-type: minor
I self-certify!
This allows to visualize the planning process as a decision tree for debugging.
For example, the following task definition
Will print the code to generate the following diagram of the decision tree. The nodes in green joined by the solid arrows are the final plan.
Change-type: minor