Skip to content

joaopamaral/deep_reinforcement_learning_nd_navigation_p1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Udacity Deep Reinforcement Learning Nanodegree

Project 1: Navigation

Introduction

For this project, an agent is trained to collect bananas in a large, square world.

Trained Agent

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, the agent must get an average score of +13 over 100 consecutive episodes.

The Environment

The environment is a square world where a single agent will navigate to collect bananas.

  • Number of agents: 1
  • Number of actions: 4
  • State length: 37
    • Example: [1., 0., 0., 0., 0.84408134 0., 0., 1., 0., 0.0748472 0., 1., 0., 0., 0.25755 1., 0., 0., 0., 0.74177343 0., 1., 0., 0., 0.25854847 0., 0., 1., 0., 0.09355672, 0., 1., 0., 0., 0.31969345 0., 0.]

Getting Started

  1. Download the environment from one of the links below. Select the environment that matches your operating system:

    (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.

  2. Place the file in the DRLND GitHub repository, in the p1_navigation/ folder, and unzip (or decompress) the file.

Dependencies

To set up your python environment to run the code in this repository, follow the instructions below.

  1. Create (and activate) a new environment with Python 3.6.

    • Linux or Mac:
    conda create --name drlnd python=3.6
    source activate drlnd
    • Windows:
    conda create --name drlnd python=3.6 
    activate drlnd
  2. Install all dependencies from requirements.txt:

pip install -r requirements.txt
  1. Install Pytorch version 0.4.0 with your correct Cuda version (in my case, I'm using cuda 10.0).
conda install -n drlnd pytorch=0.4.0 cudatoolkit=10.0 -c pytorch

4 - Create an IPython kernel for the drlnd environment.

python -m ipykernel install --user --name drlnd --display-name "drlnd"

Instructions

Follow the instructions in Report.ipynb to get started with training the agent!

Result

In episode 600, the agent achieved the expected result 👍 (score >= 13). We kept training the agent until 2000 episodes, and the final mean score was higher than 16 🚀.

Chart result yellow

So let's see what happen to the agent:

We started with a random agent After 2000 episodes he learned to collect yellow bananas

Bonus

What happen if we invert the reward and train the agent again? The agent will learn to collect blue banana?

Yes, as we see below, the agent learned to collect blue bananas 🤘!

About

Project 1 (Navigation) from Udacity Deep Reinforcement Learning Nanodegree

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published