Skip to main content

A Gymnasium grid environment for educational purposes

Project description

pypi license tests

EduGrid

[!NOTE] EduGrid is intended for educational purposes and is hence not optimized for speed. If you don't need so much flexibility, have a look at the Gymmasium environments "Minigrid" and "Frozen Lake".

EduGrid is a Gymnasium grid environment with focus on flexibility for educational purposes. The agent moves in a grid of cells and tries to reach target cells. Furthermore, dynamic programming algorithms are implemented and can iteratively be inspected.

Features

  • The following environment properties can be inspected and modified:
    • transition_matrix with shape (rows, columns, actions, rows, columns) specifying the probabilities for all "state-action-next_state" transitions
    • reward_matrix with shape (rows, columns, actions, rows, columns) specifying the rewards for all "state-action-next_state" transitions
    • terminal_matrix with shape (rows, columns) specifying whether states are terminal.
  • Custom cells can be defined by implementing the abstract class Cell and overriding callbacks such as on_left, on_entered, on_step, is_blocking, and render.
  • The dynamic programming algorithms "policy evaluation", "policy iteration" and "value iteration" are implemented in edugrid.algorithms. They can iteratively be executed and inspected.

Installation

pip install edugrid

Examples

Environment creation and modification:

import edugrid
import gymnasium as gym

env = gym.make(
        "philsteg/EduGrid-v0",
        size=(3, 3),
        agent_location=(0, 0),
        wall_locations=[(2, slice(None))],
        sink_locations=[(0, 1), (1, 0)],
        target_locations=[(0, 2)],
        slip_prob=0.5,
    )

# Modify the reward matrix
env.unwrapped.reward_matrix[:, :, :, 0, 0] = 5

Algorithm: Value Iteration

import edugrid
from edugrid.algorithms.dynamic_programming import ValueIteration
import gymnasium as gym

env = gym.make("philsteg/EduGrid-v0")

value_iteration = ValueIteration(env, mode="state", gamma=1.0)

for i, values in enumerate(value_iteration.iter()):
    # Inspect the values in each iteration
    ...

policy = value_iteration.get_policy(values, type="stochastic")

See the more sophisticated examples in examples.

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

edugrid-0.0.2.tar.gz (23.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

edugrid-0.0.2-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

Details for the file edugrid-0.0.2.tar.gz.

File metadata

  • Download URL: edugrid-0.0.2.tar.gz
  • Upload date:
  • Size: 23.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for edugrid-0.0.2.tar.gz
Algorithm Hash digest
SHA256 9c725c17d7ef1becbfe8c0e05f586f63bcc1b7937bd2f5e59543c5a1a52b9c9c
MD5 ecbf06508a9dcdc3e5296fe9f6f848d0
BLAKE2b-256 e851489d51298e2bc3354885e9fdfcde27df58ed594ca871a6ba931c385bb9c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for edugrid-0.0.2.tar.gz:

Publisher: python-publish.yml on philsteg/edugrid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file edugrid-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: edugrid-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 21.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for edugrid-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 641219850e3fba531a22df7467b059e1a8a020d02a4d2a9581feeb01a7ca205c
MD5 2cb8834f580f0c50dfcd446095e3a1c1
BLAKE2b-256 e24f7a33cd19c2ffc1a8394c5f28ba9c4c6dea743bcde9a0bfa5a5ccec34705a

See more details on using hashes here.

Provenance

The following attestation bundles were made for edugrid-0.0.2-py3-none-any.whl:

Publisher: python-publish.yml on philsteg/edugrid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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