In this project, we train an agent to navigate a large, square world to collect yellow bananas while avoiding blue bananas. We use a Unity ML-Agents based environment provided by Udacity for this exercise. More details about the environment is provided below.
The state space has 37 dimensions and contains the agent's velocity, along with ray-based perception of objects around the agent's forward direction. Given this information, the agent has to learn how to best select actions.
The agent can take one of four discrete actions, corresponding to:
action_id | action |
---|---|
0 | move forward |
1 | move backward |
2 | turn left |
3 | turn right |
A reward of +1 is provided for collecting a yellow banana, and a reward of -1 is provided for collecting a blue banana. The goal of the agent is to collect as many yellow bananas as possible while avoiding blue bananas.
The task is episodic - there are 300 time-steps in each episode (by default; this setting can be changed). The environment is considered solved when the agent gets an average score of +13 over 100 consecutive episodes.
To set up your python environment to run the code in this repository, follow the instructions below.
-
Create (and activate) a new environment with Python 3.6.
- Linux or Mac:
conda create --name drlnd python=3.6 conda activate drlnd
- Windows:
conda create --name drlnd python=3.6 conda activate drlnd
-
Clone the repository (if you haven't already!), and navigate to the
python/
folder. Then, install several dependencies.git clone https://github.com/nsriram13/rl-navigation.git cd rl-navigation/python pip install .
-
Create an IPython kernel for the
drlnd
environment.python -m ipykernel install --user --name drlnd --display-name "drlnd"
-
Before running code in a notebook, change the kernel to match the
drlnd
environment by using the drop-downKernel
menu. -
This repository uses pre-commit hooks for auto-formatting and linting.
- Run
pre-commit install
to set up the git hook scripts - this installs flake8 formatting, black auto-formatting as pre-commit hooks. - Run
gitlint install-hook
to install the gitlint commit-msg hook - (optional) If you want to manually run all pre-commit hooks on a repository,
run
pre-commit run --all-files
. To run individual hooks usepre-commit run <hook_id>
.
- Run
-
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.
-
Place the file in the root directory of this repo and unzip (or decompress) the file. The notebook to train the agent will look for the environment at the project root.
Follow the instructions in Navigation.ipynb
to train the agent.