Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revisionLast revisionBoth sides next revision | ||
quick:agents [2020/02/18 15:05] – [Setting-Up the execution with Behavior Bricks] jesusmayoral | quick:agents [2020/09/03 09:46] – pedro | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | < | ||
# ML-Agents Integration Guide | # ML-Agents Integration Guide | ||
Line 16: | Line 17: | ||
- Add a cube to the enemy above the `shootpoint` scaled to (0.1, 0.1, 0.3) at the relative position (0, 0.5, 0.5). This will tell us where the enemy is aiming. | - Add a cube to the enemy above the `shootpoint` scaled to (0.1, 0.1, 0.3) at the relative position (0, 0.5, 0.5). This will tell us where the enemy is aiming. | ||
- | {{: | + | ![](: |
In addition, we have to modify the way the enemy shoots in order to fit the training and the execution of the agent. Specifically, | In addition, we have to modify the way the enemy shoots in order to fit the training and the execution of the agent. Specifically, | ||
Line 22: | Line 23: | ||
The script `FiredBullet` consists in giving intelligence to the bullet, so it can tell if the it has impacted the player, besides autodestroy passed 2 seconds (or whatever the time indicated by the parameter). Additionally, | The script `FiredBullet` consists in giving intelligence to the bullet, so it can tell if the it has impacted the player, besides autodestroy passed 2 seconds (or whatever the time indicated by the parameter). Additionally, | ||
- | < | + | |
+ | ```csharp | ||
using UnityEngine; | using UnityEngine; | ||
Line 61: | Line 63: | ||
} | } | ||
} | } | ||
- | </ | + | ``` |
The code should be self-explanatory, | The code should be self-explanatory, | ||
Line 71: | Line 73: | ||
The script `EnemyShoot` implements the shooting capacity of the enemy agent. We create a C# script that extends `Monobehaviour` based on the previous script `ShootOnce`. | The script `EnemyShoot` implements the shooting capacity of the enemy agent. We create a C# script that extends `Monobehaviour` based on the previous script `ShootOnce`. | ||
- | < | + | ```csharp |
using UnityEngine; | using UnityEngine; | ||
Line 148: | Line 150: | ||
} | } | ||
} | } | ||
- | </ | + | ``` |
We have to note the following points: | We have to note the following points: | ||
Line 159: | Line 161: | ||
Finally, we create the C# script `EnemyAgent`, | Finally, we create the C# script `EnemyAgent`, | ||
- | < | + | ```csharp |
using UnityEngine; | using UnityEngine; | ||
Line 252: | Line 254: | ||
} | } | ||
} | } | ||
- | </ | + | ``` |
This class has three main methods that are overriden from the `Agent` class. Explaining why this methods have to be overridden and how Agent class works is out of the scope of this guide. The concrete implementation of these methods is described below. | This class has three main methods that are overriden from the `Agent` class. Explaining why this methods have to be overridden and how Agent class works is out of the scope of this guide. The concrete implementation of these methods is described below. | ||
Line 274: | Line 276: | ||
- | {{: | + | ![](: |
Line 283: | Line 285: | ||
- | {{: | + | ![](: |
Line 291: | Line 293: | ||
- | {{: | + | ![](: |
Line 302: | Line 304: | ||
- | {{: | + | ![](: |
Line 308: | Line 310: | ||
- | {{: | + | ![](: |
Line 318: | Line 320: | ||
- We have 2 continuous actions, one to rotate and one to shoot, that is the space size. | - We have 2 continuous actions, one to rotate and one to shoot, that is the space size. | ||
- | You need to train our Enemy for having a proper behavior, but, for now, we give you a trained model that you can set in the `Behavior parameters` | + | You need to train our Enemy for having a proper behavior, but, for now, we give you a trained model that you can set in the `Behavior parameters` |
- | {{: | + | ![](: |
## Training | ## Training | ||
- | The node used to execute `ML-Agents` in `Behavior Bricks` lets also to train a behavior inside a behavior tree. To do so, the only thing that has to be done is to check the control checkbox | + | The node used to execute `ML-Agents` in `Behavior Bricks` lets also to train a behavior inside a behavior tree. To do so, We have to follow |
- | Then we have to follow the same procedure as indicated in [ML-Agents guides.](https: | + | </markdown> |