Event Structure
Events are the atomic units of gameplay. Every state transition produces one or more events that describe what happened. The Event dataclass fromcore.py:23-29 defines the structure:
Fields Explained
type: str
type: str
The event name (e.g.,
"MOVE", "EAT", "DIE_WALL").Defines what kind of transition occurred. Event types are domain-specific — Snake has different events than Pac-Man or Chess.entity: str
entity: str
Which entity caused or experienced the event (e.g.,
"player", "food").Entities are defined by their behavior under collision. A “food” is whatever produces EAT events when touched.payload: dict
payload: dict
Event-specific data (e.g.,
{"pos": (5, 7)}, {"length": 4}).Contains the details needed to encode the event as tokens. Can include positions, scores, directions, or any relevant state change.tick: int
tick: int
Game tick when the event occurred.Events are bundled by tick — all events from a single game step share the same tick value. This creates temporal structure in the event stream.
salience: Salience
salience: Salience
Importance level for filtering (0-4).Not all events are equally important. Salience allows the encoder to filter out low-priority events if needed.
Salience Levels
Salience is an integer enum fromcore.py:15-20 that defines event importance:
Hierarchy
COLLISION (2)
Interaction events like
DIE_WALL or DIE_SELF. Higher priority because they change game state significantly.The encoder can filter events by salience threshold. For example,
salience_threshold=Salience.MOVEMENT keeps only movement and higher events, dropping pure TICK markers.Game Interface Protocol
Any game can plug into the pipeline by implementing three methods:reset() → State
Initialize a new game episode and return the starting state.snake.py:14-24.
step(action) → (State, Events, Done)
Execute one action and return:- New state
- List of events that occurred
- Whether the episode is done
snake.py:26-128. A single step can produce many events.
legal_actions(state) → List[Action]
Return valid actions for the current state.snake.py:130-131. Snake can’t reverse direction instantly.
Event Examples from Snake
Here are real event types fromsnake.py:
Input Event
snake.py:39-45. Records player input.
Movement Event
snake.py:95-99. Player moved to new position.
Collision Event (Death)
snake.py:53-57. Hit the wall, game over.
Rule Effect Events (Eating)
When the player eats food, multiple events fire:snake.py:69-121. This is collision-defined semantics in action: food is defined by the event chain it triggers.
Tick Bundling
All events from a singlestep() call share the same tick value. The encoder groups them together:
TICK token marks the start of a new time step. Events within a tick are causally related.
Event Stream to Token Sequence
The event stream is the boundary between the game and the model:
The codec (next page) handles the translation from events to tokens.
Game-Agnostic Design
The event stream protocol is intentionally minimal. Any game can implementreset(), step(), and legal_actions() without knowing anything about tokens or transformers.
From the README: “For now, the game never touches the model. The tokenization layer is where game-agnosticism lives.”
- Events capture state transitions
- Salience marks importance
- Tick numbers create temporal structure
- Payload contains domain-specific details
Next Steps
Theory
Understand the Wittgensteinian foundation
Tokenization
See how events become token sequences
