Unity Machine Learning Agents (ML-Agents) is an open-source Unity plugin that enables games and simulations to serve as environments for training intelligent agents.
For game developers, these trained agents can be used for multiple purposes, including controlling NPC behaviour (in a variety of settings such as multi-agent and adversarial), automated testing of game builds and evaluating different game design decisions pre-release.
In this project, we develop a Deep Q-Learning agent that utilises its newly acquired skills to navigate in a large, square example world and collect bananas. 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 the 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 the agent's forward direction. Given this information, the agent has to learn how to best select actions. Four discrete actions are available, corresponding to:
- move forward
- move backwards
- turn left
- 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.
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 navigation python=3.6 source activate navigation
- Windows:
conda create --name navigation python=3.6 activate navigation
-
Install Dependencies
-
Install Pytoch by following the instructions for your system here
-
To install the necessary dependencies run
pip install ./python
-
-
Download the Unity Environment
For this project, you will not need to install Unity - this is because we have already built the environment for you, and you can download it 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
- Create an IPython kernel for the
navigation
environment.
python -m ipykernel install --user --name navigation--display-name "navigation"
- Before running code in a notebook, change the kernel to match the
navigation
environment by using the drop-downKernel
menu.
Open the Navigation.ipynb
on a notebook and run the cells. In any case, the weights of a pretrained network are saved in checkpoint.pth
, so you can witness how a trained agent behaves.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.