Rulebook Documentation
Rulebook is a statically-checked imperative language that turns interactive behaviour—reinforcement-learning environments, video-games, or in general complex interactive subsystems—into something you can query, replay, fuzz, and formally verify.
4hammer (our flagship demo) shows Rulebook in action.
Why Rulebook?
Capture every run – automatically store, load, print, replay, and mutate both state and execution traces.
Push-button testing – drop in standard fuzzers, formal proofs, or reinforcement-learning agents.
Self-configuring UIs – the UI introspects your program graph and adapts its controls on the fly.
Remote execution – ship interactive logic across the network with a zero-boilerplate RPC layer.
Solve the interactive inversion-of-control problem at the language level—no more interactive spaghetti.
Under the hood
Rulebook’s defining idea is the notion of Action functions with SPIN properties, which make all of the above possible.
Integration
Rulebook compiles to one shared library (or WebAssembly module) with a C-compatible ABI and generated bindings for C, C++, C#, Python, and Godot Script. Use it the way SQL complements those languages—drop it in wherever interactive logic is the hard part. Rulebook puts action functions on the stack, unless you want it on the heap. Zero mallocs unless explicitly requested by the user.
Tools
Reinforcement Learning Docs:
UI, Controller and Gameplay Programming
UI, controller and gameplay programming are among the sections that benefit the most from using Rulebook. Beside automatically fuzz , prove correct and run reinforcement learning on your program, write self-configuring UIs , Rulebook automatically provides a sharp division between UI concerns and Controllers or Gameplay.
UIs, Controllers, Gameplay:
- UI, Controller and Gameplay
- MVC
- VIEW-Rulebook pattern
- Efficient VIEW-Rulebook pattern
- View-Rulebook-Model Pattern
- automatic textual and binary serialization of the model.
- automatic tracing, and textual and binary serialization for the tracing o f the controller.
- automatic testing with fuzzers, machine learning and proofs.
- automatic bindings to execute the view indipendently from rulebook.
- automatic bindings to write the view in multiple languages.
- View-Multi Rulebook Controller pattern
- Multilayer Rulebook Controllers.
- 4Hammer
References:
- Rulebook Language
- RLC
- Rulebook Language
- Rulebook Types
- Enum Types
- Array Types
- Alternative Types
- Class Types
- Function Types
- Functions
- Action Functions
- Frm and Ctx Qualifiers
- Action Statements
- Actions Statements
- Subaction Statements
- Context Variables in Subaction Statements
- Return Statements
- If Statements
- While Statements
- Using Statements
- Declaration Statements
- Reference Declaration Statements
- Frame Declarations Statements
- Declaration Statements Destruction
- Call Expressions
- stdlib