This project contains implementation of DQN, DDQN and Duel-DQN to train an agent to navigate (and collect bananas!) in a large, square world.
A reward of +1 is provided for collecting a yellow banana, and a reward of -1 is provided for collecting a blue banana. Thus, the goal of your agent is to collect as many yellow bananas as possible while avoiding blue bananas.The state space has 37 dimensions and contains the agent's velocity, along with ray-based perception of objects around agent's forward direction. Given this information, the agent has to learn how to best select actions. Four discrete actions are available, corresponding to:
0
- move forward.1
- move backward.2
- turn left.3
- turn right.
The task is episodic, and in order to solve the environment, your agent must get an average score of +13 over 100 consecutive episodes.
-
Install anaconda using installer at https://www.anaconda.com/products/individual according to your Operating System.
-
Create (and activate) a new environment with Python 3.6.
conda create --name drl python=3.6
activate drl
- Clone the repository (if you haven't already!), and navigate to the
python/
folder. Then, install several dependencies.
git clone https://github.com/KanikaGera/Navigation-Game-RL.git
cd python
conda install pytorch=0.4.1 cuda90 -c pytorch
pip install .
- Create an IPython kernel for the
drl
environment.
python -m ipykernel install --user --name drl --display-name "drl"
- Before running code in a notebook, change the kernel to match the
drl
environment by using the drop-downKernel
menu.
DQN
Folder consist of Deep Q Network Implementation . It has four files:
1.`Navigation.ipynb` consist of unityagent ml library to interact with unity environment and train the agent.
2.`model.py` consists of structure of RL model coded in pytorch.
3.`dqnagent.py` consist of DQN Algorithm Implementation
4. `model.pt` is saved trained model with weights.
Duel_DQN
Folder consist of Duel Deep Q Network Implementation. It has four files
1.`Navigation-Duel DQN.ipynb` consist of unityagent ml library to interact with unity environment and train the agent.
2.`duel_model.py` consists of structure of RL model coded in pytorch.
3.`duel_dqn_agent.py` consist of Duel-DQN Algorithm Implementation
4. `model_1.pt` is saved trained model with weights.
Double DQN
Folder consist of Duel Deep Q Network Implementation. It has three files
1.`Navigation-DDQN.ipynb` consist of unityagent ml library to interact with unity environment and train the agent.
2.`Navigation-DDQN-Test.ipynb` is to test trained agent .
3. `model_3.pt` is saved trained model with weights.
Video
A video of the agent collecting yellow bananas for a episode is uploaded in this folder.
-
Install Dependies by following commands in Getting Started
-
- Linux: click here
- Mac OSX: click here
- Windows (32-bit): click here
- Windows (64-bit): click here
(For Windows users) Check out this link if you need help with determining if your computer is running a 32-bit version or 64-bit version of the Windows operating system.
(For AWS) If you'd like to train the agent on AWS (and have not enabled a virtual screen), then please use this link to obtain the environment.
-
Place the file in the downloaded GitHub repository, in the main repository folder, and unzip (or decompress) the file.
-
Open the Folder according to the algorithm you want to run. Should open Double DQN if you want to train the best agent only.
- Open Navigation-[Model_Name].ipynb
- Run Jupyter Notebook
- Run the cells to train the model.
- In case of Double DQN , run cells of
Navigation-DDQN-Test.ipynb
. - For other algoruhms, run the last Cell of
Navigation-[Model_Name].ipynb
notebook to calculate the average reward over 100 episodes.
The best average reward over 100 episodes when training mode is off , was achieved by DDQN Algorithm. Report is uploaded in main folder for detailed explaination of algorithms and implementation details.