|
|
|
|
|
|
|
|
|
|
namespace Unity.MLAgents.Sensors |
|
|
|
{ |
|
|
|
public class BufferSensor : ISensor |
|
|
|
public class BufferSensor : ISensor, IDimensionPropertiesSensor |
|
|
|
{ |
|
|
|
private int m_MaxNumObs; |
|
|
|
private int m_ObsSize; |
|
|
|
|
|
|
return new int[] { m_MaxNumObs, m_ObsSize }; |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public DimensionProperty[] GetDimensionProperties() |
|
|
|
{ |
|
|
|
return new DimensionProperty[]{ |
|
|
|
DimensionProperty.VariableSize, |
|
|
|
DimensionProperty.None |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 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
|
|
|
|
|
|
|
} |
|
|
|
for (int i = 0; i < obs.Length; i++) |
|
|
|
{ |
|
|
|
m_ObservationBuffer[m_CurrentNumObservables * m_MaxNumObs + i] = obs[i]; |
|
|
|
m_ObservationBuffer[m_CurrentNumObservables * m_ObsSize + i] = obs[i]; |
|
|
|
} |
|
|
|
m_CurrentNumObservables++; |
|
|
|
} |
|
|
|