Skip to main content

A flexible Goal-Oriented Action Planning (GOAP) system for game AI and planning problems, featuring A* search, efficient state management, and modular design.

Project description

GOAP Planner (goapauto)

Goal-Oriented Action Planning for Python — Build intelligent, autonomous agents with strict typing and comprehensive tooling.

CI Release License

goapauto provides a modular framework for AI decision-making using A* search. It separates Perception (Sensors), Thinking (Arbitration), Planning (A*), and Acting (Actions), making it ideal for game AI, NPCs, and simulation bots.

🚀 Key Features (v0.2.0)

  • 🎯 Goal Arbitration: Dynamically select the best goal based on priority and state.
  • 🧠 Smart Planning: A* pathfinding finds the optimal sequence of actions.
  • 🛡️ Type Safety: Built on Pydantic for strict validation and robustness.
  • 👁️ Visualizer: Export search trees to Mermaid or Graphviz for debugging.
  • 🔌 Modular Architecture: Decoupled components for WorldState, Sensors, and Goals.

📚 Documentation

Detailed documentation is available in the docs/ directory:

📦 Installation

uv add goapauto
# or
uv add goapauto

⚡ Quick Start

Here's a minimal example of an agent figuring out how to open a door.

from goapauto.models.worldstate import WorldState
from goapauto.models.goal import Goal
from goapauto.models.actions import Action
from goapauto.models.goap_planner import Planner

# 1. The World: Agent has a key, but the door is closed.
state = WorldState(has_key=True, is_open=False)

# 2. The Action: Needs 'has_key' to open the door.
open_door = Action(
    name="open_door",
    preconditions={"has_key": True, "is_open": False},
    effects={"is_open": True},
    cost=1.0
)

# 3. The Goal: We want the door open.
goal = Goal(target_state={"is_open": True})

# 4. The Plan: Find the path.
planner = Planner(actions_list=[open_door])
result = planner.generate_plan(state, goal)

print(f"Plan to '{goal.name}': {result.plan}")
# Output: Plan to "{'is_open': True}": ['open_door']

🛠️ Advanced Tooling

Visualization

Debug your planner's decision-making process by exporting the search tree:

from goapauto.utils.visualizer import SearchTreeVisualizer

viz = SearchTreeVisualizer()
planner.register_hook("on_node_expanded", viz.on_node_expanded)

# ... run plan ...

# Save as a Mermaid diagram
viz.export("planning_tree.mmd")

Visualization

GoapAuto includes a built-in search tree visualizer that hooks into the planning process to capture every explored node.

Capturing the Search Tree

Register the visualizer hook with the planner before generating a plan:

from goapauto.utils.visualizer import SearchTreeVisualizer

viz = SearchTreeVisualizer()
planner.register_hook("on_node_expanded", viz.on_node_expanded)
planner.generate_plan(initial_state, goal)
viz.export("search_tree.md")

Branching and Complexity

Simple planning problems often result in linear "chains". To see A* explore multiple branches, provide actions with overlapping effects or varying costs.

See [examples/complex_search_demo.py](file:///f:/AI/goapauto/examples/complex_search_demo.py) for a scenario that demonstrates branching search trees.

🤝 Contributing

Contributions are welcome! Please read CONTRIBUTING.md and our Code of Conduct.

📄 License

MIT License. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

goapauto-0.2.7.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

goapauto-0.2.7-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

Details for the file goapauto-0.2.7.tar.gz.

File metadata

  • Download URL: goapauto-0.2.7.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for goapauto-0.2.7.tar.gz
Algorithm Hash digest
SHA256 6dc1f73c3ecf420cde2bcb624b43a0569cdc89b69e7cf0dc1130fff3053a276d
MD5 c81e1aab2993692ab0b4193cf956ed22
BLAKE2b-256 b302e66ee50a238e8c2089099bb6b1732b7d26a76fe460d70d2079afff934afb

See more details on using hashes here.

Provenance

The following attestation bundles were made for goapauto-0.2.7.tar.gz:

Publisher: release.yml on IAmNo1Special/goapauto

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file goapauto-0.2.7-py3-none-any.whl.

File metadata

  • Download URL: goapauto-0.2.7-py3-none-any.whl
  • Upload date:
  • Size: 25.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for goapauto-0.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 27e2297b3b727de39a31a3c83a54d80f414a98a00b8c885268c1938833982a25
MD5 1a4517393b5901b9eb530f0050f06aa8
BLAKE2b-256 5ba0c21f665aca5d71c1df6deef8595f50f7cbd9bf77494c678461e6ca6f7141

See more details on using hashes here.

Provenance

The following attestation bundles were made for goapauto-0.2.7-py3-none-any.whl:

Publisher: release.yml on IAmNo1Special/goapauto

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page