For this project, I trained 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.
-
Download the environment from one of the links below. You need only select the environment that matches your operating system:
- 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.
To train an agent using the code in this repository, you will need to follow the set up instructions below:
- Create and activate a Python 3.6 environment using Anaconda (
env_name
can be replaced with any name):
$ conda create --name env_name python=3.6
$ source activate env_name
- Clone this repository and install the dependencies:
$ git clone https://github.com/hmisra/DRL-Navigation.git
$ cd python
$ pip install .
- The structure of the code repository is as follows:
p1_navigation/
checkpoint.pth
dqn_agent.py
model.py
unity-environment.log
README.md
p1_navigation_solution.ipynb
Report.ipynb
python/
__pycache__/
-
Extract the banana.app.zip file in the directory.
-
Launch
p1_navigation_solution.ipynb
in Jupyter and start training the agent by executing the code in the notebook.
$ jupyter notebook
dqn_agent.py
contains theAgent
andReplayBuffer
classes for the agent to interact with the environment.model.py
contains the Pytorch neural network used to approximate the Q-value functions that the agent will be using.p1_navigation_solution.ipynb
is the code entry point for starting the environment and the training loop.Report.ipynb
contains description of the solution and hyperparameters etc.unity-environment.log
is the log file that is created during the training loop.checkpoint.pth
contains the weights of the Pytorch model once the environment is successfully solved.banana.app.zip
contains the unity environment file.python\
directory contains all the dependencies.