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

47 行
1.5 KiB

using UnityEngine;
namespace MLAgents.Sensors
{
/// <summary>
/// Component that wraps a <see cref="RenderTextureSensor"/>.
/// </summary>
[AddComponentMenu("ML Agents/Render Texture Sensor", (int)MenuGroup.Sensors)]
public class RenderTextureSensorComponent : SensorComponent
{
/// <summary>
/// The <see cref="RenderTexture"/> instance that the associated
/// <see cref="RenderTextureSensor"/> wraps.
/// </summary>
public RenderTexture renderTexture;
/// <summary>
/// Name of the sensor.
/// </summary>
public string sensorName = "RenderTextureSensor";
/// <summary>
/// Whether the RenderTexture observation should be converted to grayscale or not.
/// </summary>
public bool grayscale;
/// <summary>
/// Compression type for the render texture observation.
/// </summary>
public SensorCompressionType compression = SensorCompressionType.PNG;
/// <inheritdoc/>
public override ISensor CreateSensor()
{
return new RenderTextureSensor(renderTexture, grayscale, sensorName, compression);
}
/// <inheritdoc/>
public override int[] GetObservationShape()
{
var width = renderTexture != null ? renderTexture.width : 0;
var height = renderTexture != null ? renderTexture.height : 0;
return new[] { height, width, grayscale ? 1 : 3 };
}
}
}