Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
quick:agents [2019/03/01 11:22] victorzamoraquick:agents [2020/02/18 10:29] – [Setting-up the environment] jesusmayoral
Line 5: Line 5:
 This tutorial continues the small example created in the BT tutorials, where the player moves his avatar in the “environment” (a mere plane) using mouse clicks, and the enemy wanders around and pursues the player when he is near enough. We encourage you to follow that tutorial in the first place but, if you are impatient, its final version (and the starting point for this guide) is available in the Behavior Bricks package, under `Samples\ProgrammersQuickStartGuide\Done` folder. Obviously, you are supposed to have been loaded Behavior Bricks into a new Unity project. Refer to the download instructions in other case. This tutorial continues the small example created in the BT tutorials, where the player moves his avatar in the “environment” (a mere plane) using mouse clicks, and the enemy wanders around and pursues the player when he is near enough. We encourage you to follow that tutorial in the first place but, if you are impatient, its final version (and the starting point for this guide) is available in the Behavior Bricks package, under `Samples\ProgrammersQuickStartGuide\Done` folder. Obviously, you are supposed to have been loaded Behavior Bricks into a new Unity project. Refer to the download instructions in other case.
  
-The final scene and all the contents of this ML-Agents integration guide is also available in the Behavior Bricks package, under `Samples\MLAgentsIntegrationGuide\Done` folder. 
  
 ## Setting-up the environment ## Setting-up the environment
 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 227: Line 216:
      }      }
  
-     public override void AgentAction(float[] vectorAction, string textAction)+     public override void AgentAction(float[] vectorAction)
      {      {
          // Actions, size = 2          // Actions, size = 2