HeadlinesBriefing favicon HeadlinesBriefing.com

go‑bt v0.1.0: A Lean Go Library for Behavior Trees

Hacker News •
×

GitHub user rvitorper released go‑bt v0.1.0, a lightweight Go library that implements Behavior Trees for background workers, game AI, and task automation. The package eschews blocking calls, instead using a cooperative multitasking model where nodes return status codes—Success, Running, or Failure—allowing the supervisor to tick without stalling the main thread.

go‑bt keeps nodes stateless; all runtime data lives in a generic BTContext[T] that embeds Go’s context.Context, giving native cancellation and timeout support. The library ships a minimal node set—Selector, Sequence, Inverter, Timeout, Action, Sleep—that can be composed into any control flow. Developers can inject a mock clock into BTContext to test Sleep or Timeout nodes instantly during CI/CD testing.

The project includes a concurrent, panic‑safe Supervisor that ticks every 100 ms, freeing the main thread while the tree runs. Testing benefits from the Now function on BTContext, letting developers advance time by hours or days in a microsecond, eliminating flaky waits. Early feedback from Go veterans will shape the next iteration of this promising tool and robust performance everywhere.