Meaning is Use
The meaning of a word is its use in the language. — Wittgenstein, Philosophical Investigations §43State has no intrinsic meaning. Meaning arises only through events — a coin is the thing that increments your score when you touch it. Entities are defined solely by their behavior under collision. The structure of what can follow what is the game’s grammar. A causal transformer learns this grammar by predicting the next event token, the same way a language model learns syntax. From this single objective it learns physical regularities, rule mappings, temporal dependencies, and long-horizon behavioral patterns.
Why Events vs State
Traditional game representations focus on static state: “the player is at position (5,5), the food is at (8,6), the score is 3.” This approach has a fundamental problem: state has no intrinsic meaning. Game Grammar takes a different approach inspired by Wittgenstein’s philosophy of language:Collision-defined semantics: Entities are defined by what happens when they interact, not by what they “are”
- Food is “the thing that triggers EAT→GROW→FOOD_SPAWN when the player touches it”
- Walls are “the things that trigger DIE_WALL when touched”
- The player is “the entity that moves, eats, grows, and dies”
Event-Driven Representation
Gameplay is atomized into discrete events — movements, collisions, collections, deaths — and tokenized into a sequence. Each event captures a state transition, not a snapshot of state.Real Example from Snake
Here’s how a single game step produces multiple events insnake.py:26-128:
INPUT_R → MOVE → EAT → GROW → FOOD_SPAWN → SCORE.
Grammar as Structure
The grammar of a game is the structure of valid event sequences. Not all sequences are legal:MOVEmust be followed by position change to an adjacent cellEATmust triggerGROWandFOOD_SPAWNDIE_WALLorDIE_SELFmust be followed byEOS(end of sequence)- Movement can’t jump across the grid or go out of bounds
Tokenized Event Sequence
From the README example, a real Snake game becomes:- Physical regularities: Movement is always one cell per tick, positions stay in bounds
- Rule mappings:
EATalways triggersGROWandFOOD_SPAWN - Temporal dependencies: Death events terminate the sequence
- Behavioral patterns: Different agents produce different event patterns
Learning from Event Grammar
A causal transformer trained on next-token prediction learns the rules, physics, and behavioral patterns of the game from the event sequence alone. The model learns:Physical Validity (95% on Snake)
Physical Validity (95% on Snake)
- Moves are always to adjacent cells
- Positions stay within bounds
- Direction changes are legal (no instant reversals)
- From README: “The model learned that movement is one cell per tick”
Rule Validity (100% on Snake)
Rule Validity (100% on Snake)
EATalways triggersGROWandFOOD_SPAWNDIE_WALLorDIE_SELFalways followed byEOS- Score increments on food collection
- From README: “eating triggers growth and food respawn, and that death ends the episode”
Behavioral Patterns (Emerging)
Behavioral Patterns (Emerging)
- Player archetypes as statistical regularities
- Wall followers vs. food chasers vs. space fillers
- No explicit labels — patterns emerge from the grammar
Comparison to Other Approaches
Unlike MuZero (which learns what a player should do), Game Grammar learns what players actually do — and the output is readable by construction. The event stream is:- Interpretable: You can read the token sequence and understand what happened
- Compositional: Events combine to form patterns
- Generalizable: The same tokenization approach works for any game
- Debuggable: Invalid sequences can be traced to specific rule violations
Pipeline Overview
“For now, the game never touches the model. The tokenization layer is where game-agnosticism lives. In the long run we will feed the snake its own tail.”The separation of concerns is clean:
- Game implements the rules and emits events
- Codec translates events into tokens
- Transformer learns patterns in token sequences
- Validator checks that generated sequences obey the grammar
Next Steps
Event Streams
Learn how games emit structured events
Tokenization
See how events become token sequences
