Skip to content

Simple PyTorch implementation of Deep Q-learning Algorithm to play Lunar Lander.

License

Notifications You must be signed in to change notification settings

LemuelPuglisi/Lunar-Lander-DQN

Repository files navigation


Lunar Lander - DQN

animated

A simple PyTorch implementation of the Deep Q-Learning algorithm to solve Lunar Lander environment from Gymnasium.


AI Course Project - UniCT, DMI.

Pretrained models

Replay Memory Capacity Target-network sync-rate Pre-trained models folder
500000 10 link
50000 10 link
5000 10 link
500000 1 link
500000 100 link

Installation

Download and install Anaconda or miniconda from the official website. Make it works by opening a shell and running:

$ conda env list

This should prompt the list of your conda environments. Now create a new environment:

$ conda create -n dqn python=3.9

And activate the new env:

$ conda activate dqn

Finally, clone the repository and install the aicourse module running the following inside the project folder:

$ pip install -e .

Running the model

Select one checkpoint from the models folder, then use the play.py script to let the agent play one episode:

(your_env) <Lunar-Lander-DQN> python play.py --help

usage: play.py [-h] [--model-ckpt MODEL_CKPT] [--episodes EPISODES]

optional arguments:
  -h, --help            show this help message and exit
  --model-ckpt MODEL_CKPT
  --episodes EPISODES

Example:

python play.py --model-ckpt models/ll-cap_500000_sr_10/models/ll-ep50.ckpt

Training

Start the training using train.py script:

(your_env) <Lunar-Lander-DQN> python train.py --help

usage: train.py [-h] [--dest DEST] [--epochs EPOCHS] [--episodes EPISODES] [--batch-size BATCH_SIZE] [--capacity CAPACITY]
                [--sync-rate SYNC_RATE]

optional arguments:
  -h, --help                show this help message and exit
  --dest DEST               destination folder
  --epochs EPOCHS           number of epochs
  --episodes EPISODES       number of episodes to play in an epoch
  --batch-size BATCH_SIZE   batch size on trainin phase
  --capacity CAPACITY       capacity of the replay memory
  --sync-rate SYNC_RATE     sync rate of the target network

Authors

About

Simple PyTorch implementation of Deep Q-learning Algorithm to play Lunar Lander.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •