Unity 机器学习代理工具包 (ML-Agents) 是一个开源项目,它使游戏和模拟能够作为训练智能代理的环境。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

47 行
1.4 KiB

using UnityEngine;
namespace MLAgents.Sensor
{
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 GetObservationShape().
/// </summary>
/// <param name="output"></param>
public abstract void WriteObservation(float[] output);
public abstract int[] GetObservationShape();
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>
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;
}
public void Update() { }
public virtual byte[] GetCompressedObservation()
{
return null;
}
public virtual SensorCompressionType GetCompressionType()
{
return SensorCompressionType.None;
}
}
}