Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revisionBoth sides next revision
quick:agents [2020/02/18 10:04] – [ML-Agents Integration Guide] jesusmayoralquick:agents [2020/02/18 10:29] – [Setting-up the environment] jesusmayoral
Line 9: Line 9:
 To start creating a new tree with a behavior trained in ML-Agents in a project that is using Behavior Bricks, it is necessary to make the regular installantion of ML-Agents. More information can be retrieved in [the ML-Agents documentation.](https://github.com/Unity-Technologies/ml-agents/blob/master/docs/Installation.md) Once ML-Agents is installed, it is enough to drag the *ML-Agents* and *Gizmos* folders from `~/UnitySDK/Assets` to the Unity Project tab in order to import it to the project. To start creating a new tree with a behavior trained in ML-Agents in a project that is using Behavior Bricks, it is necessary to make the regular installantion of ML-Agents. More information can be retrieved in [the ML-Agents documentation.](https://github.com/Unity-Technologies/ml-agents/blob/master/docs/Installation.md) Once ML-Agents is installed, it is enough to drag the *ML-Agents* and *Gizmos* folders from `~/UnitySDK/Assets` to the Unity Project tab in order to import it to the project.
  
-First thing we are going to do is to prepare all necessary `gameObjects` that allow us to execute a trained model using ML-Agents: an `Academy`, a `Brain` and an `Agent`. Therefore, we start creating an empty `gameObject` in the scene and we add a C# script called `BBAcademy`. This script must extend `Academy`, so also must include ML-Agents, and should be left empty, since we only need the parameters and the functionality provided by inheritance. +First thing we are going to do is to prepare the necessary `gameObject` that allow us to execute a trained model using ML-Agents: an `Agent`. 
- +
-<code csharp> +
- using MLAgents; +
- +
- public class BBAcademy : Academy {} +
-</code> +
- +
-Now we create a `learning brain` (e.g. by right clicking in a folder of the project tab and `create/ML-Agents/Learning Brain`) and name it `EnemyBrain`. We left the by default parameters by now (we will modify these paremeters later). This brain have to be added to the `Academy Broadcast Hub`, leaving the `Control` box unchecked. +
- +
-{{:images:agents:EnemyBrain_ByDefaultParameters_Academy_AddLearningBrain.png}}+
  
 Before creating the C# script for our agent, we have to modify the player and the enemy: Before creating the C# script for our agent, we have to modify the player and the enemy:
Line 226: Line 216:
      }      }
  
-     public override void AgentAction(float[] vectorAction, string textAction)+     public override void AgentAction(float[] vectorAction)
      {      {
          // Actions, size = 2          // Actions, size = 2