/cartpole-q-learning

A cart pole balancing agent powered by Q-Learning.

Primary LanguagePythonMIT LicenseMIT

cartpole-q-learning

A cart pole balancing agent powered by Q-Learning. Uses Python 3 and Gymnasium (formerly OpenAI Gym).

Screenshot

Prerequisites

This project uses Poetry for managing Python packages and tools. Please install it first.

Then install the dependencies using:

$ poetry install --without dev --no-root

Running

To run the environment in verbose mode (with rendering, plotting, and detailed logging), run:

$ poetry shell
$ python run.py --verbose

To run in performance mode (no visualizations, only basic logging), run:

$ poetry shell
$ python run.py

Episode statistics will be available in experiment-results/episode_history.csv.

Troubleshooting

Issue: Episode History window not showing up on Linux

You may need to install the TkAgg backend support for matplotlib in order for the GUI window to show up properly. For example:

$ sudo apt install python3.10-tk

Development

Install the development dependencies:

$ poetry install --with dev --no-root

Install pre-commit hooks (recommended):

$ pre-commit install

Run unit tests:

$ pytest .