Abstract
Ludii is a state-of-the-art general game system that utilizes a "ludemic" approach—deconstructing games into modular, conceptual units—to represent and play thousands of distinct titles. By mapping a human-readable game description language directly to Java code via reflection, Ludii achieves a unique balance of high expressivity and extreme computational efficiency. This guide details the underlying logic that enables Ludii to model complex rules, hidden information, and non-standard geometries.
Introduction: The Expressivity-Efficiency Trade-off
In General Game Playing (GGP), researchers face a persistent conflict between expressivity and efficiency. A language must be capable of describing any game, from ancient Mancala variants to modern Chess, yet the engine must remain fast enough for AI agents, such as those using Monte Carlo Tree Search (MCTS), to simulate thousands of games per second.
Traditional logic-based languages like GDL (Game Description Language) offer high expressivity but are often slow and verbose. Ludii addresses these challenges through a "ludemic" approach, where games are defined as trees of "ludemes" (units of game information). This structure allows for a highly efficient representation of game rules and states.
System Architecture and Methods
The core of Ludii’s architecture is its Class Grammar approach. Rather than employing a separate parser and interpreter, Ludii uses Java Reflection to create a 1:1 mapping between keywords in a .lud game file and the actual Java constructors within the engine.
Key Technical Components
- The Context Object: This central object stores the game definition ($\mathcal{G}$), the current state ($s$), and the history of moves (the trial $\tau$).
- ChunkSet State Representation: To minimize memory footprint, Ludii compresses game state information into a custom
BitSetclass calledChunkSet. By calculating the minimum number of bits required to represent every possible state per site, Ludii enables rapid state copies and updates. - Graph-Based Topology: Ludii treats every game board as a graph composed of vertices, edges, and faces. This abstraction allows the system to automatically generate "radials" (lines of sight) and "steps" for any tiling, including square, hexagonal, triangular, or semi-regular geometries.
Core Insights: The Ludemic Philosophy
The "ludemic" approach is centered on the idea that games are composed of fundamental building blocks.
- The Language is the Code: Due to the Class Grammar approach, the game description language is automatically derived from the Java source code. Adding a new "Move" class in Java immediately makes it a usable keyword for game designers.
- Separation of Concerns: Ludii strictly separates Equipment (boards, pieces, dice) from Rules (movement, end conditions). This modularity allows for easy "remixing"—for instance, applying Chess rules to a hexagonal board requires only a single line of code change.
- Native Hidden Information: Unlike many GGP systems, Ludii natively supports hidden information (e.g., fog of war or card hands) through specialized state vectors that track visibility for each player.
- Puzzles as CSPs: Beyond standard games, Ludii models deduction puzzles (e.g., Sudoku) as Constraint Satisfaction Problems (CSPs) using a dedicated
ContainerDeductionPuzzleState.
Game Mechanics and Execution
Ludii handles a vast array of game mechanics through a robust execution model:
- Atomic Actions: Every move is decomposed into primitive "atomic actions" (e.g.,
ActionAdd,ActionMove,ActionRemove), which are applied successively to modify the state. - Complex Movement: The system supports advanced movement types, including "Sowing" (for Mancala), "Leaps" (Knight-like moves), and "Slides" (Queen-like moves).
- Safety Mechanisms: To prevent infinite loops, Ludii implements hard limits, such as a maximum of 10,000 moves per game and a turn limit relative to the number of players.
Limitations and Future Directions
While highly capable, Ludii continues to evolve. Current areas of refinement include:
- Card Games: While
DeckandCardludemes are available, their implementation is ongoing and subject to change. - Dynamic Boards: Games without fixed boards are currently simulated on a large static board; future versions will implement dynamic board growth.
- Performance Optimization: Complex "Requirement Moves"—which filter legal moves based on the resulting state—can introduce significant overhead and require careful design.
Summary updated