gymDSM
gymDSM (Didactically Supercharged Mod): A modified version of Gymnasium (the maintained successor of OpenAI Gym).
What is gymDSM?
gymDSM is a small Python package that provides didactically enhanced (teaching-friendly) variants of classic Gymnasium environments.
MountainCar
At the moment, gymDSM focuses on MountainCar with a small (but important) visual modification: the car’s color reflects the last action taken:
0(push left) → red1(no push) → blue2(push right) → green
The goal is to make it easier to understand what an agent is doing while interacting with the environment.
Everything else (physics, rewards, observation/action spaces, seeding, the 200-step time limit, and the goal_velocity parameter) is identical to Gymnasium's Mountain Car, because the gymDSM environment subclasses it and only changes the rendering.
Installation
The library gymDSM is on the Python Package Index.
To install the library, first install pip and then use the command pip install gymDSM. Alternatively, you can use pip install gymdsm. Remember that pip/PyPI treat distribution names case-insensitively.
This project works with Gymnasium 1.0 or newer (tested with Gymnasium 1.0.0 and 1.4.0), which is installed automatically as a dependency.
If you want to use rendering (render_mode="human" or render_mode="rgb_array"), use the following installation command:
pip install "gymDSM[render]"
(The command above installs gymnasium[classic-control], which brings in the pygame version that your Gymnasium release expects.)
Upgrading from gymDSM 1.x (Gym 0.22)? See Migrating from gymDSM 1.x below.
Minimal Working Example (MWE)
1) Create the environment using gymDSM.make
This is designed to be easily replaceable with the usual Gymnasium pattern:
import gymDSM
env = gymDSM.make("MountainCar-v0")
obs, info = env.reset(seed=42)
done = False
while not done:
action = env.action_space.sample() # random policy
obs, reward, terminated, truncated, info = env.step(action)
done = terminated or truncated
env.close()
2) Render in a window (optional)
In Gymnasium, the render mode is chosen when the environment is created. With render_mode="human", the window is updated automatically on every reset() and step(), so there is no need to call env.render():
import gymDSM
env = gymDSM.make("MountainCar-v0", render_mode="human") # requires pygame
obs, info = env.reset(seed=42)
done = False
while not done:
action = env.action_space.sample()
obs, reward, terminated, truncated, info = env.step(action)
done = terminated or truncated
env.close()
3) Get frames as images (optional)
Use render_mode="rgb_array" to get each frame as a NumPy array of shape (400, 600, 3), e.g., to record videos or show them in a Jupyter notebook:
import gymDSM
env = gymDSM.make("MountainCar-v0", render_mode="rgb_array") # requires pygame
obs, info = env.reset(seed=42)
obs, reward, terminated, truncated, info = env.step(2) # push right
frame = env.render() # the car is green in this frame
env.close()
Behavior and supported environments
For now, only Gymnasium's Mountain Car environment is supported.
-
If you call:
env = gymDSM.make("MountainCar-v0")
gymDSM will try to create the gymDSM MountainCar variant (with action-based colors).
-
If
env_idis not supported by gymDSM, or if creating the gymDSM version fails for any reason,gymDSM.make(...)falls back to:gymnasium.make(env_id, ...)
using the standard Gymnasium environment (a warning is shown if the gymDSM version failed).
-
Importing gymDSM also registers the colored environment in Gymnasium under the ID
ColoredActionMountainCar-v0, so it can be used with plain Gymnasium too (e.g., with vectorized environments or RL libraries that callgymnasium.makeinternally):import gymnasium as gym import gymDSM # registers "ColoredActionMountainCar-v0" env = gym.make("ColoredActionMountainCar-v0", render_mode="rgb_array")
Migrating from gymDSM 1.x (Gym 0.22)
gymDSM 2.0 follows the Gymnasium API. If you have code written for gymDSM 1.x, update it as follows:
| gymDSM 1.x (Gym 0.22) | gymDSM 2.x (Gymnasium) |
|---|---|
obs = env.reset() |
obs, info = env.reset(seed=None) |
obs, reward, done, info = env.step(a) |
obs, reward, terminated, truncated, info = env.step(a)done = terminated or truncated |
env.render() / env.render(mode="rgb_array") |
gymDSM.make(..., render_mode="human") or render_mode="rgb_array", then env.render() (no arguments) |
env.seed(42) |
env.reset(seed=42) |
import gym |
import gymnasium as gym |
terminated is True when the car reaches the flag; truncated is True when the 200-step time limit is reached.
License and Acknowledgments
gymDSM is an independent open-source project that originates from a fork of OpenAI Gym and is now built on top of Gymnasium. This project is not affiliated with or endorsed by OpenAI or the Farama Foundation. gymDSM is developed for research and educational purposes. It builds upon the foundation laid by the OpenAI Gym and Gymnasium libraries, and we acknowledge and thank the original OpenAI Gym authors, the Farama Foundation, and all contributors for their pioneering work.
gymDSM, the original OpenAI Gym, and Gymnasium are released under the MIT License. We have retained the original project's MIT licensing for gymDSM, ensuring that any use or distribution of this fork complies with the same terms. Please see the LICENSE file in this repository for the full text of the MIT License.
Metadata
Release files for gymDSM 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gymdsm-2.0.0.tar.gz | 8.9 kB | Without provenance | Details for gymdsm-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gymdsm-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for gymdsm-2.0.0-py3-none-any.whl |
Total release size: 18.1 kB
Release files / gymdsm-2.0.0.tar.gz
| Download URL | gymdsm-2.0.0.tar.gz |
|---|---|
| Size | 8.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
af927865582f8745ce5443f3c6efd18057ad4444b976ec20b0c58a937b3844ed
|
|
BLAKE2b-256 checksum How to use checksums |
e2c532b513c0d8c312b170e748675575d463542b4fa0236cc8c51523efc04a76
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.16
|
Release files / gymdsm-2.0.0-py3-none-any.whl
| Download URL | gymdsm-2.0.0-py3-none-any.whl |
|---|---|
| Size | 9.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3c767495cd839676847fc3a6c5ec89adb75ffae39b7649fa28cd31c3e1a427fa
|
|
BLAKE2b-256 checksum How to use checksums |
d719b2575a81a7c3fdd9038886c35ea1c9ac0b111fea9a3c116c3ee2c2b0e75d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.16
|
Security for gymDSM 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.