Friday, February 13, 2026

cnl video game library

license: public domain CC0.

 

You can build multiple CNLs, each tailored to a specific classic arcade game. In fact, this is exactly the kind of structure that keeps an LLM grounded, prevents rule‑drift, and gives human designers a clean, readable way to define game logic.

Let’s walk through how this works and then I’ll sketch six separate CNLs, each tuned to the mechanics of a different game.


🎮 Why build multiple CNLs instead of one universal one?

Each of the games you listed has a distinct mechanical grammar:

  • Space Invaders → grid, formations, downward pressure, bullets
  • Asteroids → continuous space, rotation, inertia, wraparound
  • Missile Command → trajectories, explosions, interception arcs
  • Frogger → lanes, moving obstacles, discrete hops
  • Defender/Stargate → scrolling world, radar, abductors, rescue logic
  • Pac‑Man → maze, pellets, ghosts with AI modes

Trying to force all of these into one CNL would either:

  • become too abstract to be useful, or
  • become too complex for an LLM to reliably follow.

Instead, you create six small, tight CNLs, each with:

  • a restricted vocabulary
  • a restricted grammar
  • a domain‑specific ontology
  • a clear mapping to structured state

This is exactly how ACE works: domain‑specific micro‑languages.


🧠 Can an LLM stick to a CNL?

Yes — if you give it:

  • a glossary
  • a grammar
  • examples
  • a system prompt that enforces the rules
  • a validator that rejects invalid sentences

LLMs are very good at staying inside a constrained language when the constraints are explicit.


🧩 Now let’s design the six CNLs

Below are concise but concrete CNL definitions for each game type. Each includes:

  • Vocabulary
  • Sentence patterns
  • Example spec fragments

These are starting points — you can expand them as needed.


1) Space Invaders CNL

Vocabulary

player ship, enemy, formation, bullet, shield
row, column, grid
move, fire, descend, destroy
left, right, up, down
tick, boundary

Grammar (examples)

There is a player ship at row <int> column <int>.
There are <int> enemies in row <int>.
Each enemy moves horizontally by <int> cells each tick.
If any enemy reaches a boundary then all enemies descend by <int> rows.
The player ship fires a bullet when the action FIRE occurs.
If a bullet occupies the same cell as an enemy then the enemy is destroyed.

Example spec

The grid has 15 rows and 10 columns.
There is a player ship at row 1 column 5.
There are 20 enemies in rows 10 to 12.
Each enemy moves horizontally by 1 cell each tick.
If any enemy reaches a boundary then all enemies descend by 1 row.

2) Asteroids CNL

Vocabulary

ship, asteroid, fragment, bullet
position, velocity, angle, rotation
wrap, thrust, split

Grammar

The ship has position <float,float> and angle <float>.
The ship rotates by <float> degrees when commanded.
The ship applies thrust to change velocity.
An asteroid moves according to its velocity.
If a bullet hits an asteroid then the asteroid splits into <int> fragments.
If an object crosses a boundary then it wraps to the opposite side.

Example spec

The ship starts at position (0,0) with angle 0.
Asteroids drift with constant velocity.
If a bullet hits an asteroid then the asteroid splits into 2 fragments.
Objects wrap at all boundaries.

3) Missile Command CNL

Vocabulary

city, silo, missile, interceptor, explosion
trajectory, arc, target, radius
launch, intercept, destroy

Grammar

A missile travels along a straight trajectory toward a city.
A silo launches an interceptor when commanded.
An interceptor creates an explosion with radius <float>.
If a missile enters an explosion radius then the missile is destroyed.
If a missile reaches a city then the city is destroyed.

Example spec

There are 6 cities.
Missiles spawn at the top with random trajectories.
Interceptors explode with radius 1.5.
If a missile enters an explosion radius then the missile is destroyed.

4) Frogger CNL

Vocabulary

frog, lane, car, log, river, goal
move, hop, collide, ride
left, right, forward, backward

Grammar

The frog starts in lane <int>.
Cars move left or right by <int> cells each tick.
Logs move left or right by <int> cells each tick.
If the frog is on a log then the frog moves with the log.
If the frog collides with a car then the frog dies.
If the frog reaches the goal lane then the frog wins.

Example spec

There are 5 lanes of cars and 3 lanes of logs.
Cars move by 1 cell each tick.
Logs move by 1 cell each tick.
If the frog collides with a car then the frog dies.

5) Defender / Stargate CNL

Vocabulary

ship, humanoid, lander, bomber, pod, baiter
scroll, radar, abduct, rescue
x-position, y-position, velocity

Grammar

The world scrolls horizontally at speed <float>.
The ship moves freely in both axes.
A lander attempts to abduct a humanoid.
If a lander reaches a humanoid then the lander abducts the humanoid.
If the ship destroys the lander then the humanoid falls.
If the ship catches the falling humanoid then the humanoid is rescued.

Example spec

The world scrolls at speed 1.
Landers attempt to abduct humanoids.
If a lander reaches a humanoid then the lander abducts the humanoid.
If the ship catches a falling humanoid then the humanoid is rescued.

6) Pac‑Man CNL

Vocabulary

pacman, ghost, pellet, power pellet, maze, tunnel
scatter, chase, frightened
move, eat, collide

Grammar

Pacman moves by 1 cell each tick.
Ghosts follow one of four modes: scatter, chase, frightened, or eaten.
If Pacman eats a pellet then the pellet is removed.
If Pacman eats a power pellet then all ghosts enter frightened mode.
If Pacman collides with a ghost in frightened mode then the ghost is eaten.
If Pacman collides with a ghost in chase mode then Pacman dies.

Example spec

Pacman moves by 1 cell each tick.
Ghosts alternate between scatter and chase modes.
If Pacman eats a power pellet then ghosts enter frightened mode for 6 seconds.

🧱 Why this works so well

Each CNL:

  • captures the core mechanics of its game
  • is small enough for an LLM to follow reliably
  • is clear enough for humans to write
  • maps cleanly to structured state
  • prevents the LLM from drifting into unrelated concepts

You can even build a meta‑CNL that selects which game CNL is active.


The design you've presented for creating multiple Controlled Natural Languages (CNLs) tailored to specific classic arcade games is an excellent idea. It effectively narrows down the scope for each game and gives both human developers and the LLM clear rules and constraints to follow. However, there are a few areas that could be further refined or adjusted to make the implementation smoother and more robust. Let’s walk through some critical reviews and suggested improvements:


1. Vocabulary Choices

While the vocabulary for each game is mostly well-chosen, there are a few areas where further clarification or expansion could help. Specifically:

Space Invaders CNL:

  • “formation”: This term could be made more specific. For example, you could use “enemy formation” or “enemy grid” to clarify that it refers to how enemies are organized.

  • "shield": This may need further specification, such as whether it's a single shield or multiple, where it's located, and how it behaves (e.g., durability, regeneration).

Asteroids CNL:

  • "velocity" and "angle": These are key terms, but it might be useful to add "rotation" and "thrust" as explicit actions, as the player might be rotating and thrusting the ship in various ways. You could clarify how these two actions are treated (e.g., is there a limit to the angle or speed?).

Missile Command CNL:

  • “arc”: While it’s great that you included this term, it could benefit from further definition. Does "arc" mean a parabolic trajectory, or is it customizable? Making it clear whether the arc is affected by gravity or wind (or if it's just a simple path) would be helpful.

Frogger CNL:

  • "log": In the spec, it mentions logs, but it would help to clarify if logs have any specific properties (e.g., size, speed variation, interaction with obstacles). Logs could be a moving platform for the frog, and any changes in speed could be added here.

Defender/Stargate CNL:

  • “velocity” and "scroll": These need to be expanded with more precise definitions. For example, does scrolling refer to a fixed speed, or is it dynamic (e.g., tied to player actions)? You may also want to clarify the ship’s movement (does it have inertia, or is it a fixed speed?).

  • "baiter": The term baiter is quite niche. You may want to define it more clearly (e.g., does the baiter attract enemies, or is it a decoy?)

Pac-Man CNL:

  • "frightened mode": It might be helpful to specify the duration of frightened mode and if there’s any variability in behavior when a ghost is in this mode (e.g., does the ghost move randomly?).

  • "tunnel": Is this a single tunnel or multiple? Clarifying how tunnels work (e.g., they wrap Pac-Man between opposite sides of the maze) could prevent confusion.


2. Grammar Rules

The grammar you’ve outlined is good for defining the basic behaviors of each game, but it might be enhanced by:

Introducing More Complex Sentence Patterns:

For example, some games might have conditionals, loops, or nested logic that need to be expressed in the grammar. This would allow the CNLs to support more intricate game mechanics like power-ups, enemy behaviors, or even dynamic world changes.

Example Refinement:

For Missile Command:

A missile follows a straight-line trajectory toward a city. 
An interceptor is launched from a silo when commanded.
If a missile enters an explosion radius, it is destroyed.
If an interceptor misses the missile, the missile reaches the city and destroys it.

It could be helpful to show the full "missed intercept" behavior clearly so that the game engine knows exactly how to handle different states, not just direct hits.

For Pac-Man:

If Pac-Man eats a power pellet, all ghosts turn into frightened mode for 6 seconds.
If Pac-Man collides with a ghost while in frightened mode, the ghost is eaten.

The duration of power pellets could be handled better if specified explicitly in the grammar (e.g., a time limit).


3. Clarifying Actions and Interactions

Some actions and interactions might benefit from further clarification or specific rules. Let’s go deeper into behavioral aspects.

Space Invaders:

  • Enemy Movement: You specify “enemies move horizontally,” but what happens when they hit the boundary? Adding behaviors like “if all enemies reach the boundary, they all descend and move the other direction” could prevent ambiguity in their behavior.

Asteroids:

  • Splitting Asteroids: It’s mentioned that asteroids split into fragments, but should each fragment continue to behave like the parent asteroid, or do they have distinct behaviors (e.g., smaller asteroids moving faster)? Defining this would ensure the LLM correctly interprets this interaction.

Frogger:

  • Interaction with River and Cars: The CNL mentions the frog “rides the log,” but what happens if the frog misses the log or “falls off”? What happens when the frog is not on a log or in the river?

Pac-Man:

  • Ghost AI: You’ve defined ghost behavior (chase, scatter, frightened, etc.), but specifying how the ghosts transition between these states (e.g., “scatter for 7 seconds, then chase for 5 seconds”) could help make the LLM more grounded and avoid erratic behavior.


4. Domain-Specific Ontology and State Representation

Each game needs to have a clear mapping from CNL to the structured state of the game. Currently, the vocabulary and grammar are well-defined, but specific details of the state representation could be fleshed out more.

For example, consider the Frogger CNL:

{
  "frog": { "position": { "lane": 5, "column": 3 }, "alive": true },
  "cars": [
    { "position": { "lane": 3, "column": 4 }, "direction": "right", "speed": 1 },
    { "position": { "lane": 4, "column": 2 }, "direction": "left", "speed": 1 }
  ],
  "logs": [
    { "position": { "lane": 2, "column": 1 }, "speed": 1 },
    { "position": { "lane": 3, "column": 6 }, "speed": 1 }
  ],
  "goal": { "lane": 0, "column": 5 }
}

By mapping each game entity to specific state attributes (e.g., frog position, car movement, log speed), the LLM can more easily follow the actions and rules of the game.


5. Example of Validation and Error Handling

You mentioned the importance of a validator to reject invalid sentences. Here’s a suggestion on how to do that:

Creating a Structured Schema for the Game State

Create a schema that describes the valid states for each game. For instance, in Missile Command, the missile’s position, trajectory, and target should be described using vectors and radii. Having this schema would help detect when an invalid rule violates the game logic.


6. Handling Complexity: Adding Extensibility

You’ve taken a modular approach by designing small, tight CNLs, but as the game mechanics evolve, you may encounter edge cases that need new mechanics. Some suggestions for this:

  1. Adding New Game Mechanics:

    • Introduce the possibility of extending the CNL with new entities or behaviors as optional extensions (e.g., power-ups, new types of enemies, or dynamic maps).

  2. Hybrid CNL Approach:

    • If needed, create a meta-CNL that provides basic building blocks across all games, with specific game-specific extensions. This could allow you to expand on shared mechanics (e.g., movement, collisions) while maintaining separate rules for each game’s uniqueness.


Final Thoughts and Suggestions for Fixes

  • Clarify Ambiguous Behaviors: In some cases, behaviors (e.g., power-ups, asteroid splitting) could benefit from more precise definitions and conditions (e.g., timing for power-up effects, speed adjustments for smaller fragments of asteroids).

  • Action and Interaction Depth: Make sure actions (e.g., “hop,” “fire,” “move”) and interactions (e.g., “collide,” “destroy”) have clear triggers and consequences, especially for edge cases (e.g., colliding with multiple objects at once, missing a log in Frogger).

  • State Representation: Ensure a clear and structured mapping of CNL rules to game state objects. This will help both LLMs and human developers have a consistent reference point for defining game logic.

  • Error Validation: Create a formal validation system for parsing and detecting invalid rules, ideally with specific error messages to guide the developer.

These improvements would help ensure that the CNLs are robust enough for both human creativity and machine processing, providing a stable foundation for the LLM-driven game engine.


No comments:

Post a Comment