Note: This repository is based on a ml-agents branch.
Overview
This is an AI and Machine Learning with Unity ML-Agents project!
This project aims to explore, test, optimize Deep Reinforcement
Learning (DRL) algorithms for controlling agents in Unity game engine.
We will develop custom sensors, experiment with environments and
document our results.
Table of Contents
- Introduction
- Objectives
- Project Description
- Getting Started
- Installation Guide
- Project Phases
- Risk Analysis
- Usage Instructions
- References and Resources
- Project Contributors
Introduction
This project is about putting Deep Reinforcement Learning (DRL) to work in Unity.
We will be using Unity's Ml-Agents (Unity-Technologies, n.d.) to build agents
that can fulfill different tasks in 3D game.
Objectives
The main objectives of this project are as follows:
- Implement Deep Reinforcement Learning (DRL) using the ML-Agents Toolkit, train
agents in pre-made 3D games and fine-tune the models to achieve better performance
- Design and implement new sensors inputs for agents in Unity to enhance their
ability to interact and perceive the environment and make the pre-made models mimic
the real world.
- Evaluate the performance of the created algorithm using metrics, training time,
resource usage, the framerate of the stimulation and optimize agents behaviour by
exploring different environment complexity, sensor configurations and hyperparameters
Project Description
For this project, we will be using Unity Game Engine with the Ml-Agents toolkit
to create a 3D stimulation environment. Unity will handle the visual aspects
and the in-game logic. Ml-Agents, written in Python, will manage the
decision-making process. By combining those two we will explore and analyse the DRL techniques
in real-time simulations and hypertune the agents through thorough testing
Key Software Components
- Unity: Used for creating, stimulating and publishing 3D (and 2D) games
- Ml-Agents Toolkit: Used to integrate Unity and Machine Learning Agent behaviours
- C#: handles the game mechanics using Unity scripts
- Python: Runs the machine learning algorithms
Getting Started
Prerequisites
- Git: Version control software used to manage the respository
- Unity game Engine: Required for 3D stimulation
- Python(v3.10.x): Used for Ml-Agents
- Ml-Agents Toolkit: Used for training and manging agents
Installation Guide
- Clone The Repository:
git clone https://github.com/AlexNicSor/ml-agents-unity.git
cd ml-agents-unity
- Set Up Virtual Environment
python -m venv venv
MAC/Linux: source venv/bin/activate
Windows: venv\Scripts\activate
- Install ML-Agents:
pip install --upgrade pip
pip install -e ./ml-angents-envs
pip install -e ./ml-angents
- Test instalation:
ml-agents-learn --help
- Additional dependencies:
pip install torch torchvision torchaudio
- Install Unity: Download and install Unity
Project Phases
Our future plans for this project are split into two phases and include the following tasks:
-
Phase 2 Tasks
- Implement Baseline Algorithm for Scenario Adaptation.
- Parameter Adjustment for Algorithm Optimization.
- Code Addition for New Input Type in Soccer Twos
- Peripheral Vision and Advanced Input Simulation
-
Phase 3 Tasks
- Establish Baseline Performance of Algorithm in a selected envi-
ronment(Chosen Game)
- Experiment with Parameter Tuning
- Experiment with different sensor/input types
Risk Analysis
- Lack of Experience: Some team members are new to Unity and Ml-Agents, this will pose a challenge
- Computational Constraints: Training deep RLM can be resource-intensive and may require significant computational power
- Time Management:Balancing the project tasks effectively will be important, since we are occupied with different courses
- Debugging Issues:Debugging issues with complex agents, environments and Unity might be challenging and time-consuming
Usage Instructions
To use the cloned repository, after all other installation steps are completed:
- Open unity hub.
- Press the add button and select the add from disk option.
- Navigate to the location of the cloned repository.
- Select the folder named Project and add it.
- Open the project.
- Select the examples folder located at the bottom left of your screen.
- Select the example game that you want to run.
- Select the Scences folder and then the scene you want to run.
- Press play, located at the top middle part of your screen.
References and Resources
- Unity-Technologies. (n.d.-b). GitHub - Unity-Technologies/ml-agents: The Unity Machine Learning Agents Toolkit (ML-Agents) is an open-source project that enables games and simulations to serve as environments for training intelligent agents using deep reinforcement learning and imitation learning. GitHub. https://github.com/Unity-Technologies/ml-agents
- Unity documentation. (n.d.). Unity Documentation. https://docs.unity.com/
- Van Rossum, G., & Drake, F. L. (2009). Python 3 Reference Manual. In CreateSpace eBooks. https://dl.acm.org/citation.cfm?id=1593511
Contributors
This project was developed by the following group of Maastricht University computer
science students:
- Alexandru Lazarina
- Karol Plandowski
- Marios Petrides
- Carl Balagtas
- Marcel Pendyk
- Ethan de Beer
- Hadi Ayoub