Skip to main content

Quick Start Guide

This guide will help you get up and running with Reward Machines (RMs) and Counting Reward Machines (CRMs) in just a few minutes.

Basic Example

We’ll use the Letter World environment, where an agent must visit letters (specific goal locations)in a specific order.

What’s Happening?

  1. Ground Environment (LetterWorld) A simple grid world subclass of gymnasium.Env.
  2. Labelling Function (LetterWorldLabellingFunction) Maps low-level environment transitions to high-level events (propositions).
  3. Reward Machine (RM) (LetterWorldRewardMachine) Specifies rewards based on event sequences.
  4. Cross-Product MDP (LetterWorldCrossProduct) Combines environment, labelling function, and RM into a single Gymnasium-compatible environment.
To model tasks requiring counting or extended memory, swap in a CountingRewardMachine instead of a standard RM. The workflow is identical.

Training a Simple Agent

Here’s a basic tabular Q-learning loop:

Next Steps

Worked Examples

Core Concepts