Show HN: Go-Bt: Minimalist Behavior Trees for Go

go-bt is a minimalist Behavior Tree library for Go designed for background workers and game AI, featuring a cooperative multitasking model and time-travel testing capabilities.
go-bt is a Behavior Tree library for Go, designed for background workers, game AI, mundane task automation, and asynchronous logic. Instead of time.Sleep or infinite while loops, go-bt uses a cooperative multitasking model. Nodes return state instantly, yielding control back to the supervisor. Stateless nodes do not hold runtime state; all execution states live within the generic BTContext[T]. Every node's Run method returns Success (1), Running (0), or Failure (-1). It embeds Go's standard context.Context and features "Time-Travel Testing" via an injected clock, allowing instant testing of long timeouts. The library provides core nodes like Composites (Selector, Sequence), Decorators (Inverter, Retry), and Leaves (Condition, Action, Sleep). It uses Go Generics for the blackboard state and includes a concurrent, panic-safe Supervisor to drive the tree logic without blocking the main thread.
Source: Hacker News















