Skip to main content

so much room for activities

Project description

PyPI Python Versions License: MIT Code Style: Black Linter: Ruff CircleCI

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),
)

grid_state_values

Example notebooks

The fastest way to explore the library is through the notebooks in /examples .


Entrypoint APIs (optional)

Bettermdptools provides optional high-level entrypoints for quick experimentation and hyperparameter search.

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:

  1. Fork the repository
  2. Create a feature branch
  3. Commit changes
  4. Open a pull request

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

bettermdptools-0.8.6.tar.gz (936.3 kB view details)

Uploaded Source

File details

Details for the file bettermdptools-0.8.6.tar.gz.

File metadata

  • Download URL: bettermdptools-0.8.6.tar.gz
  • Upload date:
  • Size: 936.3 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

Hashes for bettermdptools-0.8.6.tar.gz
Algorithm Hash digest
SHA256 4327c3d1295cdeb26138f9c1cf1265d07b45a9dfb1ec6fe3c9492d5da2130df1
MD5 a34e25631269bf25cf7e1a3e06405cdd
BLAKE2b-256 10b32a4219af60e5427af8011bdd9b99a0b0105edccd738e980a19167acb3a59

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