so much room for activities
Project description
bettermdptools
Bettermdptools is a lightweight toolkit for working with Gymnasium environments using classic planning and tabular reinforcement learning methods.
It is designed to help users get up and running quickly, explore standard RL algorithms, and experiment with environments like FrozenLake, Taxi, Blackjack, and CartPole without heavy framework overhead.
Getting started
Install
Install from PyPI:
pip install bettermdptools
pygame installation issues (Python 3.11+)
If you encounter errors installing pygame on Python 3.11 or newer, try:
pip install pygame --pre
Google Colab notes (NumPy + Gymnasium)
Some Gymnasium-compatible environments may require a NumPy downgrade.
When using Google Colab - after installing numpy<2 you must restart the Colab session for the change to take effect.
Typical workflow:
pip install "numpy<2"
Then:
Runtime → Restart session
Quick example (FrozenLake)
Below is a minimal example using value iteration on FrozenLake:
import gymnasium as gym
from bettermdptools.algorithms.planner import Planner
from bettermdptools.utils.plots import Plots
env = gym.make("FrozenLake8x8-v1", render_mode=None)
V, V_track, pi = Planner(env.P).value_iteration()
Plots.values_heat_map(
V,
title="FrozenLake Value Iteration - State Values",
size=(8, 8),
)
Example notebooks
The fastest way to explore the library is through the example notebooks in the examples/ directory.
Core environments
-
examples/frozen_lake.ipynb
Planning and tabular RL on FrozenLake -
examples/blackjack.ipynb
Q-learning on Blackjack -
examples/cartpole.ipynb
Discretized CartPole using a wrapper for tabular methods
Experiments API
examples/experiments_demo.ipynb
Demonstrates the optionalbettermdptools.experiments.run(...)entrypoint across:- FrozenLake (VI and Q-learning)
- Blackjack (Q-learning)
- CartPole (discretized)
Utilities and plotting
-
examples/plots.ipynb
Visualization helpers -
examples/other_utilities.ipynb
Miscellaneous helpers
These notebooks are intended as examples and starting points, not benchmarks.
Experiments API (optional)
Bettermdptools includes an optional high-level experiments entrypoint that wires together:
- environment creation
- transition model handling
- algorithm dispatch
- optional policy evaluation
Primary entrypoint:
from bettermdptools.experiments import run
See:
Development and tooling
Dependency management
The project supports standard pip workflows. For development, using Poetry is recommended to ensure reproducible environments.
Example:
poetry install
poetry shell
Code quality
The codebase uses the following tools during development:
- ruff for fast linting
- black for code formatting
Typical usage:
ruff check .
black .
Documentation
API documentation is generated using pdoc (not pdoc3) and lives in the docs/ directory.
To regenerate documentation locally:
pdoc --include-undocumented -d numpy -t docs-templates --output-dir docs bettermdptools
Contributing
Pull requests are welcome.
Guidelines:
- Use numpy-style docstrings
- Add or update tests when introducing new functionality
- Prefer explicit, readable code over clever or showy abstractions
- Format code with black and check linting with ruff before submitting
- Keep public APIs stable and avoid breaking changes unless clearly justified
- Prefer small, focused pull requests with a limited number of file changes
Basic workflow:
- Fork the repository
- Create a feature branch
- Commit changes
- Open a pull request
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
File details
Details for the file bettermdptools-0.8.5.tar.gz.
File metadata
- Download URL: bettermdptools-0.8.5.tar.gz
- Upload date:
- Size: 936.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.66.1 urllib3/1.26.5 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25a7ba44edc03098734982a0eab70b825f7483be13a03033458deea7ac27c018
|
|
| MD5 |
796abc92a34e049cedb745a86bcbacdf
|
|
| BLAKE2b-256 |
fba750fe775aac2f63f02315bb325fc0745e81ef164fdfcaeaac4269b54ff7c6
|