GitHub
5 年前
当前提交
11ff1553
共有 5 个文件被更改,包括 114 次插入 和 2 次删除
-
18com.unity.ml-agents/Runtime/Sensors/RenderTextureSensor.cs
-
34com.unity.ml-agents/Tests/Editor/Sensor/RenderTextureSenorTests.cs
-
11com.unity.ml-agents/Tests/Editor/Sensor/RenderTextureSenorTests.cs.meta
-
42com.unity.ml-agents/Tests/Editor/Sensor/RenderTextureSensorComponentTests.cs
-
11com.unity.ml-agents/Tests/Editor/Sensor/RenderTextureSensorComponentTests.cs.meta
|
|||
using System; |
|||
using NUnit.Framework; |
|||
using UnityEngine; |
|||
using MLAgents.Sensors; |
|||
|
|||
namespace MLAgents.Tests |
|||
{ |
|||
|
|||
[TestFixture] |
|||
public class RenderTextureSensorTest |
|||
{ |
|||
[Test] |
|||
public void TestRenderTextureSensor() |
|||
{ |
|||
foreach (var grayscale in new[] { true, false }) |
|||
{ |
|||
foreach (SensorCompressionType compression in Enum.GetValues(typeof(SensorCompressionType))) |
|||
{ |
|||
var width = 24; |
|||
var height = 16; |
|||
var texture = new RenderTexture(width, height, 0); |
|||
var sensor = new RenderTextureSensor(texture, grayscale, "TestCameraSensor", compression); |
|||
|
|||
var writeAdapter = new WriteAdapter(); |
|||
var obs = sensor.GetObservationProto(writeAdapter); |
|||
|
|||
Assert.AreEqual((int) compression, (int) obs.CompressionType); |
|||
var expectedShape = new[] { height, width, grayscale ? 1 : 3 }; |
|||
Assert.AreEqual(expectedShape, obs.Shape); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: be9f7d8ce17d8407e92d46fbee2ab809 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using NUnit.Framework; |
|||
using UnityEngine; |
|||
using MLAgents.Sensors; |
|||
|
|||
namespace MLAgents.Tests |
|||
{ |
|||
|
|||
[TestFixture] |
|||
public class RenderTextureSensorComponentTest |
|||
{ |
|||
[Test] |
|||
public void TestRenderTextureSensorComponent() |
|||
{ |
|||
foreach (var grayscale in new[] { true, false }) |
|||
{ |
|||
foreach (SensorCompressionType compression in Enum.GetValues(typeof(SensorCompressionType))) |
|||
{ |
|||
var width = 24; |
|||
var height = 16; |
|||
var texture = new RenderTexture(width, height, 0); |
|||
|
|||
var agentGameObj = new GameObject("agent"); |
|||
|
|||
var renderTexComponent = agentGameObj.AddComponent<RenderTextureSensorComponent>(); |
|||
renderTexComponent.renderTexture = texture; |
|||
renderTexComponent.grayscale = grayscale; |
|||
renderTexComponent.compression = compression; |
|||
|
|||
var expectedShape = new[] { height, width, grayscale ? 1 : 3 }; |
|||
Assert.AreEqual(expectedShape, renderTexComponent.GetObservationShape()); |
|||
Assert.IsTrue(renderTexComponent.IsVisual()); |
|||
Assert.IsFalse(renderTexComponent.IsVector()); |
|||
|
|||
var sensor = renderTexComponent.CreateSensor(); |
|||
Assert.AreEqual(expectedShape, sensor.GetObservationShape()); |
|||
Assert.AreEqual(typeof(RenderTextureSensor), sensor.GetType()); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 6be53c3cd01244f179a58c96560c54cf |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue