Arthur Juliani
4 年前
当前提交
0903613b
共有 11 个文件被更改,包括 55 次插入 和 104 次删除
-
5Project/Assets/ML-Agents/Examples/Crawler/Prefabs/DynamicPlatform.prefab
-
4Project/Assets/ML-Agents/Examples/Crawler/Scenes/CrawlerDynamicTarget.unity
-
8Project/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAgent.cs
-
13Project/Assets/ML-Agents/Examples/GoalNav/Prefabs/VisualArea.prefab
-
8Project/Assets/ML-Agents/Examples/GoalNav/Scripts/GoalNavAgent.cs
-
6Project/Assets/ML-Agents/Examples/GridWorld/Scripts/GridAgent.cs
-
6Project/Assets/ML-Agents/Examples/PushJump/Scripts/WJPBAgent.cs
-
6com.unity.ml-agents/Runtime/Sensors/VectorSensor.cs
-
28Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/VectorSensorComponent.cs
-
75Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/GoalSensorComponent.cs
-
0/Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/VectorSensorComponent.cs.meta
|
|||
using System.Collections.Generic; |
|||
using System.Collections.ObjectModel; |
|||
using Unity.MLAgents.Sensors; |
|||
using UnityEngine; |
|||
|
|||
|
|||
public class VectorSensorComponent : SensorComponent |
|||
{ |
|||
public int observationSize; |
|||
public VectorSensor sensor; |
|||
public ObservationType observationType; |
|||
|
|||
/// <summary>
|
|||
/// Creates a VectorSensor.
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
public override ISensor CreateSensor() |
|||
{ |
|||
sensor = new VectorSensor(observationSize, observationType: observationType); |
|||
return sensor; |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
public override int[] GetObservationShape() |
|||
{ |
|||
return new[] { observationSize }; |
|||
} |
|||
} |
|
|||
using System.Collections.Generic; |
|||
using System.Collections.ObjectModel; |
|||
using Unity.MLAgents.Sensors; |
|||
using UnityEngine; |
|||
|
|||
|
|||
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 AddGoal(IEnumerable<float> goal) |
|||
{ |
|||
if (goalSensor != null) |
|||
{ |
|||
goalSensor.AddObservation(goal); |
|||
} |
|||
} |
|||
|
|||
public void AddGoal(float goal) |
|||
{ |
|||
if (goalSensor != null) |
|||
{ |
|||
goalSensor.AddObservation(goal); |
|||
} |
|||
} |
|||
|
|||
public void AddOneHotGoal(int goal, int range) |
|||
{ |
|||
if (goalSensor != null) |
|||
{ |
|||
goalSensor.AddOneHotObservation(goal, range); |
|||
} |
|||
} |
|||
|
|||
public void AddGoal(Vector3 goal) |
|||
{ |
|||
if (goalSensor != null) |
|||
{ |
|||
goalSensor.AddObservation(goal); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public class GoalSensor : VectorSensor |
|||
{ |
|||
|
|||
public GoalSensor(int observationSize, string name = null) : base(observationSize) |
|||
{ |
|||
if (name == null) |
|||
{ |
|||
name = $"GoalSensor_size{observationSize}"; |
|||
} |
|||
} |
|||
|
|||
public override ObservationType GetObservationType() |
|||
{ |
|||
return ObservationType.Goal; |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue