GitHub
4 年前
当前提交
31919e08
共有 36 个文件被更改,包括 502 次插入 和 228 次删除
-
10DevProject/Packages/manifest.json
-
4DevProject/ProjectSettings/ProjectVersion.txt
-
60Project/Assets/ML-Agents/Examples/Basic/Prefabs/Basic.prefab
-
53Project/Assets/ML-Agents/Examples/Basic/Scenes/Basic.unity
-
23Project/Assets/ML-Agents/Examples/Basic/Scripts/BasicController.cs
-
14com.unity.ml-agents/Editor/BehaviorParametersEditor.cs
-
7com.unity.ml-agents/Runtime/Academy.cs
-
17com.unity.ml-agents/Runtime/Actuators/ActionSpec.cs
-
9com.unity.ml-agents/Runtime/Actuators/ActuatorComponent.cs
-
3com.unity.ml-agents/Runtime/Actuators/ActuatorDiscreteActionMask.cs
-
49com.unity.ml-agents/Runtime/Actuators/ActuatorManager.cs
-
16com.unity.ml-agents/Runtime/Actuators/IActionReceiver.cs
-
2com.unity.ml-agents/Runtime/Actuators/IActuator.cs
-
10com.unity.ml-agents/Runtime/Actuators/VectorActuator.cs
-
25com.unity.ml-agents/Runtime/Agent.cs
-
11com.unity.ml-agents/Runtime/Agent.deprecated.cs
-
34com.unity.ml-agents/Runtime/Communicator/GrpcExtensions.cs
-
5com.unity.ml-agents/Runtime/Communicator/ICommunicator.cs
-
27com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs
-
3com.unity.ml-agents/Runtime/DiscreteActionMasker.cs
-
90com.unity.ml-agents/Runtime/Inference/BarracudaModelParamLoader.cs
-
10com.unity.ml-agents/Runtime/Inference/ModelRunner.cs
-
13com.unity.ml-agents/Runtime/Inference/TensorApplier.cs
-
7com.unity.ml-agents/Runtime/Policies/BarracudaPolicy.cs
-
31com.unity.ml-agents/Runtime/Policies/BehaviorParameters.cs
-
4com.unity.ml-agents/Runtime/Policies/HeuristicPolicy.cs
-
9com.unity.ml-agents/Runtime/Policies/RemotePolicy.cs
-
2com.unity.ml-agents/Tests/Editor/Actuators/ActuatorManagerTests.cs
-
4com.unity.ml-agents/Tests/Editor/Actuators/TestActuator.cs
-
3com.unity.ml-agents/Tests/Editor/BehaviorParameterTests.cs
-
18com.unity.ml-agents/Tests/Editor/Communicator/GrpcExtensionsTests.cs
-
5com.unity.ml-agents/Tests/Editor/EditModeTestInternalBrainTensorApplier.cs
-
31com.unity.ml-agents/Tests/Editor/ModelRunnerTest.cs
-
33com.unity.ml-agents/Tests/Editor/ParameterLoaderTest.cs
-
85Project/Assets/ML-Agents/Examples/Basic/Scripts/BasicActuatorComponent.cs
-
3Project/Assets/ML-Agents/Examples/Basic/Scripts/BasicActuatorComponent.cs.meta
|
|||
m_EditorVersion: 2019.3.11f1 |
|||
m_EditorVersionWithRevision: 2019.3.11f1 (ceef2d848e70) |
|||
m_EditorVersion: 2019.4.7f1 |
|||
m_EditorVersionWithRevision: 2019.4.7f1 (e992b1a16e65) |
|
|||
using System; |
|||
using Unity.MLAgents.Actuators; |
|||
|
|||
namespace Unity.MLAgentsExamples |
|||
{ |
|||
/// <summary>
|
|||
/// A simple example of a ActuatorComponent.
|
|||
/// This should be added to the same GameObject as the BasicController
|
|||
/// </summary>
|
|||
public class BasicActuatorComponent : ActuatorComponent |
|||
{ |
|||
public BasicController basicController; |
|||
ActionSpec m_ActionSpec = ActionSpec.MakeDiscrete(3); |
|||
|
|||
/// <summary>
|
|||
/// Creates a BasicActuator.
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
public override IActuator CreateActuator() |
|||
{ |
|||
return new BasicActuator(basicController); |
|||
} |
|||
|
|||
public override ActionSpec ActionSpec |
|||
{ |
|||
get { return m_ActionSpec; } |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Simple actuator that converts the action into a {-1, 0, 1} direction
|
|||
/// </summary>
|
|||
public class BasicActuator : IActuator |
|||
{ |
|||
public BasicController basicController; |
|||
ActionSpec m_ActionSpec; |
|||
|
|||
public BasicActuator(BasicController controller) |
|||
{ |
|||
basicController = controller; |
|||
m_ActionSpec = ActionSpec.MakeDiscrete(3); |
|||
} |
|||
|
|||
public ActionSpec ActionSpec |
|||
{ |
|||
get { return m_ActionSpec; } |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
public String Name |
|||
{ |
|||
get { return "Basic"; } |
|||
} |
|||
|
|||
public void ResetData() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public void OnActionReceived(ActionBuffers actionBuffers) |
|||
{ |
|||
var movement = actionBuffers.DiscreteActions[0]; |
|||
|
|||
var direction = 0; |
|||
|
|||
switch (movement) |
|||
{ |
|||
case 1: |
|||
direction = -1; |
|||
break; |
|||
case 2: |
|||
direction = 1; |
|||
break; |
|||
} |
|||
|
|||
basicController.MoveDirection(direction); |
|||
} |
|||
|
|||
public void WriteDiscreteActionMask(IDiscreteActionMask actionMask) |
|||
{ |
|||
|
|||
} |
|||
|
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 4ce4e199dabb494e8764b09f4c378098 |
|||
timeCreated: 1597446960 |
撰写
预览
正在加载...
取消
保存
Reference in new issue