Skip to content

refactor: documentation, bug fixes, test coverage, and GOAP rewrite#1

Open
vantreeseba wants to merge 23 commits into
mainfrom
refactor
Open

refactor: documentation, bug fixes, test coverage, and GOAP rewrite#1
vantreeseba wants to merge 23 commits into
mainfrom
refactor

Conversation

@vantreeseba

Copy link
Copy Markdown
Member

Summary

  • Docs: Added AGENTS.md, CLAUDE.md, and .agents/ reference docs (overview, architecture, conventions, development, testing, todos) following patterns from sibling libs
  • Bug fixes: SucceederNode double-return, LeafNode stub implemented, Action placeholder docs removed, FSM.toDot() null crash + spurious any-node, FSM.tick() null guard, Plan.length property wired correctly
  • Refactors: Blackboard stores Float instead of Int; Action.Cost changed to Float; Plan.isCompleted() made iterative; Planner fully rewritten to use dropecho.ds Graph + Search.dijkstra for globally optimal plans (replaces greedy backward-chaining); build.hxml gets missing -lib dropecho.ds
  • Tests: Expanded coverage across 10 test files — BlackboardTests, TaskBankTests, TaskNodeTests, UtilityTests, FSMTests, PlanTests, PlannerTests, ActionTests, StateTests (new); added edge cases for circular dependencies, globally-cheapest path selection, multi-action plan advancement, null-state guards

GOAP Planner rewrite

The old planner used greedy backward-chaining (cheapest action per precondition independently), which cannot guarantee globally optimal plans and has no cycle detection.

The new planner:

  1. Represents world states as sorted comma-joined condition strings (e.g. "found_weapon,has_weapon")
  2. BFS-expands the reachable state space into a Graph<String, Action> using Queue + Set from dropecho.ds (visited set prevents cycles)
  3. Runs Search.dijkstra to find the globally cheapest path to any goal-satisfying state
  4. Reconstructs the ordered action sequence via Dijkstra's prev-pointers

Test plan

  • haxelib run dropecho.testing — all targets green
  • Verify PlannerTests.test_globally_cheapest_plan_chosen_over_greedy passes (key correctness test for new planner)
  • Verify PlannerTests.test_circular_dependencies_do_not_infinite_loop passes (was an infinite loop before)
  • Verify FSMTests.test_tick_before_change_to_state_throws passes (null guard)
  • Verify BlackboardTests / TaskBankTests / TaskNodeTests all pass (were empty or missing)

🤖 Generated with Claude Code

vantreeseba and others added 23 commits June 5, 2024 17:04
Initializes agent documentation following patterns from sibling libs
(dropecho.ds, dropecho.storygen, dropecho.testing). Adds project
settings with permission allowlist for common read-only commands.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… nodes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… Motive what-comment

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…s coverage

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…plan tests

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Resolved conflict: keep private _facts field and inline methods,
take Float types from worktree branch.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Resolved conflict: kept _currentState.tick() call (now safe after null
guard), merged in getCurrentState() accessor added by worktree.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ng cleanup

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nused

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…MTests

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Resolved FSMTests conflict: kept _bb/_st1/_st2/_fsm field names and
Type.getClassName-based getName(); removed stale broken tests with
undefined TestState1/2 and wrong lambda arity; kept correct new tests.
Fixed Plan.get_length to reference _actions not Actions.
Deduplicated PlannerTests chained-action test; fixed assertions to use
_actions.dequeue() instead of nonexistent index access.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…i-action, PlannerTests edge cases, StateTests

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…, Action.Cost Float

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… Action.Cost Float

Resolved conflicts: kept field initializers on Action (worktree removed them),
took worktree's iterative isCompleted() and full generatePlan() Graph+Dijkstra rewrite.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant