TL;DR
Ludax is the first board game description language that compiles directly into hardware-accelerated JAX code for GPUs. It bridges the gap between high-level, human-readable game description languages (like Ludii) and lightning-fast, hardware-accelerated simulators (like PGX). By turning game rules into vectorized JAX environments, Ludax lets researchers simulate millions of steps per second and seamlessly train deep reinforcement learning (RL) agents across diverse, customizable games.
What Problem Does This Paper Address?
AI research has relied on games for decades, but modern deep reinforcement learning faces a frustrating trade-off:
- General Game Description Languages (GDLs) like Ludii can represent thousands of historical and novel games via modular rule descriptions, but they run primarily on CPUs and are difficult to scale across massive GPU clusters.
- GPU-Accelerated Simulators like PGX deliver millions of steps per second in JAX, but their game logic is hard-coded by hand. Creating a new game or testing an altered ruleset requires writing custom, bug-prone accelerator code from scratch.
This leaves researchers stuck choosing between speed and generality. Ludax resolves this tension by providing a high-level domain-specific language (DSL) that automatically compiles into vectorized, JIT-compilable JAX code.
Methods
- "Ludemic" Syntax: Inspired by Ludii, Ludax breaks games into modular building blocks (ludemes) split across
equipment,start,play, andendrules. Primitive elements—such asmasks(board positions),functions(e.g., counting lines of pieces), andpredicates(logical checks)—compose via first-order logic. - Bottom-Up JAX Function Composition: Ludax parses game code using the Lark library. Leaves in the syntax tree compile into small JAX functions mapping game states to values. Parent nodes compose these functions into a single step function. Fixed properties discovered during parsing (e.g., board geometry, line orientations) are passed into compiled JAX kernels as static compile-time constants.
- Smart Precomputation: Instead of raycasting or scanning dynamically during play, Ludax precomputes static arrays of board coordinate tuples at compile time (e.g., every combination of board indices that forms a line of length $k$). Game evaluations reduce to batched, multi-dimensional array slicing.
- Dynamic State Tracking: If a game requires topological connectivity checks (like Hex), Ludax automatically inserts specialized intermediate logic into the step function to update connected components incrementally after each move, avoiding expensive full-board graph traversals.
Datasets
Rather than static training datasets, the authors evaluate Ludax across:
- 10 Benchmark Board Games: 4 overlapping with both PGX and Ludii (Tic-Tac-Toe, Connect Four, Hex, Reversi) and 6 implemented in Ludax and Ludii (Gomoku, Pente, Yavalath, Yavalax, Dai Hasami Shogi, HopThrough).
- Novel Generated Games Benchmark: 100 candidate games procedurally sampled via uniform random syntax trees and large language models (LLMs), evaluated across gameplay heuristic metrics adapted from the GAVEL framework.
Key Insights and Ideas
- Action Space Standardization: Unlike Ludii (which uses game-specific action mechanics, such as a "drop" action in Connect Four), Ludax standardizes actions to board coordinates with legality masks. This allows general game-playing agents and neural networks to transfer representations easily across games with matching board sizes.
- Zero Overhead During Training: While hand-tuned JAX environments have slightly faster raw simulation throughput, the authors found that in an AlphaZero pipeline, environment step time accounts for so little total compute compared to neural network forward/backward passes that Ludax had virtually no practical wall-clock penalty (~1.5% runtime difference).
- Out-of-the-Box LLM Synthesizability: Because the DSL mimics natural language logic, off-the-shelf open-weight LLMs (without fine-tuning) successfully authored novel, compilable, and strategically deep games directly from the grammar.
Key Results
- Simulation Throughput: On an NVIDIA RTX 4090, Ludax outspeeds 32-thread multi-core CPU execution of Ludii across all 10 benchmark games, achieving speedups ranging from ~3× (Hex) up to ~55× (Pente).
- Competitive with Hand-Coded JAX: Ludax matched PGX throughput at smaller batch sizes and remained within an order of magnitude of PGX at batch sizes up to $2^{15}$, despite PGX being heavily hand-optimized.
- RL Agent Training: Training an AlphaZero-style ResNetV2 agent on Reversi over 57 million frames took roughly 3 hours on a single A100 GPU. The agent trained in Ludax exhibited identical learning stability and win-rates against the PGX baseline agent.
- Automated Game Generation: Few-shot prompted LLMs excelled at generating games in the DSL.
GPT-OSS-120Bgenerated games that were 95% playable (compiled and ran) and 83% interesting (GAVEL score $> 0.4$), compared to 4% playable and 0% interesting for random grammatical sampling.
Limitations and Future Work
- Supported Game Scope: Ludax currently supports only two-player, perfect-information, turn-based board games dominated by piece placement, sliding/hopping, and custodial capturing. It does not yet support multiple piece types (e.g., Checkers/Chess), irregular board topologies, imperfect information, card games, or video games.
- Memory Bottlenecks at Large Batches: At very high batch sizes, Ludax plateaus earlier than PGX due to memory pressure from maintaining separate state arrays (like explicit connection components).
- Future Directions: Extending the grammar to multi-phase games (e.g., Nine-Men's Morris), building rich web interfaces for human-subject cognitive experiments, and using Ludax as an inner-loop simulation engine for automated game design and world-model research.
Summary updated