Skip to main content

Gymnasium environment for Street Fighter III: 3rd Strike using the MAME emulator

Project description

SFIII Gym

Latest Tag Pypi version

Code Checks Pytest

Supported OS Python Version Latest Repo Update

License

SFIII Gym

A Gymnasium environment for Street Fighter III: 3rd Strike using the MAME emulator. Train reinforcement learning agents to play one of the most iconic fighting games ever made.

SFIII Gym

Features

  • Gymnasium-compatible — standard reset() / step() / render() API
  • Rich observations — game frame (224×384 RGB), player healths, sides, opponent character, and current stage
  • 15 discrete actions — movement (8 directions + idle) and attacks (6 punch/kick buttons)
  • Configurable difficulty — 8 difficulty levels (1–8)
  • Render modes"human" for live playback, "rgb_array" for headless training

Prerequisites

  • Python ≥ 3.12
  • Linux (MAME emulator requirement)
  • Street Fighter III: 3rd Strike ROM (sfiii3n.zip) — you must legally obtain this ROM and place it in a local directory (e.g. ./rom/)

Installation

pip install sfiii-gym

Or with uv:

uv add sfiii-gym

For development:

git clone https://github.com/alexpalms/sfiii-gym.git
cd sfiii-gym
uv sync

Getting Started

from sfiii_gym import Environment

# Create the environment
env = Environment("env1", "./rom", render_mode="human", throttle=False)
obs, info = env.reset()

cumulative_reward = 0
while True:
    env.render()
    action = env.action_space.sample()  # Replace with your agent's action
    obs, reward, terminated, truncated, info = env.step(action)
    cumulative_reward += reward

    if terminated or truncated:
        print(f"Episode finished — Cumulative Reward: {cumulative_reward}")
        obs, info = env.reset()
        cumulative_reward = 0

Observation Space

Key Space Description
frame Box(0, 255, (224, 384, 3), uint8) Raw game screen (RGB)
healthP1 Box(-1, 160, int16) Player 1 health
healthP2 Box(-1, 160, int16) Player 2 (opponent) health
sideP1 MultiBinary(1) Player 1 side
sideP2 MultiBinary(1) Player 2 side
characterP2 Discrete(20) Opponent character ID
stage Box(1, 10, uint8) Current stage (1–10)

Action Space

Discrete(15) — 0: no-op, 1–8: movement directions, 9–14: attacks (jab, strong, fierce, short, forward, roundhouse).

Configuration

Parameter Type Default Description
env_id str Unique environment identifier
roms_path str Path to directory containing the ROM
difficulty int 6 CPU difficulty level (1–8)
frame_ratio int 6 Frames per step (higher = faster)
render_mode str "rgb_array" "human" or "rgb_array"
throttle bool False Throttle to real-time speed

Repository Structure

sfiii-gym/
├── src/sfiii_gym/          # Main package
│   ├── __init__.py         # Package exports
│   ├── environment.py      # Gymnasium environment implementation
│   ├── actions.py          # Action definitions and mappings
│   ├── steps.py            # Step/observation processing logic
│   └── py.typed            # PEP 561 typing marker
├── tests/
│   ├── unit/               # Unit tests (actions, steps)
│   └── integration/        # Integration tests (env run, Gym API compliance)
├── stubs/MAMEToolkit/      # Type stubs for the MAME emulator toolkit
├── examples/
│   └── run_env.py          # Example script to run the environment
├── rom/                    # ROM directory (not distributed)
└── pyproject.toml          # Project metadata and dependencies

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sfiii_gym-0.1.1.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sfiii_gym-0.1.1-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file sfiii_gym-0.1.1.tar.gz.

File metadata

  • Download URL: sfiii_gym-0.1.1.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for sfiii_gym-0.1.1.tar.gz
Algorithm Hash digest
SHA256 045432b4a3ff8ef98828b0ac5b4cdb2553057ee0495d6e4ccc270a5b4be5a176
MD5 ad936d6acdab05f14586e7424d2d1f01
BLAKE2b-256 c1f18ea69835d8c17688db587e97adb2aea48e29c0146f246c837d380ced79fa

See more details on using hashes here.

File details

Details for the file sfiii_gym-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: sfiii_gym-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for sfiii_gym-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 480a3ba6be0d41b403d1be728b795028776e35dd0b569f77b7d3ecb4bb710300
MD5 cce926574cc490dbc9e46b710bcda532
BLAKE2b-256 acc0e288c960db00c968e6e17bbd8a0e794512e92b43c4bf11840eb7f0f4a6b0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page