Super Mario Bros. for Gymnasium
Project description
gymnasium-mariobros
A Gymnasium environment for Super Mario Bros. & Super Mario Bros. 2 (Lost Levels) on The Nintendo Entertainment System (NES) using the cynes emulator.
安装
使用 pip 安装:
pip install gymnasium-mariobros
使用方法
使用前必须先 import gymnasium_mariobros,因为 gymnasium 环境在导入时注册。
默认情况下,gymnasium_mariobros 环境使用完整的 256 个 NES 离散动作空间。
为了缩减动作空间,gymnasium_mariobros.actions 提供了三个动作列表
(RIGHT_ONLY、SIMPLE_MOVEMENT 和 COMPLEX_MOVEMENT)供 JoypadSpace 使用。
from gymnasium_mariobros.wrappers import JoypadSpace
import gymnasium_mariobros
from gymnasium_mariobros.actions import SIMPLE_MOVEMENT
# 创建环境,render_mode="human" 弹窗显示游戏画面
env = gymnasium_mariobros.make('SuperMarioBros-v2', render_mode="human")
# JoypadSpace 将 256 个 NES 动作缩减为指定的动作子集
env = JoypadSpace(env, SIMPLE_MOVEMENT)
done = True
for step in range(5000):
if done:
state, info = env.reset()
state, reward, terminated, truncated, info = env.step(env.action_space.sample())
done = terminated or truncated
env.close()
gymnasium_mariobros.make是gymnasium.make的别名render_mode="human"弹窗显示游戏画面,"rgb_array"返回画面数组(用于录制/训练),None不渲染- 训练时建议设为
render_mode="rgb_array"或不传(默认None)以提升速度
命令行
gymnasium_mariobros 提供命令行界面,支持键盘操控或随机动作:
gymnasium_mariobros -e <环境 ID> -m <human 或 random>
- 默认
-e为SuperMarioBros-v0,-m为human SuperMarioBrosRandomStages-*支持--stages/-S参数指定关卡子集,如-S 1-4 2-4 3-4 4-4
Environments
这些环境允许 3 次尝试(3 条命)通过游戏中的 32 个关卡。 环境只将有奖励的游戏画面帧发送给智能体;过场动画、加载画面等不会发送给智能体, 智能体也无法在这些时刻执行动作。如果过场动画无法通过修改 NES 内存跳过, 环境将阻塞 Python 进程直到模拟器准备好接受下一个动作。
| Environment | Game | ROM | 说明 | Screenshot |
|---|---|---|---|---|
SuperMarioBros-v0 |
SMB | standard | 原版画面,推荐使用 | |
SuperMarioBros-v1 |
SMB | downsample | 降采样画面 | |
SuperMarioBros-v2 |
SMB | pixel | 像素模式画面 | |
SuperMarioBros-v3 |
SMB | rectangle | 矩形模式画面 | |
SuperMarioBros2-v0 |
SMB2 | standard | 失落关卡原版画面 | |
SuperMarioBros2-v1 |
SMB2 | downsample | 失落关卡降采样画面 |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gymnasium_mariobros-1.0.1.tar.gz.
File metadata
- Download URL: gymnasium_mariobros-1.0.1.tar.gz
- Upload date:
- Size: 200.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e319b3a9df2c88b83a96de2299a1cef3d968fc3cf942cbeec17442b9dfc5498
|
|
| MD5 |
efa5eb9fa49810f5614e4afc8a20ed65
|
|
| BLAKE2b-256 |
6e4ba0f3bdddacc26399b4cc28715a4f6f1db25d033fb939402cf7b7eeb276ba
|
File details
Details for the file gymnasium_mariobros-1.0.1-py3-none-any.whl.
File metadata
- Download URL: gymnasium_mariobros-1.0.1-py3-none-any.whl
- Upload date:
- Size: 202.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d10541d5250b29ee81ab651c280051a2e7f6ead91de04bf32fd475d6ff03184
|
|
| MD5 |
4219595b6c8af4a8cd4194981aa1e1ba
|
|
| BLAKE2b-256 |
03734d401d4543dbf262cb4d657c2b97ca6e4b84cd54b6bd763ff6f497a8226b
|