Behavior-tree scripting DSL + interpreter for a game
A DSL and interpreter for behavior-tree-style scripting in a game, built to allow player scripts and dogfooded for enemy AI. Stateful typed builders were split into an untyped AST and a typed IR, and a TypeScript schema -> codegen build step generates .ts/.rs code.
What it addresses
The off-the-shelf behavior tree dependency looked too limited ("too easy") and stateful typed builders were annoying and repetitive, so a custom DSL with an untyped-AST -> typed-IR pipeline and schema-driven codegen was built instead.
Shared over time
Each entry reflects what was shared on that date. Details may have changed since then.
Behavior-tree scripting DSL + interpreter for a game
A DSL and interpreter for behavior-tree-style scripting in a game, built to allow player scripts and dogfooded for enemy AI. Stateful typed builders were split into an untyped AST and a typed IR, and a TypeScript schema -> codegen build step generates .ts/.rs code.
Problem: The off-the-shelf behavior tree dependency looked too limited ("too easy") and stateful typed builders were annoying and repetitive, so a custom DSL with an untyped-AST -> typed-IR pipeline and schema-driven codegen was built instead.
Audience: Players of the game, who are meant to be able to write scripts; dogfooded by the developer for enemy AI
Posted by @Frotag · Original comment ↗
“>Making a simple game >Want player scripts to be possible (And dogfood it for enemy ai too) >Behavior tree dep looks too easy, let's make a dsl + interpreter >Typed builders are annoying (because stateful), lets separate into builders -> untyped ast -> typed ir >Hm, typed ir is super repetitive, now I have a schema (ts) -> codegen (ts) -> .ts / .rs build step Fun waste of 2 weeks, not even counting the time spent on pl literature”