Skip to content

Games

Game rules, rewards and encoders are separate components. The table describes the built-in defaults; constructors expose the configurable details.

Game Players Decisions Chance Information Actions Observation Reward arguments (defaults) Adapter
Backgammon 2 Sequential Dice Perfect 1,352 discrete ids Fixed CHW tensor win=1, gammon=2, backgammon=3 PettingZoo AEC
Chess 2 Sequential No Perfect AlphaZero 8x8x73 Selectable fixed CHW encoder win=1, loss=-1, draw=0 PettingZoo AEC
Connect 4 2 Sequential No Perfect 7 columns Fixed CHW tensor win=1, loss=-1, draw=0 PettingZoo AEC
GridWorld 1 Sequential No Perfect 4 directions Fixed CHW tensor step=0, goal=1 Gymnasium
CarRacing 1 Sequential Track-generation seed (root only) Perfect 5 discrete controls Rendered CHW pixels (3, 96, 96) tile=1000, step=-0.1, off_playfield=-100 None (withheld until the HWC adapter presentation lands)
Kuhn poker 2-10 Sequential Card deal Imperfect Pass / bet Fixed information-state tensor scale=1 PettingZoo AEC
Leduc poker 2 Sequential Card deal Imperfect Fold / call / raise Fixed information-state tensor scale=1 PettingZoo AEC
Snake 2-8 Simultaneous Placement and respawn Perfect 3 relative moves Egocentric fixed CHW tensor step=0, food=0, loss=-1, draw=0, kill=0, win=1, survival=0 PettingZoo Parallel
Texas Hold'em 2-9 Sequential Deal and board Imperfect Fold / call / raise Egocentric fixed CHW tensor scale=1 PettingZoo AEC

The action interface is one fixed discrete vocabulary per game; continuous and parameterized actions are outside the current action-space boundary. The Decisions column describes one game-wide mode: a game cannot currently switch between sequential and simultaneous decision phases.

Reward arguments are the keyword weights accepted by rf.Reward for that game; unknown names are rejected at Engine construction. Poker's scale multiplies the native chip-delta event.

Observation encoders

Every game constructor accepts an encoder= handle and otherwise selects its registered default. The encoder owns the network-facing observation and action frame, while the game owns rules and state transitions. Chess currently offers multiple views; the other built-in games each expose one. Size a network from game.observation_space().shape after construction.

game = rf.games.Chess(encoder=rf.encoders.RelativeChess())
obs_shape = game.observation_space().shape  # (19, 8, 8)
Encoder Game Observation shape Constructor Purpose
Snake Snake (5, grid_size, grid_size); (5, 20, 20) by default rf.encoders.Snake() Mover-relative own-head, own-body, opponent-head, opponent-body, and food planes.
Connect4 Connect 4 (2, 6, 7) rf.encoders.Connect4() Acting-player and opponent piece planes.
MinimalChess Chess (19, 8, 8) rf.encoders.MinimalChess() Absolute piece, turn, castling, en-passant and clock planes; the Chess default.
RelativeChess Chess (19, 8, 8) rf.encoders.RelativeChess() Mover-relative board and matching action-head mapping.
OpenSpielChess Chess (20, 8, 8) rf.encoders.OpenSpielChess() OpenSpiel-compatible observation for parity and benchmarking.
AlphaZeroChess Chess (119, 8, 8) by default rf.encoders.AlphaZeroChess(history_length=8) Uses 14 * history_length + 7 channels for history, repetition, side, move-count, castling and clock features.
Backgammon Backgammon (200, 1, 1) rf.encoders.Backgammon() Tesauro-style point, bar, borne-off, turn, and dice features.
TexasHoldem Texas Hold'em (2 * num_players + 19, 4, 13); (31, 4, 13) by default rf.encoders.TexasHoldem() Player-relative cards, betting state, stacks, and positions.
KuhnPoker Kuhn poker (3 * players, 1, 1); (6, 1, 1) by default rf.encoders.KuhnPoker() Private card and public betting-history information state.
LeducPoker Leduc poker (21, 1, 1) rf.encoders.LeducPoker() Private/public cards and two-round betting information state.
GridWorld GridWorld (2, size, size); (2, 5, 5) by default rf.encoders.GridWorld() Agent-position and goal planes.
CarRacingPixels CarRacing (3, 96, 96) rf.encoders.CarRacingPixels() Rendered top-down frame, raw 0-255 values, channel-major (gym renders HWC).
CarRacingVec CarRacing (1, 1, 21) rf.encoders.CarRacingVec() Diagnostic pose/velocity/wheel/progress vector; renderer-free training and physics-vs-visual failure isolation.

Before moving action ids between a network and Env, read the action-frame contract.

CarRacing notes

CarRacing ports Gymnasium's CarRacing-v3 (discrete). Faithful means the action contract, observation content, track-generation algorithm, reward and episode rules, and qualitative driving behavior; trajectories, checkpoints, and scores from the Gymnasium build do not transfer (different physics engine and float paths).

  • The rendered HUD score is the canonical Gym score (fixed tile/step constants, off-playfield never shown) regardless of the rf.Reward weights you train with.
  • Tile progress counts per-wheel contact-entry events, matching Gym's behavior including its sticky reset-contact lap quirk.
  • Observations are channel-major (3, 96, 96) raw 0-255 floats per the framework contract; Gymnasium renders the same content as HWC uint8, so pipelines moving between the two must permute and cast.
  • Snapshot bytes carry only validated dynamic values (poses, velocities, controls, joint warm-start impulses, progress); the physics world is reconstructed canonically at restore, which is what keeps hostile snapshot bytes safe. Restore is exact over those serialized values and always resumes the same trajectory, but that trajectory departs from a never-snapshotted run at float rounding order (solver bookkeeping is rebuilt, not restored), so restored collection is deterministic rather than record-identical to an uninterrupted run.
  • Search-based algorithms (TreeStrap, AlphaZero) are mechanically supported: after the track is realized the game is a deterministic single-agent planning problem. Under the pixels encoder every search node renders a full frame, so search-based training is far more economical with rf.encoders.CarRacingVec().
  • The standard-API adapters withhold car_racing until frames can be presented in Gym's native HWC uint8 layout; use rf.Env directly.

See built-in compatibility for supported workflows and the Python API for constructor parameters.