Ludii Game Logic Guide

Éric Piette, Cameron Browne, Dennis J. N. J. SoemersarXiv 2021 · arXiv

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 BitSet class called ChunkSet. 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.
The Ludeme interface hierarchy, showing how different game elements like Rules, Equipment, and Functions are categorized.

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 Deck and Card ludemes 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

Abstract

This technical report outlines the fundamental workings of the game logic behind Ludii, a general game system, that can be used to play a wide variety of games. Ludii is a program developed for the ERC-funded Digital Ludeme Project, in which mathematical and computational approaches are used to study how games were played, and spread, throughout history. This report explains how general game states and equipment are represented in Ludii, and how the rule ludemes dictating play are implemented behind the scenes, giving some insight into the core game logic behind the Ludii general game player. This guide is intended to help game designers using the Ludii game description language to understand it more completely and make fuller use of its features when describing their games.
BibTeX
@misc{piette2021ludii,
  author = {Éric Piette and Cameron Browne and Dennis J. N. J. Soemers},
  title = {{Ludii Game Logic Guide}},
  year = {2021},
  eprint = {2101.02120},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2101.02120},
}
Figure