An implementation of Claude playing Tetris using the PyBoy emulator.
- Clone this repository
- Install the required packages:
pip install -r requirements.txt
- Set up your Anthropic API key as an environment variable:
export ANTHROPIC_API_KEY=your_api_key_here
- Place your Tetris ROM file in the root directory (you need to provide your own ROM)
Run the main script:
python main.py
agent.py
: Main agent class that uses Claude to play Tetrisemulator.py
: Wrapper around PyBoy with helper functionsapiutils.py
: Utilities for interacting with the Anthropic APIprompts.py
: Contains prompts used by the agentconfig.py
: Contains model settings
- The agent captures a screenshot from the emulator
- It reads the game state information from memory
- It sends the screenshot and game state to Claude
- Claude responds with explanations and emulator commands
- The agent executes the commands and repeats the process
This project is based on ClaudePlaysPokemonStarter.