Class OneHotGridSensor
Grid-based sensor with one-hot observations.
Inherited Members
Namespace: Unity.MLAgents.Sensors
Assembly: Unity.ML-Agents.dll
Syntax
public class OneHotGridSensor : GridSensorBase, ISensor, IDisposable
Constructors
OneHotGridSensor(string, Vector3, Vector3Int, string[], SensorCompressionType)
Create a OneHotGridSensor with the specified configuration.
Declaration
public OneHotGridSensor(string name, Vector3 cellScale, Vector3Int gridSize, string[] detectableTags, SensorCompressionType compression)
Parameters
Type | Name | Description |
---|---|---|
string | name | The sensor name |
Vector3 | cellScale | The scale of each cell in the grid |
Vector3Int | gridSize | Number of cells on each side of the grid |
string[] | detectableTags | Tags to be detected by the sensor |
Sensor |
compression | Compression type |
Methods
GetCellObservationSize()
Get the observation size for each cell. This will be the size of dataBuffer for Get
Declaration
protected override int GetCellObservationSize()
Returns
Type | Description |
---|---|
int | The observation size of each cell. |
Overrides
GetObjectData(GameObject, int, float[])
Get the one-hot representation of the detected game object's tag.
Declaration
protected override void GetObjectData(GameObject detectedObject, int tagIndex, float[] dataBuffer)
Parameters
Type | Name | Description |
---|---|---|
Game |
detectedObject | The game object that was detected within a certain cell |
int | tagIndex | The index of the detectedObject's tag in the DetectableObjects list |
float[] | dataBuffer | The buffer to write the observation values.
The buffer size is configured by Get |
Overrides
GetProcessCollidersMethod()
Whether to process all detected colliders in a cell. Default to false and only use the one closest to the agent.
If overriding Get
Declaration
protected override ProcessCollidersMethod GetProcessCollidersMethod()
Returns
Type | Description |
---|---|
Process |
Bool value indicating whether to process all detected colliders in a cell. |
Overrides
IsDataNormalized()
Whether the data is normalized within [0, 1]. The sensor can only use PNG compression if the data is normailzed.
If overriding Get
Declaration
protected override bool IsDataNormalized()
Returns
Type | Description |
---|---|
bool | Bool value indicating whether data is normalized. |