SheepSeb/tinyworldformer

Tiny world model generates games and stream ac plays them all on Pico 2W

What it solves

This project addresses the challenge of running complex, interactive game simulations on extremely resource-constrained hardware like a Raspberry Pi Pico 2 W. It enables a device to "dream" its own game environment and learn to play it entirely on-chip, without needing a connection to a powerful computer.

How it works

It uses two small neural networks that run on the microcontroller: a "world model" and an "actor." The world model is a tiny, looped transformer that predicts the next frame and reward based on the current frame and the player's action. The actor is a simple multi-layer network that observes the frames generated by the world model and decides which action to take. Because the world model reuses the same transformer weights multiple times (a "looped" design), it remains small enough to fit into the Pico's memory while still accurately simulating game mechanics like physics and enemy movement.

Who it’s for

This project is for developers and researchers interested in edge AI, lightweight machine learning, and reinforcement learning on microcontrollers. It is ideal for those who want to experiment with how neural networks can simulate environments and learn behaviors within the strict memory and processing limits of embedded hardware.

Highlights

  • Runs entirely on a Raspberry Pi Pico 2 W using no_std Rust.
  • Features a looped transformer world model that uses int8 quantization to save memory.
  • Includes a streaming reinforcement learning agent that can learn to play games from scratch directly on the chip.
  • Supports multiple classic-style games like Breakout, Pong, Flappy Bird, Doom-lite, and Pac-Man.
  • Allows users to take control of the game at any time, effectively playing inside the model's "dream."

Related

  • Project
  • Project
  • Project
  • Project