using UnityEngine;
namespace Unity.MLAgents.Sensors
{
///
/// A component for BufferSensor.
///
[AddComponentMenu("ML Agents/Buffer Sensor", (int)MenuGroup.Sensors)]
internal class BufferSensorComponent : SensorComponent
{
public int ObservableSize;
public int MaxNumObservables;
private BufferSensor m_Sensor;
///
public override ISensor CreateSensor()
{
m_Sensor = new BufferSensor(MaxNumObservables, ObservableSize);
return m_Sensor;
}
///
public override int[] GetObservationShape()
{
return new[] { MaxNumObservables, ObservableSize };
}
///
/// Appends an observation to the buffer. If the buffer is full (maximum number
/// of observation is reached) the observation will be ignored. the length of
/// the provided observation array must be equal to the observation size of
/// the buffer sensor.
///
/// The float array observation
public void AppendObservation(float[] obs)
{
m_Sensor.AppendObservation(obs);
}
}
}