How do Unity ML-Agents work?

Before training our agent, we need to understand what ML-Agents is and how it works.

What is Unity ML-Agents?

Unity ML-Agents is a toolkit for the game engine Unity that allows us to create environments using Unity or use pre-made environments to train our agents.

It’s developed by Unity Technologies, the developers of Unity, one of the most famous Game Engines used by the creators of Firewatch, Cuphead, and Cities: Skylines.

Firewatch
Firewatch was made with Unity

The six components

With Unity ML-Agents, you have six essential components:

MLAgents
Source: Unity ML-Agents Documentation

Inside the Learning Component

Inside the Learning Component, we have two important elements:

To better understand its role, let’s remember the RL process. This can be modeled as a loop that works like this:

The RL process
The RL Process: a loop of state, action, reward and next state
Source: Reinforcement Learning: An Introduction, Richard Sutton and Andrew G. Barto

Now, let’s imagine an agent learning to play a platform game. The RL process looks like this:

The RL process

This RL loop outputs a sequence of state, action, reward and next state. The goal of the agent is to maximize the expected cumulative reward.

The Academy will be the one that will send the order to our Agents and ensure that agents are in sync:

The MLAgents Academy

Now that we understand how ML-Agents works, we’re ready to train our agents.

< > Update on GitHub