浏览代码

Add GoalSensor and component

/MLA-1734-demo-provider
Arthur Juliani 4 年前
当前提交
6933b9c2
共有 3 个文件被更改,包括 60 次插入1 次删除
  1. 2
      com.unity.ml-agents/Runtime/Sensors/VectorSensor.cs
  2. 48
      Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/GoalSensorComponent.cs
  3. 11
      Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/GoalSensorComponent.cs.meta

2
com.unity.ml-agents/Runtime/Sensors/VectorSensor.cs


}
/// <inheritdoc/>
public SensorType GetSensorType()
public virtual SensorType GetSensorType()
{
return SensorType.Observation;
}

48
Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/GoalSensorComponent.cs


using Unity.MLAgents.Sensors;
public class GoalSensorComponent : SensorComponent
{
public int observationSize;
public GoalSensor goalSensor;
/// <summary>
/// Creates a GoalSensor.
/// </summary>
/// <returns></returns>
public override ISensor CreateSensor()
{
goalSensor = new GoalSensor(observationSize);
return goalSensor;
}
/// <inheritdoc/>
public override int[] GetObservationShape()
{
return new[] { observationSize };
}
public void AddParameterizaton(float parameter)
{
if(goalSensor != null)
{
goalSensor.AddObservation(parameter);
}
}
}
public class GoalSensor : VectorSensor
{
public GoalSensor(int observationSize, string name = null) : base(observationSize)
{
if (name == null)
{
name = $"GoalSensor_size{observationSize}";
}
}
public override SensorType GetSensorType()
{
return SensorType.Goal;
}
}

11
Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/GoalSensorComponent.cs.meta


fileFormatVersion: 2
guid: 163dac4bcbb2f4d8499db2cdcb22a89e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存