Skip to main content

A random walk environment for Gymnasium

Project description

Random Walk

This environment reflects the Markov Reward Process (MRP) defined in Example 6.2 Random Walk of the book Reinforcement Learning An Introduction (2nd Ed) by Richard S. Sutton and Andrew G. Barto.
The Random Walk Environment is a custom Gymnasium environment that simulates a simple random walk process. The agent starts in a predefined state and moves randomly to adjacent states (left or right) at each timestep. The states are arranged in a row, with terminal states at both ends. The rightmost terminal state rewards the agent with +1, while all other transitions have a reward of 0. The environment is ideal for experiments in reinforcement learning or Markov Reward Processes (MRPs), focusing on stochastic state transitions without actions.

Installation

pip install random-walk-env

Use with gymnasium

import random_walk_env
import gymnasium as gym

env = gym.make('random_walk_env/RandomWalk-v0')

Note

As per the gymnasium API for the step function, an action must be provided. However, this value is ignored as this environment represents a Markov Reward Process (and not a Markov Decision Process).

The terminal states are represented by * (asterisk). Terminal states are the leftmost and the rightmost states.

You can set the number of (nonterminal) states and the index of the start state as the following.

env = gym.make('random_walk_env/RandomWalk-v0', num_states=6, start_state=4) # *ABCD[E]F*

Default is num_states=5, start_state=2 (*AB[C]DE*).

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

random_walk_env-0.0.4.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

random_walk_env-0.0.4-py2.py3-none-any.whl (4.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file random_walk_env-0.0.4.tar.gz.

File metadata

  • Download URL: random_walk_env-0.0.4.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for random_walk_env-0.0.4.tar.gz
Algorithm Hash digest
SHA256 88fa26623e0f86a0134135c1bf74f2a10dd731b41bcac3ad21859e81967b339b
MD5 d81704ef995716a26db4a53a159b0159
BLAKE2b-256 74f947754d0feadab2a238df3410ac0e4f4d4d5923e564017c7f9349dc031d07

See more details on using hashes here.

File details

Details for the file random_walk_env-0.0.4-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for random_walk_env-0.0.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 5c81f56dbac97ec984d63ae5982b7e63954150f29e3c9b936bf1e84909bc6f06
MD5 ae75671462b455b591c144d063daf1e4
BLAKE2b-256 d783ee2cb840baab560a2dbbc97edc935cbbb8ec33fc022079162d776b989153

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