🤖 AI Summary
Reinforcement learning (RL) environments are commonly implemented either as isolated processes—incuring inter-process synchronization overhead—or as hand-crafted state machines—imposing unstructured programming burdens—severely limiting scalability and development efficiency. This paper introduces Rulebook, a coroutine-based domain-specific language (DSL) for RL environment specification, compiled to efficient low-level code. Its core innovation is the first systematic decoupling of coroutine semantics from syntactic expression: the compiler automatically lowers high-level coroutine programs into zero-overhead, deterministic finite-state machines with no runtime communication or manual state management. This enables modular, composable, and maintainable simulation logic while preserving full determinism and performance. Empirical evaluation demonstrates that Rulebook reduces development effort for large-scale RL environments by over 50%, significantly improving scalability, correctness assurance, and engineering practicality.
📝 Abstract
Reinforcement learning (RL) algorithms, due to their reliance on external systems to learn from, require digital environments (e.g., simulators) with very simple interfaces, which in turn constrain significantly the implementation of such environments. In particular, these environments are implemented either as separate processes or as state machines, leading to synchronization and communication overheads in the first case, and to unstructured programming in the second. We propose a new domain-specific, co-routine-based, compiled language, called Rulebook, designed to automatically generate the state machine required to interact with machine learning (ML) algorithms and similar applications, with no performance overhead. Rulebook allows users to express programs without needing to be aware of the specific interface required by the ML components. By decoupling the execution model of the program from the syntactical encoding of the program, and thus without the need for manual state management, Rulebook allows to create larger and more sophisticated environments at a lower development cost.