浏览代码

Merge branch 'develop' into release-0.11.0

/develop-gpu-test
Jonathan Harper 5 年前
当前提交
8550679d
共有 123 个文件被更改,包括 763 次插入1008 次删除
  1. 19
      .circleci/config.yml
  2. 23
      .pre-commit-config.yaml
  3. 2
      .yamato/csharp-tests.yml
  4. 4
      .yamato/standalone-build-test.yml
  5. 1
      UnitySDK/Assets/ML-Agents/Editor/AgentEditor.cs
  6. 24
      UnitySDK/Assets/ML-Agents/Editor/BehaviorParametersEditor.cs
  7. 26
      UnitySDK/Assets/ML-Agents/Editor/BrainParametersDrawer.cs
  8. 2
      UnitySDK/Assets/ML-Agents/Editor/DemonstrationImporter.cs
  9. 16
      UnitySDK/Assets/ML-Agents/Editor/ResetParameterDrawer.cs
  10. 17
      UnitySDK/Assets/ML-Agents/Editor/Tests/DemonstrationTests.cs
  11. 55
      UnitySDK/Assets/ML-Agents/Editor/Tests/EditModeTestInternalBrainTensorApplier.cs
  12. 73
      UnitySDK/Assets/ML-Agents/Editor/Tests/EditModeTestInternalBrainTensorGenerator.cs
  13. 21
      UnitySDK/Assets/ML-Agents/Editor/Tests/MLAgentsEditModeTest.cs
  14. 6
      UnitySDK/Assets/ML-Agents/Editor/Tests/RandomNormalTest.cs
  15. 4
      UnitySDK/Assets/ML-Agents/Editor/Tests/RayPerceptionTests.cs
  16. 6
      UnitySDK/Assets/ML-Agents/Editor/Tests/StandaloneBuildTest.cs
  17. 4
      UnitySDK/Assets/ML-Agents/Examples/3DBall/Scripts/Ball3DAgent.cs
  18. 4
      UnitySDK/Assets/ML-Agents/Examples/3DBall/Scripts/Ball3DHardAgent.cs
  19. 6
      UnitySDK/Assets/ML-Agents/Examples/Basic/Scripts/BasicAgent.cs
  20. 4
      UnitySDK/Assets/ML-Agents/Examples/Bouncer/Scripts/BouncerAgent.cs
  21. 2
      UnitySDK/Assets/ML-Agents/Examples/Bouncer/Scripts/BouncerTarget.cs
  22. 8
      UnitySDK/Assets/ML-Agents/Examples/FoodCollector/Scripts/FoodCollectorAgent.cs
  23. 18
      UnitySDK/Assets/ML-Agents/Examples/GridWorld/Scripts/GridAgent.cs
  24. 4
      UnitySDK/Assets/ML-Agents/Examples/GridWorld/Scripts/GridArea.cs
  25. 2
      UnitySDK/Assets/ML-Agents/Examples/Hallway/Scripts/HallwayAgent.cs
  26. 4
      UnitySDK/Assets/ML-Agents/Examples/PushBlock/Scripts/PushAgentBasic.cs
  27. 12
      UnitySDK/Assets/ML-Agents/Examples/Pyramids/Scripts/PyramidAgent.cs
  28. 2
      UnitySDK/Assets/ML-Agents/Examples/Pyramids/Scripts/PyramidArea.cs
  29. 12
      UnitySDK/Assets/ML-Agents/Examples/Pyramids/Scripts/PyramidSwitch.cs
  30. 14
      UnitySDK/Assets/ML-Agents/Examples/Reacher/Scripts/ReacherAgent.cs
  31. 6
      UnitySDK/Assets/ML-Agents/Examples/Reacher/Scripts/ReacherGoal.cs
  32. 6
      UnitySDK/Assets/ML-Agents/Examples/SharedAssets/Scripts/FlyCamera.cs
  33. 2
      UnitySDK/Assets/ML-Agents/Examples/SharedAssets/Scripts/GroundContact.cs
  34. 21
      UnitySDK/Assets/ML-Agents/Examples/SharedAssets/Scripts/RayPerception3D.cs
  35. 2
      UnitySDK/Assets/ML-Agents/Examples/SharedAssets/Scripts/TargetContact.cs
  36. 4
      UnitySDK/Assets/ML-Agents/Examples/Soccer/Scripts/AgentSoccer.cs
  37. 10
      UnitySDK/Assets/ML-Agents/Examples/Tennis/Scripts/HitWall.cs
  38. 16
      UnitySDK/Assets/ML-Agents/Examples/Tennis/Scripts/TennisAgent.cs
  39. 2
      UnitySDK/Assets/ML-Agents/Examples/Tennis/Scripts/TennisArea.cs
  40. 8
      UnitySDK/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAgent.cs
  41. 6
      UnitySDK/Assets/ML-Agents/Examples/WallJump/Scripts/WallJumpAgent.cs
  42. 6
      UnitySDK/Assets/ML-Agents/Plugins/Barracuda.Core/Barracuda/Plugins/Editor/BarracudaEditor/NNModelImporter.cs
  43. 20
      UnitySDK/Assets/ML-Agents/Scripts/Academy.cs
  44. 10
      UnitySDK/Assets/ML-Agents/Scripts/ActionMasker.cs
  45. 183
      UnitySDK/Assets/ML-Agents/Scripts/Agent.cs
  46. 14
      UnitySDK/Assets/ML-Agents/Scripts/DemonstrationRecorder.cs
  47. 24
      UnitySDK/Assets/ML-Agents/Scripts/DemonstrationStore.cs
  48. 33
      UnitySDK/Assets/ML-Agents/Scripts/Grpc/CommunicatorObjects/AgentAction.cs
  49. 41
      UnitySDK/Assets/ML-Agents/Scripts/Grpc/CommunicatorObjects/AgentInfo.cs
  50. 9
      UnitySDK/Assets/ML-Agents/Scripts/Grpc/GrpcExtensions.cs
  51. 41
      UnitySDK/Assets/ML-Agents/Scripts/Grpc/RpcCommunicator.cs
  52. 22
      UnitySDK/Assets/ML-Agents/Scripts/ICommunicator.cs
  53. 54
      UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/ApplierImpl.cs
  54. 25
      UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/BarracudaModelParamLoader.cs
  55. 141
      UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/GeneratorImpl.cs
  56. 45
      UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/ModelRunner.cs
  57. 14
      UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/TensorApplier.cs
  58. 58
      UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/TensorGenerator.cs
  59. 2
      UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/TensorProxy.cs
  60. 2
      UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/Utils/Multinomial.cs
  61. 10
      UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/Utils/RandomNormal.cs
  62. 27
      UnitySDK/Assets/ML-Agents/Scripts/Policy/BarracudaPolicy.cs
  63. 16
      UnitySDK/Assets/ML-Agents/Scripts/Policy/BehaviorParameters.cs
  64. 6
      UnitySDK/Assets/ML-Agents/Scripts/Policy/HeuristicPolicy.cs
  65. 1
      UnitySDK/Assets/ML-Agents/Scripts/Policy/IPolicy.cs
  66. 29
      UnitySDK/Assets/ML-Agents/Scripts/Policy/RemotePolicy.cs
  67. 5
      UnitySDK/Assets/ML-Agents/Scripts/ResetParameters.cs
  68. 18
      UnitySDK/Assets/ML-Agents/Scripts/Sensor/CameraSensor.cs
  69. 2
      UnitySDK/Assets/ML-Agents/Scripts/Sensor/CameraSensorComponent.cs
  70. 12
      UnitySDK/Assets/ML-Agents/Scripts/Sensor/ISensor.cs
  71. 21
      UnitySDK/Assets/ML-Agents/Scripts/Sensor/RenderTextureSensor.cs
  72. 2
      UnitySDK/Assets/ML-Agents/Scripts/Sensor/RenderTextureSensorComponent.cs
  73. 17
      UnitySDK/Assets/ML-Agents/Scripts/Sensor/SensorBase.cs
  74. 6
      UnitySDK/Assets/ML-Agents/Scripts/Startup.cs
  75. 15
      UnitySDK/Assets/ML-Agents/Scripts/Timer.cs
  76. 61
      UnitySDK/Assets/ML-Agents/Scripts/Utilities.cs
  77. 1
      UnitySDK/UnitySDK.sln.DotSettings
  78. 9
      docs/Migrating.md
  79. 2
      gym-unity/gym_unity/envs/__init__.py
  80. 1
      ml-agents-envs/mlagents/envs/action_info.py
  81. 43
      ml-agents-envs/mlagents/envs/brain.py
  82. 15
      ml-agents-envs/mlagents/envs/communicator_objects/agent_action_pb2.py
  83. 6
      ml-agents-envs/mlagents/envs/communicator_objects/agent_action_pb2.pyi
  84. 25
      ml-agents-envs/mlagents/envs/communicator_objects/agent_info_pb2.py
  85. 6
      ml-agents-envs/mlagents/envs/communicator_objects/agent_info_pb2.pyi
  86. 73
      ml-agents-envs/mlagents/envs/environment.py
  87. 2
      ml-agents-envs/mlagents/envs/mock_communicator.py
  88. 12
      ml-agents-envs/mlagents/envs/rpc_communicator.py
  89. 4
      ml-agents-envs/mlagents/envs/simple_env_manager.py
  90. 8
      ml-agents-envs/mlagents/envs/subprocess_env_manager.py
  91. 13
      ml-agents-envs/mlagents/envs/timers.py
  92. 1
      ml-agents/mlagents/trainers/barracuda.py
  93. 4
      ml-agents/mlagents/trainers/bc/policy.py
  94. 18
      ml-agents/mlagents/trainers/components/reward_signals/extrinsic/signal.py
  95. 12
      ml-agents/mlagents/trainers/learn.py
  96. 11
      ml-agents/mlagents/trainers/ppo/multi_gpu_policy.py
  97. 8
      ml-agents/mlagents/trainers/ppo/policy.py
  98. 17
      ml-agents/mlagents/trainers/rl_trainer.py
  99. 6
      ml-agents/mlagents/trainers/sac/models.py
  100. 4
      ml-agents/mlagents/trainers/sac/policy.py

19
.circleci/config.yml


markdown_link_check:
parameters:
precommit_command:
type: string
description: precommit hook to run
default: markdown-link-check
docker:
- image: circleci/node:12.6.0
working_directory: ~/repo

name: Run markdown-link-check via precommit
command: |
. venv/bin/activate
pre-commit run --hook-stage manual markdown-link-check --all-files
pre-commit run --hook-stage manual << parameters.precommit_command >> --all-files
protobuf_generation_check:
docker:

only: /[0-9]+(\.[0-9]+)*(\.dev[0-9]+)*/
branches:
ignore: /.*/
nightly:
triggers:
- schedule:
cron: "0 0 * * *"
filters:
branches:
only:
- develop
jobs:
- markdown_link_check:
name: markdown-link-check full
precommit_command: markdown-link-check-full

23
.pre-commit-config.yaml


hooks:
- id: python-check-mock-methods
- repo: https://github.com/pre-commit/mirrors-pylint
rev: v2.4.3
hooks:
- id: pylint
exclude: >
(?x)^(
.*_pb2.py|
.*_pb2_grpc.py|
.*/tests/.*
)$
require_serial: true
# "Local" hooks, see https://pre-commit.com/#repository-local-hooks
- repo: local
hooks:

# Note that you must install the package separately via npm. For example:
# brew install npm; npm install -g markdown-link-check
entry: bash -xc 'echo "$@" | xargs -n1 -t markdown-link-check -c markdown-link-check.config.json' --
entry: bash -xc 'echo "$@" | xargs -n1 -t markdown-link-check -c markdown-link-check.fast.json' --
stages: [manual]
- id: markdown-link-check-full
name: markdown-link-check-full
entry: bash -xc 'echo "$@" | xargs -n1 -t markdown-link-check -c markdown-link-check.full.json' --
language: system
types: [markdown]
exclude: ".*localized.*"
stages: [manual]
- id: validate-versions
name: validate library versions

2
.yamato/csharp-tests.yml


name: Test Mac EditMode {{ editor.version }}
agent:
type: Unity::VM::osx
image: ml-agents/ml-agents-bokken-mac:release
image: ml-agents/ml-agents-bokken-mac:v0.1.2-440635
flavor: i1.small
variables:
UNITY_VERSION: {{ editor.version }}

4
.yamato/standalone-build-test.yml


name: Test Mac Standalone {{ editor.version }}
agent:
type: Unity::VM::osx
image: ml-agents/ml-agents-bokken-mac:release
image: ml-agents/ml-agents-bokken-mac:v0.1.2-440635
flavor: i1.small
variables:
UNITY_VERSION: {{ editor.version }}

- "master"
- "/release-.*/"
- "/hotfix-.*/"
{% endfor %}
{% endfor %}

1
UnitySDK/Assets/ML-Agents/Editor/AgentEditor.cs


using UnityEngine;
using UnityEditor;
using Barracuda;
namespace MLAgents
{

24
UnitySDK/Assets/ML-Agents/Editor/BehaviorParametersEditor.cs


[CanEditMultipleObjects]
public class BehaviorParametersEditor : Editor
{
private const float k_TimeBetweenModelReloads = 2f;
const float k_TimeBetweenModelReloads = 2f;
private float m_TimeSinceModelReload;
float m_TimeSinceModelReload;
private bool m_RequireReload;
bool m_RequireReload;
var serializedObject = base.serializedObject;
serializedObject.Update();
var so = serializedObject;
so.Update();
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_BehaviorName"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_BrainParameters"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Model"), true);
EditorGUILayout.PropertyField(so.FindProperty("m_BehaviorName"));
EditorGUILayout.PropertyField(so.FindProperty("m_BrainParameters"), true);
EditorGUILayout.PropertyField(so.FindProperty("m_Model"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_InferenceDevice"), true);
EditorGUILayout.PropertyField(so.FindProperty("m_InferenceDevice"), true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_UseHeuristic"));
EditorGUILayout.PropertyField(so.FindProperty("m_UseHeuristic"));
// EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Heuristic"), true);
EditorGUI.indentLevel--;
if (EditorGUI.EndChangeCheck())

DisplayFailedModelChecks();
serializedObject.ApplyModifiedProperties();
so.ApplyModifiedProperties();
private void DisplayFailedModelChecks()
void DisplayFailedModelChecks()
{
if (m_RequireReload && m_TimeSinceModelReload > k_TimeBetweenModelReloads)
{

26
UnitySDK/Assets/ML-Agents/Editor/BrainParametersDrawer.cs


public class BrainParametersDrawer : PropertyDrawer
{
// The height of a line in the Unity Inspectors
private const float k_LineHeight = 17f;
private const int k_VecObsNumLine = 3;
private const string k_ActionSizePropName = "vectorActionSize";
private const string k_ActionTypePropName = "vectorActionSpaceType";
private const string k_ActionDescriptionPropName = "vectorActionDescriptions";
private const string k_VecObsPropName = "vectorObservationSize";
private const string k_NumVecObsPropName = "numStackedVectorObservations";
const float k_LineHeight = 17f;
const int k_VecObsNumLine = 3;
const string k_ActionSizePropName = "vectorActionSize";
const string k_ActionTypePropName = "vectorActionSpaceType";
const string k_ActionDescriptionPropName = "vectorActionDescriptions";
const string k_VecObsPropName = "vectorObservationSize";
const string k_NumVecObsPropName = "numStackedVectorObservations";
/// <inheritdoc />
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)

/// <param name="position">Rectangle on the screen to use for the property GUI.</param>
/// <param name="property">The SerializedProperty of the BrainParameters
/// to make the custom GUI for.</param>
private static void DrawVectorObservation(Rect position, SerializedProperty property)
static void DrawVectorObservation(Rect position, SerializedProperty property)
{
EditorGUI.LabelField(position, "Vector Observation");
position.y += k_LineHeight;

/// The Height required to draw the Vector Observations paramaters
/// </summary>
/// <returns>The height of the drawer of the Vector Observations </returns>
private static float GetHeightDrawVectorObservation()
static float GetHeightDrawVectorObservation()
{
return k_VecObsNumLine * k_LineHeight;
}

/// <param name="position">Rectangle on the screen to use for the property GUI.</param>
/// <param name="property">The SerializedProperty of the BrainParameters
/// to make the custom GUI for.</param>
private static void DrawVectorAction(Rect position, SerializedProperty property)
static void DrawVectorAction(Rect position, SerializedProperty property)
{
EditorGUI.LabelField(position, "Vector Action");
position.y += k_LineHeight;

/// <param name="position">Rectangle on the screen to use for the property GUI.</param>
/// <param name="property">The SerializedProperty of the BrainParameters
/// to make the custom GUI for.</param>
private static void DrawContinuousVectorAction(Rect position, SerializedProperty property)
static void DrawContinuousVectorAction(Rect position, SerializedProperty property)
{
var vecActionSize = property.FindPropertyRelative(k_ActionSizePropName);
vecActionSize.arraySize = 1;

/// <param name="position">Rectangle on the screen to use for the property GUI.</param>
/// <param name="property">The SerializedProperty of the BrainParameters
/// to make the custom GUI for.</param>
private static void DrawDiscreteVectorAction(Rect position, SerializedProperty property)
static void DrawDiscreteVectorAction(Rect position, SerializedProperty property)
{
var vecActionSize = property.FindPropertyRelative(k_ActionSizePropName);
vecActionSize.arraySize = EditorGUI.IntField(

/// The Height required to draw the Vector Action parameters
/// </summary>
/// <returns>The height of the drawer of the Vector Action </returns>
private static float GetHeightDrawVectorAction(SerializedProperty property)
static float GetHeightDrawVectorAction(SerializedProperty property)
{
var actionSize = 2 + property.FindPropertyRelative(k_ActionSizePropName).arraySize;
if (property.FindPropertyRelative(k_ActionTypePropName).enumValueIndex == 0)

2
UnitySDK/Assets/ML-Agents/Editor/DemonstrationImporter.cs


[ScriptedImporter(1, new[] {"demo"})]
public class DemonstrationImporter : ScriptedImporter
{
private const string k_IconPath = "Assets/ML-Agents/Resources/DemoIcon.png";
const string k_IconPath = "Assets/ML-Agents/Resources/DemoIcon.png";
public override void OnImportAsset(AssetImportContext ctx)
{

16
UnitySDK/Assets/ML-Agents/Editor/ResetParameterDrawer.cs


[CustomPropertyDrawer(typeof(ResetParameters))]
public class ResetParameterDrawer : PropertyDrawer
{
private ResetParameters m_Parameters;
ResetParameters m_Parameters;
private const float k_LineHeight = 17f;
const float k_LineHeight = 17f;
private const string k_NewKeyPrefix = "Param-";
const string k_NewKeyPrefix = "Param-";
/// <summary>
/// Computes the height of the Drawer depending on the property it is showing

/// </summary>
/// <param name="addRect">The rectangle for the Add New button.</param>
/// <param name="removeRect">The rectangle for the Remove Last button.</param>
private void DrawAddRemoveButtons(Rect addRect, Rect removeRect)
void DrawAddRemoveButtons(Rect addRect, Rect removeRect)
{
// This is the Add button
if (m_Parameters.Count == 0)

/// Signals that the property has been modified and requires the scene to be saved for
/// the changes to persist. Only works when the Editor is not playing.
/// </summary>
private static void MarkSceneAsDirty()
static void MarkSceneAsDirty()
{
if (!EditorApplication.isPlaying)
{

/// </summary>
/// <param name="property">The SerializedProperty of the ResetParameters
/// to make the custom GUI for.</param>
private void LazyInitializeParameters(SerializedProperty property)
void LazyInitializeParameters(SerializedProperty property)
{
if (m_Parameters != null)
{

/// <summary>
/// Removes the last ResetParameter from the ResetParameters
/// </summary>
private void RemoveLastParameter()
void RemoveLastParameter()
{
if (m_Parameters.Count > 0)
{

/// <summary>
/// Adds a new ResetParameter to the ResetParameters with a default name.
/// </summary>
private void AddParameter()
void AddParameter()
{
var key = k_NewKeyPrefix + m_Parameters.Count;
var value = default(float);

17
UnitySDK/Assets/ML-Agents/Editor/Tests/DemonstrationTests.cs


{
public class DemonstrationTests : MonoBehaviour
{
private const string k_DemoDirecory = "Assets/Demonstrations/";
private const string k_ExtensionType = ".demo";
private const string k_DemoName = "Test";
const string k_DemoDirecory = "Assets/Demonstrations/";
const string k_ExtensionType = ".demo";
const string k_DemoName = "Test";
[Test]
public void TestSanitization()

{
vectorObservationSize = 3,
numStackedVectorObservations = 2,
vectorActionDescriptions = new[] {"TestActionA", "TestActionB"},
vectorActionSize = new[] {2, 2},
vectorActionDescriptions = new[] { "TestActionA", "TestActionB" },
vectorActionSize = new[] { 2, 2 },
vectorActionSpaceType = SpaceType.Discrete
};

var agentInfo = new AgentInfo
{
reward = 1f,
actionMasks = new[] {false, true},
actionMasks = new[] { false, true },
memories = new List<float>(),
stackedVectorObservation = new List<float>() {1f, 1f, 1f},
floatObservations = new List<float>() { 1f, 1f, 1f },
storedVectorActions = new[] {0f, 1f},
storedVectorActions = new[] { 0f, 1f },
textObservation = "TestAction",
};

55
UnitySDK/Assets/ML-Agents/Editor/Tests/EditModeTestInternalBrainTensorApplier.cs


{
public class EditModeTestInternalBrainTensorApplier
{
private class TestAgent : Agent
class TestAgent : Agent
var f = typeof(Agent).GetField(
var f = typeof(Agent).GetField(
private List<Agent> GetFakeAgentInfos()
List<Agent> GetFakeAgentInfos()
{
var goA = new GameObject("goA");
var agentA = goA.AddComponent<TestAgent>();

return new List<Agent> {agentA, agentB};
return new List<Agent> { agentA, agentB };
}
[Test]

var alloc = new TensorCachingAllocator();
var tensorGenerator = new TensorApplier(bp, 0, alloc);
var mem = new Dictionary<int, List<float>>();
var tensorGenerator = new TensorApplier(bp, 0, alloc, mem);
Assert.IsNotNull(tensorGenerator);
alloc.Dispose();
}

{
var inputTensor = new TensorProxy()
{
shape = new long[] {2, 3},
data = new Tensor(2, 3, new float[] {1, 2, 3, 4, 5, 6})
shape = new long[] { 2, 3 },
data = new Tensor(2, 3, new float[] { 1, 2, 3, 4, 5, 6 })
};
var agentInfos = GetFakeAgentInfos();

{
var inputTensor = new TensorProxy()
{
shape = new long[] {2, 5},
shape = new long[] { 2, 5 },
new[] {0.5f, 22.5f, 0.1f, 5f, 1f, 4f, 5f, 6f, 7f, 8f})
new[] { 0.5f, 22.5f, 0.1f, 5f, 1f, 4f, 5f, 6f, 7f, 8f })
var applier = new DiscreteActionOutputApplier(new[] {2, 3}, 0, alloc);
var applier = new DiscreteActionOutputApplier(new[] { 2, 3 }, 0, alloc);
applier.Apply(inputTensor, agentInfos);
var agents = agentInfos;

}
[Test]
public void ApplyMemoryOutput()
{
var inputTensor = new TensorProxy()
{
shape = new long[] {2, 5},
data = new Tensor(
2,
5,
new[] {0.5f, 22.5f, 0.1f, 5f, 1f, 4f, 5f, 6f, 7f, 8f})
};
var agentInfos = GetFakeAgentInfos();
var applier = new MemoryOutputApplier();
applier.Apply(inputTensor, agentInfos);
var agents = agentInfos;
var agent = agents[0] as TestAgent;
Assert.NotNull(agent);
var action = agent.GetAction();
Assert.AreEqual(action.memories[0], 0.5f);
Assert.AreEqual(action.memories[1], 22.5f);
agent = agents[1] as TestAgent;
Assert.NotNull(agent);
action = agent.GetAction();
Assert.AreEqual(action.memories[2], 6);
Assert.AreEqual(action.memories[3], 7);
}
[Test]
shape = new long[] {2, 1},
data = new Tensor(2, 1, new[] {0.5f, 8f})
shape = new long[] { 2, 1 },
data = new Tensor(2, 1, new[] { 0.5f, 8f })
};
var agentInfos = GetFakeAgentInfos();

73
UnitySDK/Assets/ML-Agents/Editor/Tests/EditModeTestInternalBrainTensorGenerator.cs


using System.Collections.Generic;
using System.Linq;
using System.Reflection;
private static IEnumerable<Agent> GetFakeAgentInfos()
static IEnumerable<Agent> GetFakeAgents()
var acaGo = new GameObject("TestAcademy");
acaGo.AddComponent<TestAcademy>();
var aca = acaGo.GetComponent<TestAcademy>();
aca.resetParameters = new ResetParameters();
var bpA = goA.AddComponent<BehaviorParameters>();
bpA.brainParameters.vectorObservationSize = 3;
bpA.brainParameters.numStackedVectorObservations = 1;
var goB = new GameObject("goB");
var bpB = goB.AddComponent<BehaviorParameters>();
bpB.brainParameters.vectorObservationSize = 3;
bpB.brainParameters.numStackedVectorObservations = 1;
var agentB = goB.AddComponent<TestAgent>();
var agents = new List<Agent> { agentA, agentB };
foreach (var agent in agents)
{
var agentEnableMethod = typeof(Agent).GetMethod("OnEnableHelper",
BindingFlags.Instance | BindingFlags.NonPublic);
agentEnableMethod?.Invoke(agent, new object[] { aca });
}
agentA.collectObservationsSensor.AddObservation(new Vector3(1, 2, 3));
agentB.collectObservationsSensor.AddObservation(new Vector3(4, 5, 6));
stackedVectorObservation = new[] { 1f, 2f, 3f }.ToList(),
memories = null,
var goB = new GameObject("goB");
var agentB = goB.AddComponent<TestAgent>();
stackedVectorObservation = new[] { 4f, 5f, 6f }.ToList(),
memories = new[] { 1f, 1f, 1f }.ToList(),
return new List<Agent> { agentA, agentB };
return agents;
var bp = new BrainParameters();
var tensorGenerator = new TensorGenerator(bp, 0, alloc);
var mem = new Dictionary<int, List<float>>();
var tensorGenerator = new TensorGenerator(0, alloc, mem);
Assert.IsNotNull(tensorGenerator);
alloc.Dispose();
}

shape = new long[] { 2, 3 }
};
const int batchSize = 4;
var agentInfos = GetFakeAgentInfos();
var agentInfos = GetFakeAgents();
generator.AddSensorIndex(0);
generator.AddSensorIndex(1);
generator.AddSensorIndex(2);
generator.Generate(inputTensor, batchSize, agentInfos);
Assert.IsNotNull(inputTensor.data);
Assert.AreEqual(inputTensor.data[0, 0], 1);

}
[Test]
public void GenerateRecurrentInput()
{
var inputTensor = new TensorProxy
{
shape = new long[] { 2, 5 }
};
const int batchSize = 4;
var agentInfos = GetFakeAgentInfos();
var alloc = new TensorCachingAllocator();
var generator = new RecurrentInputGenerator(alloc);
generator.Generate(inputTensor, batchSize, agentInfos);
Assert.IsNotNull(inputTensor.data);
Assert.AreEqual(inputTensor.data[0, 0], 0);
Assert.AreEqual(inputTensor.data[0, 4], 0);
Assert.AreEqual(inputTensor.data[1, 0], 1);
Assert.AreEqual(inputTensor.data[1, 4], 0);
alloc.Dispose();
}
[Test]
public void GeneratePreviousActionInput()
{
var inputTensor = new TensorProxy

};
const int batchSize = 4;
var agentInfos = GetFakeAgentInfos();
var agentInfos = GetFakeAgents();
var alloc = new TensorCachingAllocator();
var generator = new PreviousActionInputGenerator(alloc);

valueType = TensorProxy.TensorType.FloatingPoint
};
const int batchSize = 4;
var agentInfos = GetFakeAgentInfos();
var agentInfos = GetFakeAgents();
var alloc = new TensorCachingAllocator();
var generator = new ActionMaskInputGenerator(alloc);
generator.Generate(inputTensor, batchSize, agentInfos);

21
UnitySDK/Assets/ML-Agents/Editor/Tests/MLAgentsEditModeTest.cs


using NUnit.Framework;
using System.Reflection;
using MLAgents.Sensor;
using MLAgents.InferenceBrain;
namespace MLAgents.Tests
{

{
initializeAgentCalls += 1;
// Add in some custom sensors so we can confirm they get sorted as expected.
// Add in some custom Sensors so we can confirm they get sorted as expected.
m_Sensors.Add(sensor2);
m_Sensors.Add(sensor1);
sensors.Add(sensor2);
sensors.Add(sensor1);
}
public override void CollectObservations()

public int[] GetFloatObservationShape()
{
return new[] { 1 };
return new[] { 0 };
public void WriteToTensor(TensorProxy tensorProxy, int agentIndex) { }
public int Write(WriteAdapter adapter)
{
// No-op
return 0;
}
public byte[] GetCompressedObservation()
{

Assert.AreEqual(0, agent1.agentActionCalls);
Assert.AreEqual(0, agent2.agentActionCalls);
// Make sure the sensors were sorted
Assert.AreEqual(agent1.m_Sensors[0].GetName(), "testsensor1");
Assert.AreEqual(agent1.m_Sensors[1].GetName(), "testsensor2");
// Make sure the Sensors were sorted
Assert.AreEqual(agent1.sensors[0].GetName(), "testsensor1");
Assert.AreEqual(agent1.sensors[1].GetName(), "testsensor2");
}
}

6
UnitySDK/Assets/ML-Agents/Editor/Tests/RandomNormalTest.cs


{
public class RandomNormalTest
{
private const float k_FirstValue = -1.19580f;
private const float k_SecondValue = -0.97345f;
private const double k_Epsilon = 0.0001;
const float k_FirstValue = -1.19580f;
const float k_SecondValue = -0.97345f;
const double k_Epsilon = 0.0001;
[Test]
public void RandomNormalTestTwoDouble()

4
UnitySDK/Assets/ML-Agents/Editor/Tests/RayPerceptionTests.cs


var go = new GameObject("MyGameObject");
var rayPer3D = go.AddComponent<RayPerception3D>();
var result = rayPer3D.Perceive(1f, angles ,
tags, 0f, 0f);
Debug.Log(result.Count);
var result = rayPer3D.Perceive(1f, angles, tags);
Assert.IsTrue(result.Count == angles.Length * (tags.Length + 2));
}

6
UnitySDK/Assets/ML-Agents/Editor/Tests/StandaloneBuildTest.cs


string[] scenes = { "Assets/ML-Agents/Examples/3DBall/Scenes/3DBall.unity" };
var buildResult = BuildPipeline.BuildPlayer(scenes, "testPlayer", BuildTarget.StandaloneOSX, BuildOptions.None);
#if UNITY_2018_1_OR_NEWER
var isOK = buildResult.summary.result == BuildResult.Succeeded;
var isOk = buildResult.summary.result == BuildResult.Succeeded;
var error = "";
foreach (var stepInfo in buildResult.steps)
{

}
#else
var error = buildResult;
var isOK = string.IsNullOrEmpty(error);
var isOk = string.IsNullOrEmpty(error);
if (isOK)
if (isOk)
{
EditorApplication.Exit(0);
}

4
UnitySDK/Assets/ML-Agents/Examples/3DBall/Scripts/Ball3DAgent.cs


{
[Header("Specific to Ball3D")]
public GameObject ball;
private Rigidbody m_BallRb;
private ResetParameters m_ResetParams;
Rigidbody m_BallRb;
ResetParameters m_ResetParams;
public override void InitializeAgent()
{

4
UnitySDK/Assets/ML-Agents/Examples/3DBall/Scripts/Ball3DHardAgent.cs


{
[Header("Specific to Ball3DHard")]
public GameObject ball;
private Rigidbody m_BallRb;
private ResetParameters m_ResetParams;
Rigidbody m_BallRb;
ResetParameters m_ResetParams;
public override void InitializeAgent()
{

6
UnitySDK/Assets/ML-Agents/Examples/Basic/Scripts/BasicAgent.cs


public class BasicAgent : Agent
{
[Header("Specific to Basic")]
private BasicAcademy m_Academy;
BasicAcademy m_Academy;
private float m_TimeSinceDecision;
float m_TimeSinceDecision;
int m_Position;
int m_SmallGoalPosition;
int m_LargeGoalPosition;

WaitTimeInference();
}
private void WaitTimeInference()
void WaitTimeInference()
{
if (!m_Academy.GetIsInference())
{

4
UnitySDK/Assets/ML-Agents/Examples/Bouncer/Scripts/BouncerAgent.cs


{
}
private void FixedUpdate()
void FixedUpdate()
{
if (Physics.Raycast(transform.position, new Vector3(0f, -1f, 0f), 0.51f) && m_JumpCooldown <= 0f)
{

return action;
}
private void Update()
void Update()
{
if (m_LookDir.magnitude > float.Epsilon)
{

2
UnitySDK/Assets/ML-Agents/Examples/Bouncer/Scripts/BouncerTarget.cs


gameObject.transform.Rotate(new Vector3(1, 0, 0), 0.5f);
}
private void OnTriggerEnter(Collider collision)
void OnTriggerEnter(Collider collision)
{
var agent = collision.gameObject.GetComponent<Agent>();
if (agent != null)

8
UnitySDK/Assets/ML-Agents/Examples/FoodCollector/Scripts/FoodCollectorAgent.cs


public class FoodCollectorAgent : Agent
{
private FoodCollectorAcademy m_MyAcademy;
FoodCollectorAcademy m_MyAcademy;
public GameObject area;
FoodCollectorArea m_MyArea;
bool m_Frozen;

float m_FrozenTime;
float m_EffectTime;
Rigidbody m_AgentRb;
private float m_LaserLength;
float m_LaserLength;
// Speed of agent rotation.
public float turnSpeed = 300;

public Material frozenMaterial;
public GameObject myLaser;
public bool contribute;
private RayPerception3D m_RayPer;
RayPerception3D m_RayPer;
public bool useVectorObs;

const float rayDistance = 50f;
float[] rayAngles = { 20f, 90f, 160f, 45f, 135f, 70f, 110f };
string[] detectableObjects = { "food", "agent", "wall", "badFood", "frozenAgent" };
AddVectorObs(m_RayPer.Perceive(rayDistance, rayAngles, detectableObjects, 0f, 0f));
AddVectorObs(m_RayPer.Perceive(rayDistance, rayAngles, detectableObjects));
var localVelocity = transform.InverseTransformDirection(m_AgentRb.velocity);
AddVectorObs(localVelocity.x);
AddVectorObs(localVelocity.z);

18
UnitySDK/Assets/ML-Agents/Examples/GridWorld/Scripts/GridAgent.cs


public class GridAgent : Agent
{
private Academy m_Academy;
Academy m_Academy;
private float m_TimeSinceDecision;
float m_TimeSinceDecision;
[Tooltip("Because we want an observation right before making a decision, we can force " +
"a camera to render before making a decision. Place the agentCam here if using " +

"masking turned on may not behave optimally when action masking is turned off.")]
public bool maskActions = true;
private const int k_NoAction = 0; // do nothing!
private const int k_Up = 1;
private const int k_Down = 2;
private const int k_Left = 3;
private const int k_Right = 4;
const int k_NoAction = 0; // do nothing!
const int k_Up = 1;
const int k_Down = 2;
const int k_Left = 3;
const int k_Right = 4;
public override void InitializeAgent()
{

/// <summary>
/// Applies the mask for the agents action to disallow unnecessary actions.
/// </summary>
private void SetMask()
void SetMask()
{
// Prevents the agent from picking an action that would make it collide with a wall
var positionX = (int)transform.position.x;

WaitTimeInference();
}
private void WaitTimeInference()
void WaitTimeInference()
{
if (renderCamera != null)
{

4
UnitySDK/Assets/ML-Agents/Examples/GridWorld/Scripts/GridArea.cs


public GameObject trueAgent;
private ResetParameters m_ResetParameters;
ResetParameters m_ResetParameters;
Camera m_AgentCam;

GameObject m_Se;
GameObject m_Sw;
private Vector3 m_InitialPosition;
Vector3 m_InitialPosition;
public void Awake()
{

2
UnitySDK/Assets/ML-Agents/Examples/Hallway/Scripts/HallwayAgent.cs


float[] rayAngles = { 20f, 60f, 90f, 120f, 160f };
string[] detectableObjects = { "symbol_O_Goal", "symbol_X_Goal", "symbol_O", "symbol_X", "wall" };
AddVectorObs(GetStepCount() / (float)agentParameters.maxStep);
AddVectorObs(m_RayPer.Perceive(rayDistance, rayAngles, detectableObjects, 0f, 0f));
AddVectorObs(m_RayPer.Perceive(rayDistance, rayAngles, detectableObjects));
}
}

4
UnitySDK/Assets/ML-Agents/Examples/PushBlock/Scripts/PushAgentBasic.cs


{
var rayDistance = 12f;
AddVectorObs(m_RayPer.Perceive(rayDistance, m_RayAngles, m_DetectableObjects, 0f, 0f));
AddVectorObs(m_RayPer.Perceive(rayDistance, m_RayAngles, m_DetectableObjects, 1.5f, 0f));
AddVectorObs(m_RayPer.Perceive(rayDistance, m_RayAngles, m_DetectableObjects));
AddVectorObs(m_RayPer.Perceive(rayDistance, m_RayAngles, m_DetectableObjects, 1.5f, 1.5f));
}
}

12
UnitySDK/Assets/ML-Agents/Examples/Pyramids/Scripts/PyramidAgent.cs


public class PyramidAgent : Agent
{
public GameObject area;
private PyramidArea m_MyArea;
private Rigidbody m_AgentRb;
private RayPerception m_RayPer;
private PyramidSwitch m_SwitchLogic;
PyramidArea m_MyArea;
Rigidbody m_AgentRb;
RayPerception m_RayPer;
PyramidSwitch m_SwitchLogic;
public GameObject areaSwitch;
public bool useVectorObs;

float[] rayAngles2 = { 15f, 85f, 155f, 40f, 130f, 65f, 105f };
string[] detectableObjects = { "block", "wall", "goal", "switchOff", "switchOn", "stone" };
AddVectorObs(m_RayPer.Perceive(rayDistance, rayAngles, detectableObjects, 0f, 0f));
AddVectorObs(m_RayPer.Perceive(rayDistance, rayAngles, detectableObjects));
AddVectorObs(m_RayPer.Perceive(rayDistance, rayAngles1, detectableObjects, 0f, 5f));
AddVectorObs(m_RayPer.Perceive(rayDistance, rayAngles2, detectableObjects, 0f, 10f));
AddVectorObs(m_SwitchLogic.GetState());

m_MyArea.CreateStonePyramid(1, items[8]);
}
private void OnCollisionEnter(Collision collision)
void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.CompareTag("goal"))
{

2
UnitySDK/Assets/ML-Agents/Examples/Pyramids/Scripts/PyramidArea.cs


CreateObject(numObjects, stonePyramid, spawnAreaIndex);
}
private void CreateObject(int numObjects, GameObject desiredObject, int spawnAreaIndex)
void CreateObject(int numObjects, GameObject desiredObject, int spawnAreaIndex)
{
for (var i = 0; i < numObjects; i++)
{

12
UnitySDK/Assets/ML-Agents/Examples/Pyramids/Scripts/PyramidSwitch.cs


public Material onMaterial;
public Material offMaterial;
public GameObject myButton;
private bool m_State;
private GameObject m_Area;
private PyramidArea m_AreaComponent;
private int m_PyramidIndex;
bool m_State;
GameObject m_Area;
PyramidArea m_AreaComponent;
int m_PyramidIndex;
public bool GetState()
{

private void Start()
void Start()
{
m_Area = gameObject.transform.parent.gameObject;
m_AreaComponent = m_Area.GetComponent<PyramidArea>();

myButton.GetComponent<Renderer>().material = offMaterial;
}
private void OnCollisionEnter(Collision other)
void OnCollisionEnter(Collision other)
{
if (other.gameObject.CompareTag("agent") && m_State == false)
{

14
UnitySDK/Assets/ML-Agents/Examples/Reacher/Scripts/ReacherAgent.cs


public GameObject pendulumB;
public GameObject hand;
public GameObject goal;
private ReacherAcademy m_MyAcademy;
ReacherAcademy m_MyAcademy;
private Rigidbody m_RbA;
private Rigidbody m_RbB;
Rigidbody m_RbA;
Rigidbody m_RbB;
private float m_GoalSpeed;
float m_GoalSpeed;
private float m_GoalSize;
float m_GoalSize;
private float m_Deviation;
float m_Deviation;
private float m_DeviationFreq;
float m_DeviationFreq;
/// <summary>
/// Collect the rigidbodies of the reacher in order to resue them for

6
UnitySDK/Assets/ML-Agents/Examples/Reacher/Scripts/ReacherGoal.cs


public GameObject hand;
public GameObject goalOn;
private void OnTriggerEnter(Collider other)
void OnTriggerEnter(Collider other)
{
if (other.gameObject == hand)
{

private void OnTriggerExit(Collider other)
void OnTriggerExit(Collider other)
{
if (other.gameObject == hand)
{

private void OnTriggerStay(Collider other)
void OnTriggerStay(Collider other)
{
if (other.gameObject == hand)
{

6
UnitySDK/Assets/ML-Agents/Examples/SharedAssets/Scripts/FlyCamera.cs


public bool rotateOnlyIfMousedown = true;
public bool movementStaysFlat = true;
private Vector3
Vector3
private float m_TotalRun = 1.0f;
float m_TotalRun = 1.0f;
void Awake()
{

}
}
private Vector3 GetBaseInput()
Vector3 GetBaseInput()
{
// returns the basic values, if it's 0 than it's not active.
var pVelocity = new Vector3();

2
UnitySDK/Assets/ML-Agents/Examples/SharedAssets/Scripts/GroundContact.cs


public bool penalizeGroundContact; // Whether to penalize on contact.
public float groundContactPenalty; // Penalty amount (ex: -1).
public bool touchingGround;
private const string k_Ground = "ground"; // Tag of ground object.
const string k_Ground = "ground"; // Tag of ground object.
/// <summary>
/// Check for collision with ground, and optionally penalize agent.

21
UnitySDK/Assets/ML-Agents/Examples/SharedAssets/Scripts/RayPerception3D.cs


/// </summary>
public class RayPerception3D : RayPerception
{
Vector3 m_EndPosition;
private float[] m_SubList;
float[] m_SubList;
/// <summary>
/// Creates perception vector to be used as part of an observation of an agent.

// along with object distance.
foreach (var angle in rayAngles)
{
m_EndPosition = transform.TransformDirection(
PolarToCartesian(rayDistance, angle));
m_EndPosition.y = endOffset;
Vector3 startPositionLocal = new Vector3(0, startOffset, 0);
Vector3 endPositionLocal = PolarToCartesian(rayDistance, angle);
endPositionLocal.y += endOffset;
var startPositionWorld = transform.TransformPoint(startPositionLocal);
var endPositionWorld = transform.TransformPoint(endPositionLocal);
var rayDirection = endPositionWorld - startPositionWorld;
Debug.DrawRay(transform.position + new Vector3(0f, startOffset, 0f),
m_EndPosition, Color.black, 0.01f, true);
Debug.DrawRay(startPositionWorld,rayDirection, Color.black, 0.01f, true);
if (Physics.SphereCast(transform.position +
new Vector3(0f, startOffset, 0f), 0.5f,
m_EndPosition, out m_Hit, rayDistance))
if (Physics.SphereCast(startPositionWorld, 0.5f, rayDirection, out m_Hit, rayDistance))
{
for (var i = 0; i < detectableObjects.Length; i++)
{

2
UnitySDK/Assets/ML-Agents/Examples/SharedAssets/Scripts/TargetContact.cs


public class TargetContact : MonoBehaviour
{
[Header("Detect Targets")] public bool touchingTarget;
private const string k_Target = "target"; // Tag on target object.
const string k_Target = "target"; // Tag on target object.
/// <summary>
/// Check for collision with a target.

4
UnitySDK/Assets/ML-Agents/Examples/Soccer/Scripts/AgentSoccer.cs


{
detectableObjects = m_DetectableObjectsBlue;
}
AddVectorObs(m_RayPer.Perceive(rayDistance, m_RayAngles, detectableObjects, 0f, 0f));
AddVectorObs(m_RayPer.Perceive(rayDistance, m_RayAngles, detectableObjects, 1f, 0f));
AddVectorObs(m_RayPer.Perceive(rayDistance, m_RayAngles, detectableObjects));
AddVectorObs(m_RayPer.Perceive(rayDistance, m_RayAngles, detectableObjects, 1f, 1f));
}
public void MoveAgent(float[] act)

10
UnitySDK/Assets/ML-Agents/Examples/Tennis/Scripts/HitWall.cs


public GameObject areaObject;
public int lastAgentHit;
private TennisArea m_Area;
private TennisAgent m_AgentA;
private TennisAgent m_AgentB;
TennisArea m_Area;
TennisAgent m_AgentA;
TennisAgent m_AgentB;
// Use this for initialization
void Start()

m_AgentB = m_Area.agentB.GetComponent<TennisAgent>();
}
private void OnTriggerExit(Collider other)
void OnTriggerExit(Collider other)
{
if (other.name == "over")
{

}
}
private void OnCollisionEnter(Collision collision)
void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.CompareTag("iWall"))
{

16
UnitySDK/Assets/ML-Agents/Examples/Tennis/Scripts/TennisAgent.cs


public float angle;
public float scale;
private Text m_TextComponent;
private Rigidbody m_AgentRb;
private Rigidbody m_BallRb;
private float m_InvertMult;
private ResetParameters m_ResetParams;
Text m_TextComponent;
Rigidbody m_AgentRb;
Rigidbody m_BallRb;
float m_InvertMult;
ResetParameters m_ResetParams;
private const string k_CanvasName = "Canvas";
private const string k_ScoreBoardAName = "ScoreA";
private const string k_ScoreBoardBName = "ScoreB";
const string k_CanvasName = "Canvas";
const string k_ScoreBoardAName = "ScoreA";
const string k_ScoreBoardBName = "ScoreB";
public override void InitializeAgent()
{

2
UnitySDK/Assets/ML-Agents/Examples/Tennis/Scripts/TennisArea.cs


public GameObject ball;
public GameObject agentA;
public GameObject agentB;
private Rigidbody m_BallRb;
Rigidbody m_BallRb;
// Use this for initialization
void Start()

8
UnitySDK/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAgent.cs


bool m_IsNewDecisionStep;
int m_CurrentDecisionStep;
private Rigidbody m_HipsRb;
private Rigidbody m_ChestRb;
private Rigidbody m_SpineRb;
Rigidbody m_HipsRb;
Rigidbody m_ChestRb;
Rigidbody m_SpineRb;
private ResetParameters m_ResetParams;
ResetParameters m_ResetParams;
public override void InitializeAgent()
{

6
UnitySDK/Assets/ML-Agents/Examples/WallJump/Scripts/WallJumpAgent.cs


var rayDistance = 20f;
float[] rayAngles = { 0f, 45f, 90f, 135f, 180f, 110f, 70f };
AddVectorObs(m_RayPer.Perceive(
rayDistance, rayAngles, m_DetectableObjects, 0f, 0f));
rayDistance, rayAngles, m_DetectableObjects));
rayDistance, rayAngles, m_DetectableObjects, 2.5f, 2.5f));
rayDistance, rayAngles, m_DetectableObjects, 2.5f, 5.0f));
var agentPos = m_AgentRb.position - ground.transform.position;
AddVectorObs(agentPos / 20f);

m_AgentRb.velocity = default(Vector3);
}
private void FixedUpdate()
void FixedUpdate()
{
if (m_Configuration != -1)
{

6
UnitySDK/Assets/ML-Agents/Plugins/Barracuda.Core/Barracuda/Plugins/Editor/BarracudaEditor/NNModelImporter.cs


[ScriptedImporter(1, new[] {"nn"})]
public class NNModelImporter : ScriptedImporter
{
private const string k_IconName = "NNModelIcon";
const string k_IconName = "NNModelIcon";
private Texture2D m_IconTexture;
Texture2D m_IconTexture;
public override void OnImportAsset(AssetImportContext ctx)
{

ctx.SetMainObject(asset);
}
private Texture2D LoadIconTexture()
Texture2D LoadIconTexture()
{
if (m_IconTexture == null)
{

20
UnitySDK/Assets/ML-Agents/Scripts/Academy.cs


"docs/Learning-Environment-Design-Academy.md")]
public abstract class Academy : MonoBehaviour
{
private const string k_ApiVersion = "API-11";
const string k_ApiVersion = "API-11";
private Vector3 m_OriginalGravity;
Vector3 m_OriginalGravity;
private float m_OriginalFixedDeltaTime;
float m_OriginalFixedDeltaTime;
private float m_OriginalMaximumDeltaTime;
float m_OriginalMaximumDeltaTime;
// Fields provided in the Inspector

/// Pointer to the communicator currently in use by the Academy.
public