浏览代码

Merge pull request #3588 from Unity-Technologies/develop-remove-duplicate-SensorBase

remove duplicate version of SensorBase
/bug-failed-api-check
GitHub 5 年前
当前提交
4e05233f
共有 2 个文件被更改,包括 0 次插入65 次删除
  1. 11
      com.unity.ml-agents/Runtime/Sensors/SensorBase.cs.meta
  2. 54
      com.unity.ml-agents/Runtime/Sensors/SensorBase.cs

11
com.unity.ml-agents/Runtime/Sensors/SensorBase.cs.meta


fileFormatVersion: 2
guid: 553b05a1b59a94260b3e545f13190389
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

54
com.unity.ml-agents/Runtime/Sensors/SensorBase.cs


namespace MLAgents.Sensors
{
/// <summary>
/// A base sensor that provides a number default implementations.
/// </summary>
public abstract class SensorBase : ISensor
{
/// <summary>
/// Write the observations to the output buffer. This size of the buffer will be product
/// of the sizes returned by <see cref="GetObservationShape"/>.
/// </summary>
/// <param name="output"></param>
public abstract void WriteObservation(float[] output);
/// <inheritdoc/>
public abstract int[] GetObservationShape();
/// <inheritdoc/>
public abstract string GetName();
/// <summary>
/// Default implementation of Write interface. This creates a temporary array,
/// calls WriteObservation, and then writes the results to the WriteAdapter.
/// </summary>
/// <param name="adapter"></param>
/// <returns>The number of elements written.</returns>
public virtual int Write(WriteAdapter adapter)
{
// TODO reuse buffer for similar agents, don't call GetObservationShape()
var numFloats = this.ObservationSize();
float[] buffer = new float[numFloats];
WriteObservation(buffer);
adapter.AddRange(buffer);
return numFloats;
}
/// <inheritdoc/>
public void Update() {}
/// <inheritdoc/>
public virtual byte[] GetCompressedObservation()
{
return null;
}
/// <inheritdoc/>
public virtual SensorCompressionType GetCompressionType()
{
return SensorCompressionType.None;
}
}
}
正在加载...
取消
保存