bettermdptools provides classic planning and tabular reinforcement learning algorithms for Gymnasium environments.
- Planning: value iteration and policy iteration
- Reinforcement learning: Q-learning and SARSA
- Environments: discrete and discretized Gymnasium environments
- Experimentation: reusable experiment, plotting, and optional Optuna utilities
Installation
BetterMDPTools supports Python 3.12 through 3.14 and NumPy 2.x. The standard installation includes everything needed for planning, training, evaluation, plotting, and other non-rendering workflows, including use on Google Colab.
pip install bettermdptools
Optional Features
For local rendering support:
pip install "bettermdptools[rendering]"
For Optuna integration:
pip install "bettermdptools[optuna]"
To install both:
pip install "bettermdptools[rendering,optuna]"
Note: Rendering is optional and is not required for BetterMDPTools' core functionality. Rendering is not supported on Google Colab; use
render=Falsethere.
The rendering extra uses pygame-ce, which provides the pygame interface expected by Gymnasium. Classic pygame is not supported and should not be installed alongside pygame-ce.
Quick Start
The transition model for Gymnasium's built-in discrete environments is stored on the unwrapped environment:
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.unwrapped.P).value_iteration(gamma=0.99)
Plots.values_heat_map(V, title="State Values", size=(8, 8))
env.close()
bettermdptools wrappers expose generated tabular models through their own .P
property. The Blackjack wrapper uses a context-aware exact representation.
CartPole, Acrobot, and Pendulum use discretized models.
Documentation
User-facing examples and tutorials are available in the
examples/
directory.
High-level experiment and optional Optuna APIs are documented in:
The generated Python API reference is built from the package docstrings.
Development
Poetry is the source of truth for dependencies, builds, and documentation tooling:
poetry install --with docs
poetry run pytest -q
poetry run ruff check .
poetry run black --check .
poetry run pdoc bettermdptools -o docs
See CONTRIBUTING.md
for the complete contributor workflow.
License
bettermdptools is distributed under the BSD 3-Clause License. See
LICENSE.
Metadata
Release files for bettermdptools 0.10.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 |
|---|---|---|---|---|
| bettermdptools-0.10.0.tar.gz | 36.3 kB | Without provenance | Details for bettermdptools-0.10.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bettermdptools-0.10.0-py3-none-any.whl | Python 3 | none | any | Details for bettermdptools-0.10.0-py3-none-any.whl |
Total release size: 83.0 kB
Release files / bettermdptools-0.10.0.tar.gz
| Download URL | bettermdptools-0.10.0.tar.gz |
|---|---|
| Size | 36.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c552d240144bdee7cb2bc2cfb456fbea7d6a87aa560f959ee436c5d96ef50dd5
|
|
BLAKE2b-256 checksum How to use checksums |
615deca162c8f5c59f45c566ec88b7dce4614c37af1104930b01afe9a5438d02
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.13.9 Darwin/25.6.0
|
Release files / bettermdptools-0.10.0-py3-none-any.whl
| Download URL | bettermdptools-0.10.0-py3-none-any.whl |
|---|---|
| Size | 46.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8ac7778c883f5a5221f74a03204263af7a5d2d4ee2d2b10dd76ad5961f310522
|
|
BLAKE2b-256 checksum How to use checksums |
a1e1c1194f35c7af497bf70851bf2335a7c306cc500ab1f52981ba19243ba942
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.13.9 Darwin/25.6.0
|
Security for bettermdptools 0.10.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.