浏览代码

Merge branch 'master' into soccer-fives

/soccer-fives
Andrew Cohen 5 年前
当前提交
573b1f6d
共有 214 个文件被更改,包括 1307 次插入879 次删除
  1. 6
      .pre-commit-config.yaml
  2. 2
      Project/Assets/ML-Agents/Examples/3DBall/Demos/Expert3DBall.demo.meta
  3. 2
      Project/Assets/ML-Agents/Examples/3DBall/Demos/Expert3DBallHard.demo.meta
  4. 2
      Project/Assets/ML-Agents/Examples/3DBall/Scripts/Ball3DAgent.cs
  5. 2
      Project/Assets/ML-Agents/Examples/3DBall/Scripts/Ball3DHardAgent.cs
  6. 2
      Project/Assets/ML-Agents/Examples/Basic/Demos/ExpertBasic.demo.meta
  7. 53
      Project/Assets/ML-Agents/Examples/Basic/Scenes/Basic.unity
  8. 2
      Project/Assets/ML-Agents/Examples/Bouncer/Demos/ExpertBouncer.demo.meta
  9. 2
      Project/Assets/ML-Agents/Examples/Bouncer/Scripts/BouncerAgent.cs
  10. 2
      Project/Assets/ML-Agents/Examples/Crawler/Demos/ExpertCrawlerDyn.demo.meta
  11. 2
      Project/Assets/ML-Agents/Examples/Crawler/Demos/ExpertCrawlerSta.demo.meta
  12. 1
      Project/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAgent.cs
  13. 2
      Project/Assets/ML-Agents/Examples/FoodCollector/Demos/ExpertFood.demo.meta
  14. 1
      Project/Assets/ML-Agents/Examples/FoodCollector/Scripts/FoodCollectorAgent.cs
  15. 2
      Project/Assets/ML-Agents/Examples/GridWorld/Demos/ExpertGrid.demo.meta
  16. 54
      Project/Assets/ML-Agents/Examples/GridWorld/Scripts/GridAgent.cs
  17. 1
      Project/Assets/ML-Agents/Examples/GridWorld/Scripts/GridArea.cs
  18. 2
      Project/Assets/ML-Agents/Examples/Hallway/Demos/ExpertHallway.demo.meta
  19. 1
      Project/Assets/ML-Agents/Examples/Hallway/Scripts/HallwayAgent.cs
  20. 2
      Project/Assets/ML-Agents/Examples/PushBlock/Demos/ExpertPush.demo.meta
  21. 2
      Project/Assets/ML-Agents/Examples/Pyramids/Demos/ExpertPyramid.demo.meta
  22. 1
      Project/Assets/ML-Agents/Examples/Pyramids/Scripts/PyramidAgent.cs
  23. 2
      Project/Assets/ML-Agents/Examples/Reacher/Demos/ExpertReacher.demo.meta
  24. 1
      Project/Assets/ML-Agents/Examples/Reacher/Scripts/ReacherAgent.cs
  25. 11
      Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/ModelOverrider.cs
  26. 6
      Project/Assets/ML-Agents/Examples/Soccer/Scripts/AgentSoccer.cs
  27. 1
      Project/Assets/ML-Agents/Examples/Template/Scripts/TemplateAgent.cs
  28. 2
      Project/Assets/ML-Agents/Examples/Tennis/Demos/ExpertTennis.demo.meta
  29. 2
      Project/Assets/ML-Agents/Examples/Tennis/Scripts/TennisAgent.cs
  30. 2
      Project/Assets/ML-Agents/Examples/Walker/Demos/ExpertWalker.demo.meta
  31. 2
      Project/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAgent.cs
  32. 2
      Project/Assets/ML-Agents/Examples/WallJump/Scripts/WallJumpAgent.cs
  33. 5
      Project/ProjectSettings/EditorBuildSettings.asset
  34. 3
      README.md
  35. 21
      com.unity.ml-agents/CHANGELOG.md
  36. 4
      com.unity.ml-agents/Editor/AgentEditor.cs
  37. 11
      com.unity.ml-agents/Editor/BehaviorParametersEditor.cs
  38. 3
      com.unity.ml-agents/Editor/BrainParametersDrawer.cs
  39. 153
      com.unity.ml-agents/Editor/DemonstrationDrawer.cs
  40. 3
      com.unity.ml-agents/Editor/DemonstrationImporter.cs
  41. 6
      com.unity.ml-agents/Editor/RayPerceptionSensorComponentBaseEditor.cs
  42. 982
      com.unity.ml-agents/Plugins/ProtoBuffer/System.Interactive.Async.dll
  43. 28
      com.unity.ml-agents/Runtime/Academy.cs
  44. 130
      com.unity.ml-agents/Runtime/Agent.cs
  45. 12
      com.unity.ml-agents/Runtime/Communicator/GrpcExtensions.cs
  46. 23
      com.unity.ml-agents/Runtime/Communicator/ICommunicator.cs
  47. 34
      com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs
  48. 3
      com.unity.ml-agents/Runtime/Demonstrations/Demonstration.cs
  49. 15
      com.unity.ml-agents/Runtime/Demonstrations/DemonstrationRecorder.cs
  50. 6
      com.unity.ml-agents/Runtime/Demonstrations/DemonstrationWriter.cs
  51. 74
      com.unity.ml-agents/Runtime/Grpc/CommunicatorObjects/UnityRlInitializationInput.cs
  52. 79
      com.unity.ml-agents/Runtime/Grpc/CommunicatorObjects/UnityRlInitializationOutput.cs
  53. 34
      com.unity.ml-agents/Runtime/Timer.cs
  54. 1
      com.unity.ml-agents/Runtime/Utilities.cs
  55. 2
      com.unity.ml-agents/Runtime/SideChannels/SideChannel.cs
  56. 2
      com.unity.ml-agents/Runtime/SideChannels/RawBytesChannel.cs
  57. 2
      com.unity.ml-agents/Runtime/SideChannels/FloatPropertiesChannel.cs
  58. 2
      com.unity.ml-agents/Runtime/SideChannels/EngineConfigurationChannel.cs
  59. 4
      com.unity.ml-agents/Runtime/Sensors/WriteAdapter.cs
  60. 2
      com.unity.ml-agents/Runtime/Sensors/VectorSensor.cs
  61. 2
      com.unity.ml-agents/Runtime/Sensors/StackingSensor.cs
  62. 6
      com.unity.ml-agents/Runtime/Sensors/SensorShapeValidator.cs
  63. 2
      com.unity.ml-agents/Runtime/Sensors/SensorComponent.cs
  64. 2
      com.unity.ml-agents/Runtime/Sensors/SensorBase.cs
  65. 2
      com.unity.ml-agents/Runtime/Sensors/RenderTextureSensorComponent.cs
  66. 6
      com.unity.ml-agents/Runtime/Sensors/RenderTextureSensor.cs
  67. 4
      com.unity.ml-agents/Runtime/Sensors/RayPerceptionSensorComponentBase.cs
  68. 2
      com.unity.ml-agents/Runtime/Sensors/RayPerceptionSensorComponent3D.cs
  69. 2
      com.unity.ml-agents/Runtime/Sensors/RayPerceptionSensorComponent2D.cs
  70. 4
      com.unity.ml-agents/Runtime/Sensors/RayPerceptionSensor.cs
  71. 3
      com.unity.ml-agents/Runtime/Sensors/Observation.cs
  72. 2
      com.unity.ml-agents/Runtime/Sensors/ISensor.cs
  73. 2
      com.unity.ml-agents/Runtime/Sensors/CameraSensorComponent.cs
  74. 20
      com.unity.ml-agents/Runtime/Sensors/CameraSensor.cs
  75. 3
      com.unity.ml-agents/Runtime/Policies/RemotePolicy.cs
  76. 3
      com.unity.ml-agents/Runtime/Policies/IPolicy.cs
  77. 92
      com.unity.ml-agents/Runtime/Policies/HeuristicPolicy.cs
  78. 6
      com.unity.ml-agents/Runtime/Policies/BrainParameters.cs
  79. 21
      com.unity.ml-agents/Runtime/Policies/BehaviorParameters.cs
  80. 7
      com.unity.ml-agents/Runtime/Policies/BarracudaPolicy.cs
  81. 2
      com.unity.ml-agents/Runtime/Inference/Utils/RandomNormal.cs
  82. 2
      com.unity.ml-agents/Runtime/Inference/Utils/Multinomial.cs
  83. 4
      com.unity.ml-agents/Runtime/Inference/TensorProxy.cs
  84. 4
      com.unity.ml-agents/Runtime/Inference/TensorNames.cs
  85. 5
      com.unity.ml-agents/Runtime/Inference/TensorGenerator.cs
  86. 4
      com.unity.ml-agents/Runtime/Inference/TensorApplier.cs
  87. 5
      com.unity.ml-agents/Runtime/Inference/ModelRunner.cs
  88. 7
      com.unity.ml-agents/Runtime/Inference/GeneratorImpl.cs
  89. 9
      com.unity.ml-agents/Runtime/Inference/BarracudaModelParamLoader.cs
  90. 4
      com.unity.ml-agents/Runtime/Inference/ApplierImpl.cs
  91. 5
      com.unity.ml-agents/Tests/Editor/DemonstrationTests.cs
  92. 4
      com.unity.ml-agents/Tests/Editor/DiscreteActionOutputApplierTest.cs
  93. 41
      com.unity.ml-agents/Tests/Editor/EditModeTestActionMasker.cs
  94. 5
      com.unity.ml-agents/Tests/Editor/EditModeTestInternalBrainTensorApplier.cs
  95. 8
      com.unity.ml-agents/Tests/Editor/EditModeTestInternalBrainTensorGenerator.cs
  96. 58
      com.unity.ml-agents/Tests/Editor/MLAgentsEditModeTest.cs
  97. 2
      com.unity.ml-agents/Tests/Editor/MultinomialTest.cs
  98. 2
      com.unity.ml-agents/Tests/Editor/RandomNormalTest.cs
  99. 2
      com.unity.ml-agents/Tests/Editor/Sensor/FloatVisualSensorTests.cs
  100. 1
      com.unity.ml-agents/Tests/Editor/Sensor/RayPerceptionSensorTests.cs

6
.pre-commit-config.yaml


language: script
entry: utils/validate_versions.py
files: ".*/__init__.py"
- id: validate-init-py
name: validate __init__.py files
language: script
entry: utils/validate_inits.py
types: [python]

2
Project/Assets/ML-Agents/Examples/3DBall/Demos/Expert3DBall.demo.meta


fileIDToRecycleName:
11400000: Assets/ML-Agents/Examples/3DBall/Demos/Expert3DBall.demo
externalObjects: {}
userData: ' (MLAgents.Demonstration)'
userData: ' (MLAgents.Demonstrations.Demonstration)'
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 7bd65ce151aaa4a41a45312543c56be1, type: 3}

2
Project/Assets/ML-Agents/Examples/3DBall/Demos/Expert3DBallHard.demo.meta


fileIDToRecycleName:
11400000: Assets/ML-Agents/Examples/3DBall/Demos/Expert3DBallHard.demo
externalObjects: {}
userData: ' (MLAgents.Demonstration)'
userData: ' (MLAgents.Demonstrations.Demonstration)'
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 7bd65ce151aaa4a41a45312543c56be1, type: 3}

2
Project/Assets/ML-Agents/Examples/3DBall/Scripts/Ball3DAgent.cs


using UnityEngine;
using MLAgents;
using MLAgents.Sensors;
using MLAgents.SideChannels;
public class Ball3DAgent : Agent
{

2
Project/Assets/ML-Agents/Examples/3DBall/Scripts/Ball3DHardAgent.cs


using UnityEngine;
using MLAgents;
using MLAgents.Sensors;
using MLAgents.SideChannels;
public class Ball3DHardAgent : Agent
{

2
Project/Assets/ML-Agents/Examples/Basic/Demos/ExpertBasic.demo.meta


fileIDToRecycleName:
11400000: Assets/ML-Agents/Examples/Basic/Demos/ExpertBasic.demo
externalObjects: {}
userData: ' (MLAgents.Demonstration)'
userData: ' (MLAgents.Demonstrations.Demonstration)'
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 7bd65ce151aaa4a41a45312543c56be1, type: 3}

53
Project/Assets/ML-Agents/Examples/Basic/Scenes/Basic.unity


objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 5889392e3f05b448a8a06c5def6c2dec, type: 3}
--- !u!1 &1335907378 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 1263463520136984, guid: c5eb289873aca4f5a8cc59c7464ab7c1,
type: 3}
m_PrefabInstance: {fileID: 1783603361}
m_PrefabAsset: {fileID: 0}
--- !u!114 &1335907380
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1335907378}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 88b6042bc9a5d4aa58d931eae49442e5, type: 3}
m_Name:
m_EditorClassIdentifier:
agentParameters:
maxStep: 0
hasUpgradedFromAgentParameters: 1
maxStep: 0
--- !u!114 &1335907381 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 114827551040495112, guid: c5eb289873aca4f5a8cc59c7464ab7c1,
type: 3}
m_PrefabInstance: {fileID: 1783603361}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1335907378}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 624480a72e46148118ab2e2d89b537de, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &1335907384
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1335907378}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6ee410d6d45349218d5e69bb2a347c63, type: 3}
m_Name:
m_EditorClassIdentifier:
basicController: {fileID: 1335907381}
--- !u!1001 &1502457254
PrefabInstance:
m_ObjectHideFlags: 0

propertyPath: m_LocalScale.z
value: 6.270299
objectReference: {fileID: 0}
- target: {fileID: 114502619508238574, guid: c5eb289873aca4f5a8cc59c7464ab7c1,
type: 3}
propertyPath: m_BrainParameters.vectorObservationSize
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: c5eb289873aca4f5a8cc59c7464ab7c1, type: 3}
--- !u!1 &1889211226

m_Name:
m_EditorClassIdentifier:
gravityMultiplier: 1
monitorVerticalOffset: 0
fixedDeltaTime: 0.02
maximumDeltaTime: 0.33333334
solverIterations: 6

2
Project/Assets/ML-Agents/Examples/Bouncer/Demos/ExpertBouncer.demo.meta


fileIDToRecycleName:
11400000: Assets/ML-Agents/Examples/Bouncer/Demos/ExpertBouncer.demo
externalObjects: {}
userData: ' (MLAgents.Demonstration)'
userData: ' (MLAgents.Demonstrations.Demonstration)'
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 7bd65ce151aaa4a41a45312543c56be1, type: 3}

2
Project/Assets/ML-Agents/Examples/Bouncer/Scripts/BouncerAgent.cs


using UnityEngine;
using MLAgents;
using MLAgents.Sensors;
using MLAgents.SideChannels;
public class BouncerAgent : Agent
{

2
Project/Assets/ML-Agents/Examples/Crawler/Demos/ExpertCrawlerDyn.demo.meta


fileIDToRecycleName:
11400000: Assets/ML-Agents/Examples/Crawler/Demos/ExpertCrawlerDyn.demo
externalObjects: {}
userData: ' (MLAgents.Demonstration)'
userData: ' (MLAgents.Demonstrations.Demonstration)'
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 7bd65ce151aaa4a41a45312543c56be1, type: 3}

2
Project/Assets/ML-Agents/Examples/Crawler/Demos/ExpertCrawlerSta.demo.meta


fileIDToRecycleName:
11400000: Assets/ML-Agents/Examples/Crawler/Demos/ExpertCrawlerSta.demo
externalObjects: {}
userData: ' (MLAgents.Demonstration)'
userData: ' (MLAgents.Demonstrations.Demonstration)'
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 7bd65ce151aaa4a41a45312543c56be1, type: 3}

1
Project/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAgent.cs


using UnityEngine;
using MLAgents;
using MLAgentsExamples;
using MLAgents.Sensors;
[RequireComponent(typeof(JointDriveController))] // Required to set joint forces
public class CrawlerAgent : Agent

2
Project/Assets/ML-Agents/Examples/FoodCollector/Demos/ExpertFood.demo.meta


fileIDToRecycleName:
11400000: Assets/ML-Agents/Examples/FoodCollector/Demos/ExpertFood.demo
externalObjects: {}
userData: ' (MLAgents.Demonstration)'
userData: ' (MLAgents.Demonstrations.Demonstration)'
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 7bd65ce151aaa4a41a45312543c56be1, type: 3}

1
Project/Assets/ML-Agents/Examples/FoodCollector/Scripts/FoodCollectorAgent.cs


using UnityEngine;
using MLAgents;
using MLAgents.Sensors;
public class FoodCollectorAgent : Agent
{

2
Project/Assets/ML-Agents/Examples/GridWorld/Demos/ExpertGrid.demo.meta


fileIDToRecycleName:
11400000: Assets/ML-Agents/Examples/GridWorld/Demos/ExpertGrid.demo
externalObjects: {}
userData: ' (MLAgents.Demonstration)'
userData: ' (MLAgents.Demonstrations.Demonstration)'
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 7bd65ce151aaa4a41a45312543c56be1, type: 3}

54
Project/Assets/ML-Agents/Examples/GridWorld/Scripts/GridAgent.cs


using UnityEngine;
using System.Linq;
using MLAgents;
using MLAgents.Sensors;
using UnityEngine.Serialization;
public class GridAgent : Agent

{
}
public override void CollectObservations(VectorSensor sensor, ActionMasker actionMasker)
public override void CollectDiscreteActionMasks(DiscreteActionMasker actionMasker)
// There are no numeric observations to collect as this environment uses visual
// observations.
SetMask(actionMasker);
}
}
/// <summary>
/// Applies the mask for the agents action to disallow unnecessary actions.
/// </summary>
void SetMask(ActionMasker actionMasker)
{
// Prevents the agent from picking an action that would make it collide with a wall
var positionX = (int)transform.position.x;
var positionZ = (int)transform.position.z;
var maxPosition = (int)Academy.Instance.FloatProperties.GetPropertyWithDefault("gridSize", 5f) - 1;
// Prevents the agent from picking an action that would make it collide with a wall
var positionX = (int)transform.position.x;
var positionZ = (int)transform.position.z;
var maxPosition = (int)Academy.Instance.FloatProperties.GetPropertyWithDefault("gridSize", 5f) - 1;
if (positionX == 0)
{
actionMasker.SetActionMask(k_Left);
}
if (positionX == 0)
{
actionMasker.SetMask(0, new int[]{ k_Left});
}
if (positionX == maxPosition)
{
actionMasker.SetActionMask(k_Right);
}
if (positionX == maxPosition)
{
actionMasker.SetMask(0, new int[]{k_Right});
}
if (positionZ == 0)
{
actionMasker.SetActionMask(k_Down);
}
if (positionZ == 0)
{
actionMasker.SetMask(0, new int[]{k_Down});
}
if (positionZ == maxPosition)
{
actionMasker.SetActionMask(k_Up);
if (positionZ == maxPosition)
{
actionMasker.SetMask(0, new int[]{k_Up});
}
}
}

1
Project/Assets/ML-Agents/Examples/GridWorld/Scripts/GridArea.cs


using UnityEngine;
using System.Linq;
using MLAgents;
using MLAgents.SideChannels;
public class GridArea : MonoBehaviour

2
Project/Assets/ML-Agents/Examples/Hallway/Demos/ExpertHallway.demo.meta


fileIDToRecycleName:
11400000: Assets/ML-Agents/Examples/Hallway/Demos/ExpertHallway.demo
externalObjects: {}
userData: ' (MLAgents.Demonstration)'
userData: ' (MLAgents.Demonstrations.Demonstration)'
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 7bd65ce151aaa4a41a45312543c56be1, type: 3}

1
Project/Assets/ML-Agents/Examples/Hallway/Scripts/HallwayAgent.cs


using System.Collections;
using UnityEngine;
using MLAgents;
using MLAgents.Sensors;
public class HallwayAgent : Agent
{

2
Project/Assets/ML-Agents/Examples/PushBlock/Demos/ExpertPush.demo.meta


fileIDToRecycleName:
11400000: Assets/ML-Agents/Examples/PushBlock/Demos/ExpertPush.demo
externalObjects: {}
userData: ' (MLAgents.Demonstration)'
userData: ' (MLAgents.Demonstrations.Demonstration)'
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 7bd65ce151aaa4a41a45312543c56be1, type: 3}

2
Project/Assets/ML-Agents/Examples/Pyramids/Demos/ExpertPyramid.demo.meta


fileIDToRecycleName:
11400000: Assets/ML-Agents/Examples/Pyramids/Demos/ExpertPyramid.demo
externalObjects: {}
userData: ' (MLAgents.Demonstration)'
userData: ' (MLAgents.Demonstrations.Demonstration)'
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 7bd65ce151aaa4a41a45312543c56be1, type: 3}

1
Project/Assets/ML-Agents/Examples/Pyramids/Scripts/PyramidAgent.cs


using UnityEngine;
using Random = UnityEngine.Random;
using MLAgents;
using MLAgents.Sensors;
public class PyramidAgent : Agent
{

2
Project/Assets/ML-Agents/Examples/Reacher/Demos/ExpertReacher.demo.meta


fileIDToRecycleName:
11400000: Assets/ML-Agents/Examples/Reacher/Demos/ExpertReacher.demo
externalObjects: {}
userData: ' (MLAgents.Demonstration)'
userData: ' (MLAgents.Demonstrations.Demonstration)'
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 7bd65ce151aaa4a41a45312543c56be1, type: 3}

1
Project/Assets/ML-Agents/Examples/Reacher/Scripts/ReacherAgent.cs


using UnityEngine;
using MLAgents;
using MLAgents.Sensors;
public class ReacherAgent : Agent
{

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


using Barracuda;
using System.IO;
using MLAgents;
using MLAgents.Policies;
namespace MLAgentsExamples
{

{
if (m_NumSteps > m_MaxEpisodes * m_Agent.maxStep)
{
// Stop recording so that we don't write partial rewards to the timer info.
TimerStack.Instance.Recording = false;
Application.Quit(0);
}
}

void OverrideModel()
{
m_Agent.LazyInitialize();
var bp = m_Agent.GetComponent<BehaviorParameters>();
var name = m_Agent.BehaviorName;
var nnModel = GetModelForBehaviorName(bp.behaviorName);
Debug.Log($"Overriding behavior {bp.behaviorName} for agent with model {nnModel?.name}");
var nnModel = GetModelForBehaviorName(name);
Debug.Log($"Overriding behavior {name} for agent with model {nnModel?.name}");
m_Agent.GiveModel($"Override_{bp.behaviorName}", nnModel);
m_Agent.GiveModel($"Override_{name}", nnModel);
}
}

6
Project/Assets/ML-Agents/Examples/Soccer/Scripts/AgentSoccer.cs


using System;
using UnityEngine;
using MLAgents;
using MLAgents.Policies;
public class AgentSoccer : Agent
{

[HideInInspector]
public Rigidbody agentRb;
SoccerSettings m_SoccerSettings;
BehaviorParameters m_BehaviorParameters;
m_BehaviorParameters = gameObject.GetComponent<BehaviorParameters>();
if (m_BehaviorParameters.m_TeamID == (int)Team.Blue)
if (TeamId == (int)Team.Blue)
{
team = Team.Blue;
m_Transform = new Vector3(transform.position.x - 4f, .5f, transform.position.z);

1
Project/Assets/ML-Agents/Examples/Template/Scripts/TemplateAgent.cs


using UnityEngine;
using MLAgents;
using MLAgents.Sensors;
public class TemplateAgent : Agent
{

2
Project/Assets/ML-Agents/Examples/Tennis/Demos/ExpertTennis.demo.meta


fileIDToRecycleName:
11400000: Assets/ML-Agents/Examples/Tennis/Demos/ExpertTennis.demo
externalObjects: {}
userData: ' (MLAgents.Demonstration)'
userData: ' (MLAgents.Demonstrations.Demonstration)'
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 7bd65ce151aaa4a41a45312543c56be1, type: 3}

2
Project/Assets/ML-Agents/Examples/Tennis/Scripts/TennisAgent.cs


using UnityEngine;
using UnityEngine.UI;
using MLAgents;
using MLAgents.Sensors;
using MLAgents.SideChannels;
public class TennisAgent : Agent
{

2
Project/Assets/ML-Agents/Examples/Walker/Demos/ExpertWalker.demo.meta


fileIDToRecycleName:
11400000: Assets/ML-Agents/Examples/Walker/Demos/ExpertWalker.demo
externalObjects: {}
userData: ' (MLAgents.Demonstration)'
userData: ' (MLAgents.Demonstrations.Demonstration)'
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 7bd65ce151aaa4a41a45312543c56be1, type: 3}

2
Project/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAgent.cs


using UnityEngine;
using MLAgents;
using MLAgentsExamples;
using MLAgents.Sensors;
using MLAgents.SideChannels;
public class WalkerAgent : Agent
{

2
Project/Assets/ML-Agents/Examples/WallJump/Scripts/WallJumpAgent.cs


using UnityEngine;
using MLAgents;
using Barracuda;
using MLAgents.Sensors;
public class WallJumpAgent : Agent
{

5
Project/ProjectSettings/EditorBuildSettings.asset


EditorBuildSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Scenes:
- enabled: 1
path: Packages/com.unity.ml-agents/Tests/Runtime/SerializeTestScene.unity
guid: 60783bd849bd242eeb66243542762b23
m_Scenes: []
m_configObjects: {}

3
README.md


team at ml-agents@unity3d.com.
## Releases
The latest release is 0.14.0. Previous releases can be found below:
The latest release is 0.14.1. Previous releases can be found below:
| **0.14.0** | [source](https://github.com/Unity-Technologies/ml-agents/tree/0.14.0) | [docs](https://github.com/Unity-Technologies/ml-agents/tree/0.14.0/docs) | [download](https://github.com/Unity-Technologies/ml-agents/archive/0.14.0.zip) |
| **0.13.1** | [source](https://github.com/Unity-Technologies/ml-agents/tree/0.13.1) | [docs](https://github.com/Unity-Technologies/ml-agents/tree/0.13.1/docs) | [download](https://github.com/Unity-Technologies/ml-agents/archive/0.13.1.zip) |
| **0.13.0** | [source](https://github.com/Unity-Technologies/ml-agents/tree/0.13.0) | [docs](https://github.com/Unity-Technologies/ml-agents/tree/0.13.0/docs) | [download](https://github.com/Unity-Technologies/ml-agents/archive/0.13.0.zip) |
| **0.12.1** | [source](https://github.com/Unity-Technologies/ml-agents/tree/0.12.1) | [docs](https://github.com/Unity-Technologies/ml-agents/tree/0.12.1/docs) | [download](https://github.com/Unity-Technologies/ml-agents/archive/0.12.1.zip) |

21
com.unity.ml-agents/CHANGELOG.md


The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
- Agent.CollectObservations now takes a VectorSensor argument. It was also overloaded to optionally take an ActionMasker argument. (#3352, #3389)
- `Agent.CollectObservations` now takes a VectorSensor argument. (#3352, #3389)
- Added `Agent.CollectDiscreteActionMasks` virtual method with a `DiscreteActionMasker` argument to specify which discrete actions are unavailable to the Agent. (#3525)
- All Sensor related code has been moved to the namespace `MLAgents.Sensors`.
- All SideChannel related code has been moved to the namespace `MLAgents.SideChannels`.
- `BrainParameters` and `SpaceType` have been removed from the public API
- `BehaviorParameters` have been removed from the public API.
### Minor Changes
- Monitor.cs was moved to Examples. (#3372)

- A tutorial on adding custom SideChannels was added (#3391)
- The stepping logic for the Agent and the Academy has been simplified (#3448)
- Update Barracuda to 0.6.0-preview
- The interface for `RayPerceptionSensor.PerceiveStatic()` was changed to take an input class and write to an output class.
* The interface for `RayPerceptionSensor.PerceiveStatic()` was changed to take an input class and write to an output class, and the method was renamed to `Perceive()`.
- The checkpoint file suffix was changed from `.cptk` to `.ckpt` (#3470)
- The command-line argument used to determine the port that an environment will listen on was changed from `--port` to `--mlagents-port`.
- `DemonstrationRecorder` can now record observations outside of the editor.

- `RayPerceptionSensorComponent` and related classes now display the debug gizmos whenever the Agent is selected (not just Play mode).
- Most fields on `RayPerceptionSensorComponent` can now be changed while the editor is in Play mode. The exceptions to this are fields that affect the number of observations.
- Unused static methods from the `Utilities` class (ShiftLeft, ReplaceRange, AddRangeNoAlloc, and GetSensorFloatObservationSize) were removed.
- The `Agent` class is no longer abstract.
- SensorBase was moved out of the package and into the Examples directory.
- `AgentInfo.actionMasks` has been renamed to `AgentInfo.discreteActionMasks`.
### Bugfixes
## [0.14.1-preview] - 2020-02-25
### Bug Fixes
- Fixed demonstration recording of experiences when the Agent is done. (#3463)
- Fixed a bug with the rewards of multiple Agents in the gym interface (#3471, #3496)
## [0.14.0-preview] - 2020-02-13

4
com.unity.ml-agents/Editor/AgentEditor.cs


using UnityEngine;
using UnityEditor;
namespace MLAgents
namespace MLAgents.Editor
{
/*
This code is meant to modify the behavior of the inspector on Agent Components.

internal class AgentEditor : Editor
internal class AgentEditor : UnityEditor.Editor
{
public override void OnInspectorGUI()
{

11
com.unity.ml-agents/Editor/BehaviorParametersEditor.cs


using UnityEngine;
using MLAgents.Sensors;
using MLAgents.Policies;
namespace MLAgents
namespace MLAgents.Editor
{
/*
This code is meant to modify the behavior of the inspector on Agent Components.

internal class BehaviorParametersEditor : Editor
internal class BehaviorParametersEditor : UnityEditor.Editor
{
const float k_TimeBetweenModelReloads = 2f;
// Time since the last reload of the model

EditorGUILayout.PropertyField(so.FindProperty("m_InferenceDevice"), true);
EditorGUI.indentLevel--;
EditorGUILayout.PropertyField(so.FindProperty("m_BehaviorType"));
EditorGUILayout.PropertyField(so.FindProperty("m_TeamID"));
EditorGUILayout.PropertyField(so.FindProperty("TeamId"));
EditorGUILayout.PropertyField(so.FindProperty("m_UseChildSensors"), true);
// EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Heuristic"), true);
EditorGUI.indentLevel--;

}
if (brainParameters != null)
{
var failedChecks = InferenceBrain.BarracudaModelParamLoader.CheckModel(
var failedChecks = Inference.BarracudaModelParamLoader.CheckModel(
barracudaModel, brainParameters, sensorComponents);
foreach (var check in failedChecks)
{

3
com.unity.ml-agents/Editor/BrainParametersDrawer.cs


using UnityEngine;
using UnityEditor;
using MLAgents.Policies;
namespace MLAgents
namespace MLAgents.Editor
{
/// <summary>
/// PropertyDrawer for BrainParameters. Defines how BrainParameters are displayed in the

153
com.unity.ml-agents/Editor/DemonstrationDrawer.cs


using System.Text;
using MLAgents;
/// <summary>
/// Renders a custom UI for Demonstration Scriptable Object.
/// </summary>
[CustomEditor(typeof(Demonstration))]
[CanEditMultipleObjects]
internal class DemonstrationEditor : Editor
{
SerializedProperty m_BrainParameters;
SerializedProperty m_DemoMetaData;
using MLAgents.Demonstrations;
using MLAgents.Policies;
void OnEnable()
{
m_BrainParameters = serializedObject.FindProperty("brainParameters");
m_DemoMetaData = serializedObject.FindProperty("metaData");
}
namespace MLAgents.Editor
{
/// Renders Inspector UI for Demonstration metadata.
/// Renders a custom UI for Demonstration Scriptable Object.
void MakeMetaDataProperty(SerializedProperty property)
[CustomEditor(typeof(Demonstration))]
[CanEditMultipleObjects]
internal class DemonstrationEditor : UnityEditor.Editor
var nameProp = property.FindPropertyRelative("demonstrationName");
var expProp = property.FindPropertyRelative("numberExperiences");
var epiProp = property.FindPropertyRelative("numberEpisodes");
var rewProp = property.FindPropertyRelative("meanReward");
SerializedProperty m_BrainParameters;
SerializedProperty m_DemoMetaData;
void OnEnable()
{
m_BrainParameters = serializedObject.FindProperty("brainParameters");
m_DemoMetaData = serializedObject.FindProperty("metaData");
}
/// <summary>
/// Renders Inspector UI for Demonstration metadata.
/// </summary>
void MakeMetaDataProperty(SerializedProperty property)
{
var nameProp = property.FindPropertyRelative("demonstrationName");
var expProp = property.FindPropertyRelative("numberExperiences");
var epiProp = property.FindPropertyRelative("numberEpisodes");
var rewProp = property.FindPropertyRelative("meanReward");
var nameLabel = nameProp.displayName + ": " + nameProp.stringValue;
var expLabel = expProp.displayName + ": " + expProp.intValue;
var epiLabel = epiProp.displayName + ": " + epiProp.intValue;
var rewLabel = rewProp.displayName + ": " + rewProp.floatValue;
var nameLabel = nameProp.displayName + ": " + nameProp.stringValue;
var expLabel = expProp.displayName + ": " + expProp.intValue;
var epiLabel = epiProp.displayName + ": " + epiProp.intValue;
var rewLabel = rewProp.displayName + ": " + rewProp.floatValue;
EditorGUILayout.LabelField(nameLabel);
EditorGUILayout.LabelField(expLabel);
EditorGUILayout.LabelField(epiLabel);
EditorGUILayout.LabelField(rewLabel);
}
EditorGUILayout.LabelField(nameLabel);
EditorGUILayout.LabelField(expLabel);
EditorGUILayout.LabelField(epiLabel);
EditorGUILayout.LabelField(rewLabel);
}
/// <summary>
/// Constructs label for action size array.
/// </summary>
static string BuildActionArrayLabel(SerializedProperty actionSizeProperty)
{
var actionSize = actionSizeProperty.arraySize;
var actionLabel = new StringBuilder("[ ");
for (var i = 0; i < actionSize; i++)
/// <summary>
/// Constructs label for action size array.
/// </summary>
static string BuildActionArrayLabel(SerializedProperty actionSizeProperty)
actionLabel.Append(actionSizeProperty.GetArrayElementAtIndex(i).intValue);
if (i < actionSize - 1)
var actionSize = actionSizeProperty.arraySize;
var actionLabel = new StringBuilder("[ ");
for (var i = 0; i < actionSize; i++)
actionLabel.Append(", ");
actionLabel.Append(actionSizeProperty.GetArrayElementAtIndex(i).intValue);
if (i < actionSize - 1)
{
actionLabel.Append(", ");
}
actionLabel.Append(" ]");
return actionLabel.ToString();
actionLabel.Append(" ]");
return actionLabel.ToString();
}
/// <summary>
/// Renders Inspector UI for Brain Parameters of Demonstration.
/// </summary>
void MakeBrainParametersProperty(SerializedProperty property)
{
var vecObsSizeProp = property.FindPropertyRelative("vectorObservationSize");
var numStackedProp = property.FindPropertyRelative("numStackedVectorObservations");
var actSizeProperty = property.FindPropertyRelative("vectorActionSize");
var actSpaceTypeProp = property.FindPropertyRelative("vectorActionSpaceType");
/// <summary>
/// Renders Inspector UI for Brain Parameters of Demonstration.
/// </summary>
void MakeBrainParametersProperty(SerializedProperty property)
{
var vecObsSizeProp = property.FindPropertyRelative("vectorObservationSize");
var numStackedProp = property.FindPropertyRelative("numStackedVectorObservations");
var actSizeProperty = property.FindPropertyRelative("vectorActionSize");
var actSpaceTypeProp = property.FindPropertyRelative("vectorActionSpaceType");
var vecObsSizeLabel = vecObsSizeProp.displayName + ": " + vecObsSizeProp.intValue;
var numStackedLabel = numStackedProp.displayName + ": " + numStackedProp.intValue;
var vecActSizeLabel =
actSizeProperty.displayName + ": " + BuildActionArrayLabel(actSizeProperty);
var actSpaceTypeLabel = actSpaceTypeProp.displayName + ": " +
(SpaceType)actSpaceTypeProp.enumValueIndex;
var vecObsSizeLabel = vecObsSizeProp.displayName + ": " + vecObsSizeProp.intValue;
var numStackedLabel = numStackedProp.displayName + ": " + numStackedProp.intValue;
var vecActSizeLabel =
actSizeProperty.displayName + ": " + BuildActionArrayLabel(actSizeProperty);
var actSpaceTypeLabel = actSpaceTypeProp.displayName + ": " +
(SpaceType)actSpaceTypeProp.enumValueIndex;
EditorGUILayout.LabelField(vecObsSizeLabel);
EditorGUILayout.LabelField(numStackedLabel);
EditorGUILayout.LabelField(vecActSizeLabel);
EditorGUILayout.LabelField(actSpaceTypeLabel);
}
EditorGUILayout.LabelField(vecObsSizeLabel);
EditorGUILayout.LabelField(numStackedLabel);
EditorGUILayout.LabelField(vecActSizeLabel);
EditorGUILayout.LabelField(actSpaceTypeLabel);
}
public override void OnInspectorGUI()
{
serializedObject.Update();
EditorGUILayout.LabelField("Meta Data", EditorStyles.boldLabel);
MakeMetaDataProperty(m_DemoMetaData);
EditorGUILayout.LabelField("Brain Parameters", EditorStyles.boldLabel);
MakeBrainParametersProperty(m_BrainParameters);
serializedObject.ApplyModifiedProperties();
public override void OnInspectorGUI()
{
serializedObject.Update();
EditorGUILayout.LabelField("Meta Data", EditorStyles.boldLabel);
MakeMetaDataProperty(m_DemoMetaData);
EditorGUILayout.LabelField("Brain Parameters", EditorStyles.boldLabel);
MakeBrainParametersProperty(m_BrainParameters);
serializedObject.ApplyModifiedProperties();
}
}
}

3
com.unity.ml-agents/Editor/DemonstrationImporter.cs


using UnityEditor;
using UnityEngine;
using UnityEditor.Experimental.AssetImporters;
using MLAgents.Demonstrations;
namespace MLAgents
namespace MLAgents.Editor
{
/// <summary>
/// Asset Importer used to parse demonstration files.

6
com.unity.ml-agents/Editor/RayPerceptionSensorComponentBaseEditor.cs


using UnityEngine;
using UnityEditor;
using Barracuda;
using MLAgents.Sensors;
namespace MLAgents
namespace MLAgents.Editor
internal class RayPerceptionSensorComponentBaseEditor : Editor
internal class RayPerceptionSensorComponentBaseEditor : UnityEditor.Editor
{
bool m_RequireSensorUpdate;

982
com.unity.ml-agents/Plugins/ProtoBuffer/System.Interactive.Async.dll
文件差异内容过多而无法显示
查看文件

28
com.unity.ml-agents/Runtime/Academy.cs


#if UNITY_EDITOR
using UnityEditor;
#endif
using MLAgents.InferenceBrain;
using MLAgents.Inference;
using MLAgents.Policies;
using MLAgents.SideChannels;
using Barracuda;
/**

"docs/Learning-Environment-Design.md")]
public class Academy : IDisposable
{
const string k_ApiVersion = "API-15-dev0";
/// <summary>
/// Communication protocol version.
/// When connecting to python, this must match UnityEnvironment.API_VERSION.
/// Currently we require strict equality between the communication protocol
/// on each side, although we may allow some flexibility in the future.
/// This should be incremented whenever a change is made to the communication protocol.
/// </summary>
const string k_ApiVersion = "0.15.0";
/// <summary>
/// Unity package version of com.unity.ml-agents.
/// This must match the version string in package.json and is checked in a unit test.
/// </summary>
internal const string k_PackageVersion = "0.14.1-preview";
internal const string k_portCommandLineFlag = "--mlagents-port";
const string k_portCommandLineFlag = "--mlagents-port";
// Lazy initializer pattern, see https://csharpindepth.com/articles/singleton#lazy
static Lazy<Academy> s_Lazy = new Lazy<Academy>(() => new Academy());

var unityRlInitParameters = Communicator.Initialize(
new CommunicatorInitParameters
{
version = k_ApiVersion,
unityCommunicationVersion = k_ApiVersion,
unityPackageVersion = k_PackageVersion,
name = "AcademySingleton",
});
UnityEngine.Random.InitState(unityRlInitParameters.seed);

public void Dispose()
{
DisableAutomaticStepping();
// Signal to listeners that the academy is being destroyed now
DestroyAction?.Invoke();

{
mr.Dispose();
}
m_ModelRunners = null;
}

130
com.unity.ml-agents/Runtime/Agent.cs


using System.Collections.Generic;
using UnityEngine;
using Barracuda;
using MLAgents.Sensors;
using MLAgents.Demonstrations;
using MLAgents.Policies;
namespace MLAgents
{

/// For discrete control, specifies the actions that the agent cannot take. Is true if
/// the action is masked.
/// </summary>
public bool[] actionMasks;
public bool[] discreteActionMasks;
/// <summary>
/// Current agent reward.

/// an Agent. An agent produces observations and takes actions in the
/// environment. Observations are determined by the cameras attached
/// to the agent in addition to the vector observations implemented by the
/// user in <see cref="Agent.CollectObservations(VectorSensor)"/> or
/// <see cref="Agent.CollectObservations(VectorSensor, ActionMasker)"/>.
/// user in <see cref="Agent.CollectObservations(VectorSensor)"/>.
/// On the other hand, actions are determined by decisions produced by a Policy.
/// Currently, this class is expected to be extended to implement the desired agent behavior.
/// </summary>

"docs/Learning-Environment-Design-Agents.md")]
[Serializable]
[RequireComponent(typeof(BehaviorParameters))]
public abstract class Agent : MonoBehaviour, ISerializationCallbackReceiver
public class Agent : MonoBehaviour, ISerializationCallbackReceiver
{
IPolicy m_Brain;
BehaviorParameters m_PolicyFactory;

public int maxStep;
}
public int TeamId {
get {
LazyInitialize();
return m_PolicyFactory.TeamId;
}
}
public string BehaviorName {
get {
LazyInitialize();
return m_PolicyFactory.behaviorName;
}
}
[SerializeField][HideInInspector]
internal AgentParameters agentParameters;
[SerializeField][HideInInspector]

bool m_Initialized;
/// Keeps track of the actions that are masked at each step.
ActionMasker m_ActionMasker;
DiscreteActionMasker m_ActionMasker;
/// <summary>
/// Set of DemonstrationWriters that the Agent will write its step information to.

InitializeSensors();
}
/// <summary>
/// Reason that the Agent is being considered "done"
/// </summary>
enum DoneReason
{
/// <summary>
/// The <see cref="Done"/> method was called.
/// </summary>
DoneCalled,
/// <summary>
/// The max steps for the Agent were reached.
/// </summary>
MaxStepReached,
/// <summary>
/// The Agent was disabled
/// </summary>
Disabled,
}
void OnDisable()
{
DemonstrationWriters.Clear();

Academy.Instance.AgentAct -= AgentStep;
Academy.Instance.AgentForceReset -= _AgentReset;
}
NotifyAgentDone();
NotifyAgentDone(DoneReason.Disabled);
void NotifyAgentDone(bool maxStepReached = false)
void NotifyAgentDone(DoneReason doneReason)
m_Info.maxStepReached = maxStepReached;
m_Info.maxStepReached = doneReason == DoneReason.MaxStepReached;
// Request the last decision with no callbacks
// We request a decision so Python knows the Agent is done immediately
m_Brain?.RequestDecision(m_Info, sensors);

demoWriter.Record(m_Info, sensors);
}
UpdateRewardStats();
if (doneReason != DoneReason.Disabled)
{
// We don't want to udpate the reward stats when the Agent is disabled, because this will make
// the rewards look lower than they actually are during shutdown.
UpdateRewardStats();
}
// The Agent is done, so we give it a new episode Id
m_EpisodeId = EpisodeIdCounter.GetEpisodeId();

/// </summary>
public void Done()
{
NotifyAgentDone();
NotifyAgentDone(DoneReason.DoneCalled);
_AgentReset();
}

m_RequestAction = true;
}
/// Helper function that resets all the data structures associated with
/// the agent. Typically used when the agent is being initialized or reset
/// at the end of an episode.

m_ActionMasker = new ActionMasker(param);
m_ActionMasker = new DiscreteActionMasker(param);
// If we haven't initialized vectorActions, initialize to 0. This should only
// happen during the creation of the Agent. In subsequent episodes, vectorAction
// should stay the previous action before the Done(), so that it is properly recorded.

/// </returns>
public virtual float[] Heuristic()
{
throw new UnityAgentsException(
"The Heuristic method was not implemented for the Agent on the " +
$"{gameObject.name} GameObject.");
Debug.LogWarning("Heuristic method called but not implemented. Returning placeholder actions.");
var param = m_PolicyFactory.brainParameters;
var actionSize = param.vectorActionSpaceType == SpaceType.Continuous ?
param.vectorActionSize[0] :
param.vectorActionSize.Length;
return new float[actionSize];
}
/// <summary>

UpdateSensors();
using (TimerStack.Instance.Scoped("CollectObservations"))
{
CollectObservations(collectObservationsSensor, m_ActionMasker);
CollectObservations(collectObservationsSensor);
}
using (TimerStack.Instance.Scoped("CollectDiscreteActionMasks"))
{
if (m_PolicyFactory.brainParameters.vectorActionSpaceType == SpaceType.Discrete)
{
CollectDiscreteActionMasks(m_ActionMasker);
}
m_Info.actionMasks = m_ActionMasker.GetMask();
m_Info.discreteActionMasks = m_ActionMasker.GetMask();
m_Info.reward = m_Reward;
m_Info.done = false;

}
/// <summary>
/// Collects the vector observations of the agent alongside the masked actions.
/// The agent observation describes the current environment from the
/// perspective of the agent.
/// Collects the masks for discrete actions.
/// When using discrete actions, the agent will not perform the masked action.
/// <param name="sensor">
/// The vector observations for the agent.
/// </param>
/// The masked actions for the agent.
/// The action masker for the agent.
/// An agents observation is any environment information that helps
/// the Agent achieve its goal. For example, for a fighting Agent, its
/// observation could include distances to friends or enemies, or the
/// current level of ammunition at its disposal.
/// Recall that an Agent may attach vector or visual observations.
/// Vector observations are added by calling the provided helper methods
/// on the VectorSensor input:
/// - <see cref="VectorSensor.AddObservation(int)"/>
/// - <see cref="VectorSensor.AddObservation(float)"/>
/// - <see cref="VectorSensor.AddObservation(Vector3)"/>
/// - <see cref="VectorSensor.AddObservation(Vector2)"/>
/// - <see cref="VectorSensor.AddObservation(Quaternion)"/>
/// - <see cref="VectorSensor.AddObservation(bool)"/>
/// - <see cref="VectorSensor.AddObservation(IEnumerable{float})"/>
/// - <see cref="VectorSensor.AddOneHotObservation(int, int)"/>
/// Depending on your environment, any combination of these helpers can
/// be used. They just need to be used in the exact same order each time
/// this method is called and the resulting size of the vector observation
/// needs to match the vectorObservationSize attribute of the linked Brain.
/// Visual observations are implicitly added from the cameras attached to
/// the Agent.
/// action by masking it. You can call the following method on the ActionMasker
/// input :
/// - <see cref="ActionMasker.SetActionMask(int)"/>
/// - <see cref="ActionMasker.SetActionMask(int, int)"/>
/// - <see cref="ActionMasker.SetActionMask(int, IEnumerable{int})"/>
/// - <see cref="ActionMasker.SetActionMask(IEnumerable{int})"/>
/// The branch input is the index of the action, actionIndices are the indices of the
/// invalid options for that action.
/// action by masking it with <see cref="DiscreteActionMasker.SetMask(int, IEnumerable{int})"/>
public virtual void CollectObservations(VectorSensor sensor, ActionMasker actionMasker)
public virtual void CollectDiscreteActionMasks(DiscreteActionMasker actionMasker)
CollectObservations(sensor);
}
/// <summary>

if ((m_StepCount >= maxStep) && (maxStep > 0))
{
NotifyAgentDone(true);
NotifyAgentDone(DoneReason.MaxStepReached);
_AgentReset();
}
}

12
com.unity.ml-agents/Runtime/Communicator/GrpcExtensions.cs


using MLAgents.CommunicatorObjects;
using UnityEngine;
using System.Runtime.CompilerServices;
using MLAgents.Sensors;
using MLAgents.Demonstrations;
using MLAgents.Policies;
[assembly: InternalsVisibleTo("Unity.ML-Agents.Editor")]
[assembly: InternalsVisibleTo("Unity.ML-Agents.Editor.Tests")]

Id = ai.episodeId,
};
if (ai.actionMasks != null)
if (ai.discreteActionMasks != null)
agentInfoProto.ActionMask.AddRange(ai.actionMasks);
agentInfoProto.ActionMask.AddRange(ai.discreteActionMasks);
}
return agentInfoProto;

{
return new UnityRLInitParameters
{
seed = inputProto.Seed
seed = inputProto.Seed,
pythonLibraryVersion = inputProto.PackageVersion,
pythonCommunicationVersion = inputProto.CommunicationVersion,
};
}

23
com.unity.ml-agents/Runtime/Communicator/ICommunicator.cs


using System;
using System.Collections.Generic;
using UnityEngine;
using MLAgents.Policies;
using MLAgents.Sensors;
using MLAgents.SideChannels;
namespace MLAgents
{

/// Port to listen for connections on.
/// </summary>
public int port;
public string version;
public string unityPackageVersion;
/// <summary>
/// The version of the communication API.
/// </summary>
public string unityCommunicationVersion;
}
internal struct UnityRLInitParameters
{

public int seed;
/// <summary>
/// The library version of the python process.
/// </summary>
public string pythonLibraryVersion;
/// <summary>
/// The version of the communication API that python is using.
/// </summary>
public string pythonCommunicationVersion;
}
internal struct UnityRLInputParameters
{

34
com.unity.ml-agents/Runtime/Communicator/RpcCommunicator.cs


using System.Linq;
using UnityEngine;
using MLAgents.CommunicatorObjects;
using MLAgents.Sensors;
using MLAgents.Policies;
using MLAgents.SideChannels;
using System.IO;
using Google.Protobuf;

var academyParameters = new UnityRLInitializationOutputProto
{
Name = initParameters.name,
Version = initParameters.version
PackageVersion = initParameters.unityPackageVersion,
CommunicationVersion = initParameters.unityCommunicationVersion
};
UnityInputProto input;

RlInitializationOutput = academyParameters
},
out input);
// Initialization succeeded part-way. The most likely cause is a mismatch between the communicator
// API strings, so log an explicit warning if that's the case.
if (initializationInput != null && input == null)
{
var pythonCommunicationVersion = initializationInput.RlInitializationInput.CommunicationVersion;
var pythonPackageVersion = initializationInput.RlInitializationInput.PackageVersion;
if (pythonCommunicationVersion != initParameters.unityCommunicationVersion)
{
Debug.LogWarningFormat(
"Communication protocol between python ({0}) and Unity ({1}) don't match. " +
"Python library version: {2}.",
pythonCommunicationVersion, initParameters.unityCommunicationVersion,
pythonPackageVersion
);
}
else
{
Debug.LogWarningFormat(
"Unknown communication error between Python. Python communication protocol: {0}, " +
"Python library version: {1}.",
pythonCommunicationVersion,
pythonPackageVersion
);
}
throw new UnityAgentsException("ICommunicator.Initialize() failed.");
}
}
catch
{

3
com.unity.ml-agents/Runtime/Demonstrations/Demonstration.cs


using System;
using UnityEngine;
using MLAgents.Policies;
namespace MLAgents
namespace MLAgents.Demonstrations
{
/// <summary>
/// Demonstration Object. Contains meta-data regarding demonstration.

15
com.unity.ml-agents/Runtime/Demonstrations/DemonstrationRecorder.cs


using System.Text.RegularExpressions;
using UnityEngine;
using System.IO;
using MLAgents.Policies;
namespace MLAgents
namespace MLAgents.Demonstrations
{
/// <summary>
/// Demonstration Recorder Component.

var stream = m_FileSystem.File.Create(filePath);
m_DemoWriter = new DemonstrationWriter(stream);
m_DemoWriter.Initialize(
demonstrationName,
behaviorParams.brainParameters,
behaviorParams.fullyQualifiedBehaviorName
);
AddDemonstrationWriterToAgent(m_DemoWriter);
return m_DemoWriter;

/// <param name="demoWriter"></param>
public void AddDemonstrationWriterToAgent(DemonstrationWriter demoWriter)
{
var behaviorParams = GetComponent<BehaviorParameters>();
demoWriter.Initialize(
demonstrationName,
behaviorParams.brainParameters,
behaviorParams.fullyQualifiedBehaviorName
);
m_Agent.DemonstrationWriters.Add(demoWriter);
}

6
com.unity.ml-agents/Runtime/Demonstrations/DemonstrationWriter.cs


using System.IO;
using Google.Protobuf;
using System.Collections.Generic;
using MLAgents.Sensors;
using MLAgents.Policies;
namespace MLAgents
namespace MLAgents.Demonstrations
{
/// <summary>
/// Responsible for writing demonstration data to stream (typically a file stream).

/// <param name="demonstrationName">Base name of the demonstration file(s).</param>
/// <param name="brainName">The name of the Brain the agent is attached to.</param>
/// <param name="brainParameters">The parameters of the Brain the agent is attached to.</param>
public void Initialize(
internal void Initialize(
string demonstrationName, BrainParameters brainParameters, string brainName)
{
if (m_Writer == null)

74
com.unity.ml-agents/Runtime/Grpc/CommunicatorObjects/UnityRlInitializationInput.cs


string.Concat(
"CkZtbGFnZW50c19lbnZzL2NvbW11bmljYXRvcl9vYmplY3RzL3VuaXR5X3Js",
"X2luaXRpYWxpemF0aW9uX2lucHV0LnByb3RvEhRjb21tdW5pY2F0b3Jfb2Jq",
"ZWN0cyIvCh9Vbml0eVJMSW5pdGlhbGl6YXRpb25JbnB1dFByb3RvEgwKBHNl",
"ZWQYASABKAVCH6oCHE1MQWdlbnRzLkNvbW11bmljYXRvck9iamVjdHNiBnBy",
"b3RvMw=="));
"ZWN0cyJnCh9Vbml0eVJMSW5pdGlhbGl6YXRpb25JbnB1dFByb3RvEgwKBHNl",
"ZWQYASABKAUSHQoVY29tbXVuaWNhdGlvbl92ZXJzaW9uGAIgASgJEhcKD3Bh",
"Y2thZ2VfdmVyc2lvbhgDIAEoCUIfqgIcTUxBZ2VudHMuQ29tbXVuaWNhdG9y",
"T2JqZWN0c2IGcHJvdG8z"));
new pbr::GeneratedClrTypeInfo(typeof(global::MLAgents.CommunicatorObjects.UnityRLInitializationInputProto), global::MLAgents.CommunicatorObjects.UnityRLInitializationInputProto.Parser, new[]{ "Seed" }, null, null, null)
new pbr::GeneratedClrTypeInfo(typeof(global::MLAgents.CommunicatorObjects.UnityRLInitializationInputProto), global::MLAgents.CommunicatorObjects.UnityRLInitializationInputProto.Parser, new[]{ "Seed", "CommunicationVersion", "PackageVersion" }, null, null, null)
}));
}
#endregion

/// <summary>
/// The initializaiton message - this is typically sent from the Python trainer to the C# environment.
/// </summary>
internal sealed partial class UnityRLInitializationInputProto : pb::IMessage<UnityRLInitializationInputProto> {
private static readonly pb::MessageParser<UnityRLInitializationInputProto> _parser = new pb::MessageParser<UnityRLInitializationInputProto>(() => new UnityRLInitializationInputProto());
private pb::UnknownFieldSet _unknownFields;

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public UnityRLInitializationInputProto(UnityRLInitializationInputProto other) : this() {
seed_ = other.seed_;
communicationVersion_ = other.communicationVersion_;
packageVersion_ = other.packageVersion_;
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
}

}
}
/// <summary>Field number for the "communication_version" field.</summary>
public const int CommunicationVersionFieldNumber = 2;
private string communicationVersion_ = "";
/// <summary>
/// Communication protocol version that the initiating side (typically the Python trainer) is using.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string CommunicationVersion {
get { return communicationVersion_; }
set {
communicationVersion_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
}
}
/// <summary>Field number for the "package_version" field.</summary>
public const int PackageVersionFieldNumber = 3;
private string packageVersion_ = "";
/// <summary>
/// Package/library version that the initiating side (typically the Python trainer) is using.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string PackageVersion {
get { return packageVersion_; }
set {
packageVersion_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
}
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override bool Equals(object other) {
return Equals(other as UnityRLInitializationInputProto);

return true;
}
if (Seed != other.Seed) return false;
if (CommunicationVersion != other.CommunicationVersion) return false;
if (PackageVersion != other.PackageVersion) return false;
return Equals(_unknownFields, other._unknownFields);
}

if (Seed != 0) hash ^= Seed.GetHashCode();
if (CommunicationVersion.Length != 0) hash ^= CommunicationVersion.GetHashCode();
if (PackageVersion.Length != 0) hash ^= PackageVersion.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}

output.WriteRawTag(8);
output.WriteInt32(Seed);
}
if (CommunicationVersion.Length != 0) {
output.WriteRawTag(18);
output.WriteString(CommunicationVersion);
}
if (PackageVersion.Length != 0) {
output.WriteRawTag(26);
output.WriteString(PackageVersion);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}

if (Seed != 0) {
size += 1 + pb::CodedOutputStream.ComputeInt32Size(Seed);
}
if (CommunicationVersion.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(CommunicationVersion);
}
if (PackageVersion.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(PackageVersion);
}
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}

if (other.Seed != 0) {
Seed = other.Seed;
}
if (other.CommunicationVersion.Length != 0) {
CommunicationVersion = other.CommunicationVersion;
}
if (other.PackageVersion.Length != 0) {
PackageVersion = other.PackageVersion;
}
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
}

break;
case 8: {
Seed = input.ReadInt32();
break;
}
case 18: {
CommunicationVersion = input.ReadString();
break;
}
case 26: {
PackageVersion = input.ReadString();
break;
}
}

79
com.unity.ml-agents/Runtime/Grpc/CommunicatorObjects/UnityRlInitializationOutput.cs


"CkdtbGFnZW50c19lbnZzL2NvbW11bmljYXRvcl9vYmplY3RzL3VuaXR5X3Js",
"X2luaXRpYWxpemF0aW9uX291dHB1dC5wcm90bxIUY29tbXVuaWNhdG9yX29i",
"amVjdHMaOW1sYWdlbnRzX2VudnMvY29tbXVuaWNhdG9yX29iamVjdHMvYnJh",
"aW5fcGFyYW1ldGVycy5wcm90byKfAQogVW5pdHlSTEluaXRpYWxpemF0aW9u",
"T3V0cHV0UHJvdG8SDAoEbmFtZRgBIAEoCRIPCgd2ZXJzaW9uGAIgASgJEhAK",
"CGxvZ19wYXRoGAMgASgJEkQKEGJyYWluX3BhcmFtZXRlcnMYBSADKAsyKi5j",
"b21tdW5pY2F0b3Jfb2JqZWN0cy5CcmFpblBhcmFtZXRlcnNQcm90b0oECAYQ",
"B0IfqgIcTUxBZ2VudHMuQ29tbXVuaWNhdG9yT2JqZWN0c2IGcHJvdG8z"));
"aW5fcGFyYW1ldGVycy5wcm90byLGAQogVW5pdHlSTEluaXRpYWxpemF0aW9u",
"T3V0cHV0UHJvdG8SDAoEbmFtZRgBIAEoCRIdChVjb21tdW5pY2F0aW9uX3Zl",
"cnNpb24YAiABKAkSEAoIbG9nX3BhdGgYAyABKAkSRAoQYnJhaW5fcGFyYW1l",
"dGVycxgFIAMoCzIqLmNvbW11bmljYXRvcl9vYmplY3RzLkJyYWluUGFyYW1l",
"dGVyc1Byb3RvEhcKD3BhY2thZ2VfdmVyc2lvbhgHIAEoCUoECAYQB0IfqgIc",
"TUxBZ2VudHMuQ29tbXVuaWNhdG9yT2JqZWN0c2IGcHJvdG8z"));
new pbr::GeneratedClrTypeInfo(typeof(global::MLAgents.CommunicatorObjects.UnityRLInitializationOutputProto), global::MLAgents.CommunicatorObjects.UnityRLInitializationOutputProto.Parser, new[]{ "Name", "Version", "LogPath", "BrainParameters" }, null, null, null)
new pbr::GeneratedClrTypeInfo(typeof(global::MLAgents.CommunicatorObjects.UnityRLInitializationOutputProto), global::MLAgents.CommunicatorObjects.UnityRLInitializationOutputProto.Parser, new[]{ "Name", "CommunicationVersion", "LogPath", "BrainParameters", "PackageVersion" }, null, null, null)
}));
}
#endregion

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public UnityRLInitializationOutputProto(UnityRLInitializationOutputProto other) : this() {
name_ = other.name_;
version_ = other.version_;
communicationVersion_ = other.communicationVersion_;
packageVersion_ = other.packageVersion_;
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
}

}
}
/// <summary>Field number for the "version" field.</summary>
public const int VersionFieldNumber = 2;
private string version_ = "";
/// <summary>Field number for the "communication_version" field.</summary>
public const int CommunicationVersionFieldNumber = 2;
private string communicationVersion_ = "";
/// <summary>
/// Communication protocol version that the responding side (typically the C# environment) is using.
/// </summary>
public string Version {
get { return version_; }
public string CommunicationVersion {
get { return communicationVersion_; }
version_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
communicationVersion_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
}
}

get { return brainParameters_; }
}
/// <summary>Field number for the "package_version" field.</summary>
public const int PackageVersionFieldNumber = 7;
private string packageVersion_ = "";
/// <summary>
/// Package/library version that the responding side (typically the C# environment) is using.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string PackageVersion {
get { return packageVersion_; }
set {
packageVersion_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
}
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override bool Equals(object other) {
return Equals(other as UnityRLInitializationOutputProto);

return true;
}
if (Name != other.Name) return false;
if (Version != other.Version) return false;
if (CommunicationVersion != other.CommunicationVersion) return false;
if (PackageVersion != other.PackageVersion) return false;
return Equals(_unknownFields, other._unknownFields);
}

if (Name.Length != 0) hash ^= Name.GetHashCode();
if (Version.Length != 0) hash ^= Version.GetHashCode();
if (CommunicationVersion.Length != 0) hash ^= CommunicationVersion.GetHashCode();
if (PackageVersion.Length != 0) hash ^= PackageVersion.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}

output.WriteRawTag(10);
output.WriteString(Name);
}
if (Version.Length != 0) {
if (CommunicationVersion.Length != 0) {
output.WriteString(Version);
output.WriteString(CommunicationVersion);
}
if (LogPath.Length != 0) {
output.WriteRawTag(26);

if (PackageVersion.Length != 0) {
output.WriteRawTag(58);
output.WriteString(PackageVersion);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}

if (Name.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(Name);
}
if (Version.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(Version);
if (CommunicationVersion.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(CommunicationVersion);
if (PackageVersion.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(PackageVersion);
}
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}

if (other.Name.Length != 0) {
Name = other.Name;
}
if (other.Version.Length != 0) {
Version = other.Version;
if (other.CommunicationVersion.Length != 0) {
CommunicationVersion = other.CommunicationVersion;
if (other.PackageVersion.Length != 0) {
PackageVersion = other.PackageVersion;
}
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
}

break;
}
case 18: {
Version = input.ReadString();
CommunicationVersion = input.ReadString();
break;
}
case 26: {

case 42: {
brainParameters_.AddEntriesFrom(input, _repeated_brainParameters_codec);
break;
}
case 58: {
PackageVersion = input.ReadString();
break;
}
}

34
com.unity.ml-agents/Runtime/Timer.cs


/// <summary>
/// Stop timing a block of code, and increment internal counts.
/// </summary>
public void End(bool isRecording)
public void End()
if (isRecording)
{
var elapsed = DateTime.Now.Ticks - m_TickStart;
m_TotalTicks += elapsed;
m_TickStart = 0;
m_NumCalls++;
}
// Note that samplers are always updated regardless of recording state, to ensure matching start and ends.
var elapsed = DateTime.Now.Ticks - m_TickStart;
m_TotalTicks += elapsed;
m_TickStart = 0;
m_NumCalls++;
m_Sampler?.End();
}

/// This implements the Singleton pattern (solution 4) as described in
/// https://csharpindepth.com/articles/singleton
/// </remarks>
public class TimerStack : IDisposable
internal class TimerStack : IDisposable
// Whether or not new timers and gauges can be added.
bool m_Recording = true;
// Explicit static constructor to tell C# compiler
// not to mark type as beforefieldinit

}
/// <summary>
/// Whether or not new timers and gauges can be added.
/// </summary>
public bool Recording
{
get { return m_Recording; }
set { m_Recording = value; }
}
/// <summary>
/// Updates the referenced gauge in the root node with the provided value.
/// </summary>
/// <param name="name">The name of the Gauge to modify.</param>

if (!Recording)
{
return;
}
if (!float.IsNaN(value))
{
GaugeNode gauge;

void Pop()
{
var node = m_Stack.Pop();
node.End(Recording);
node.End();
}
/// <summary>

1
com.unity.ml-agents/Runtime/Utilities.cs


using System;
using UnityEngine;
using MLAgents.Sensors;
namespace MLAgents
{

2
com.unity.ml-agents/Runtime/SideChannels/SideChannel.cs


using System.Collections.Generic;
using System;
namespace MLAgents
namespace MLAgents.SideChannels
{
/// <summary>
/// Side channels provide an alternative mechanism of sending/receiving data from Unity

2
com.unity.ml-agents/Runtime/SideChannels/RawBytesChannel.cs


using System.Collections.Generic;
using System;
namespace MLAgents
namespace MLAgents.SideChannels
{
/// <summary>
/// Side channel for managing raw bytes of data. It is up to the clients of this side channel

2
com.unity.ml-agents/Runtime/SideChannels/FloatPropertiesChannel.cs


using System;
using System.Text;
namespace MLAgents
namespace MLAgents.SideChannels
{
/// <summary>
/// Interface for managing a collection of float properties keyed by a string variable.

2
com.unity.ml-agents/Runtime/SideChannels/EngineConfigurationChannel.cs


using System;
using UnityEngine;
namespace MLAgents
namespace MLAgents.SideChannels
{
/// <summary>
/// Side channel that supports modifying attributes specific to the Unity Engine.

4
com.unity.ml-agents/Runtime/Sensors/WriteAdapter.cs


using System;
using System.Collections.Generic;
using Barracuda;
using MLAgents.InferenceBrain;
using MLAgents.Inference;
namespace MLAgents
namespace MLAgents.Sensors
{
/// <summary>
/// Allows sensors to write to both TensorProxy and float arrays/lists.

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


using System.Collections.Generic;
using UnityEngine;
namespace MLAgents
namespace MLAgents.Sensors
{
/// <summary>
/// A sensor implementation for vector observations.

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


namespace MLAgents
namespace MLAgents.Sensors
{
/// <summary>
/// Sensor that wraps around another Sensor to provide temporal stacking.

6
com.unity.ml-agents/Runtime/Sensors/SensorShapeValidator.cs


using System.Collections.Generic;
using UnityEngine;
namespace MLAgents
namespace MLAgents.Sensors
{
internal class SensorShapeValidator
{

// Check for compatibility with the other Agents' Sensors
// TODO make sure this only checks once per agent
Debug.Assert(m_SensorShapes.Count == sensors.Count, $"Number of Sensors must match. {m_SensorShapes.Count} != {sensors.Count}");
for (var i = 0; i < m_SensorShapes.Count; i++)
for (var i = 0; i < Mathf.Min(m_SensorShapes.Count, sensors.Count); i++)
for (var j = 0; j < cachedShape.Length; j++)
for (var j = 0; j < Mathf.Min(cachedShape.Length, sensorShape.Length); j++)
{
Debug.Assert(cachedShape[j] == sensorShape[j], "Sensor sizes much match.");
}

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


using UnityEngine;
namespace MLAgents
namespace MLAgents.Sensors
{
/// <summary>
/// Editor components for creating Sensors. Generally an ISensor implementation should have a

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


namespace MLAgents
namespace MLAgents.Sensors
{
/// <summary>
/// A base sensor that provides a number default implementations.

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


using UnityEngine;
namespace MLAgents
namespace MLAgents.Sensors
{
/// <summary>
/// Component that wraps a <see cref="RenderTextureSensor"/>.

6
com.unity.ml-agents/Runtime/Sensors/RenderTextureSensor.cs


using UnityEngine;
namespace MLAgents
namespace MLAgents.Sensors
{
/// <summary>
/// Sensor class that wraps a <see cref="RenderTexture"/> instance.

/// <inheritdoc/>
public byte[] GetCompressedObservation()
{
using (TimerStack.Instance.Scoped("RenderTexSensor.GetCompressedObservation"))
using (TimerStack.Instance.Scoped("RenderTextureSensor.GetCompressedObservation"))
{
var texture = ObservationToTexture(m_RenderTexture);
// TODO support more types here, e.g. JPG

/// <inheritdoc/>
public int Write(WriteAdapter adapter)
{
using (TimerStack.Instance.Scoped("RenderTexSensor.GetCompressedObservation"))
using (TimerStack.Instance.Scoped("RenderTextureSensor.Write"))
{
var texture = ObservationToTexture(m_RenderTexture);
var numWritten = Utilities.TextureToTensorProxy(texture, adapter, m_Grayscale);

4
com.unity.ml-agents/Runtime/Sensors/RayPerceptionSensorComponentBase.cs


using UnityEngine;
using UnityEngine.Serialization;
namespace MLAgents
namespace MLAgents.Sensors
{
/// <summary>
/// A base class to support sensor components for raycast-based sensors.

/// Greater than 90 degrees will go backwards.
/// </param>
/// <returns></returns>
public static float[] GetRayAngles(int raysPerDirection, float maxRayDegrees)
internal static float[] GetRayAngles(int raysPerDirection, float maxRayDegrees)
{
// Example:
// { 90, 90 - delta, 90 + delta, 90 - 2*delta, 90 + 2*delta }

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


using UnityEngine;
using UnityEngine.Serialization;
namespace MLAgents
namespace MLAgents.Sensors
{
/// <summary>
/// A component for 3D Ray Perception.

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


using UnityEngine;
namespace MLAgents
namespace MLAgents.Sensors
{
/// <summary>
/// A component for 2D Ray Perception.

4
com.unity.ml-agents/Runtime/Sensors/RayPerceptionSensor.cs


using System.Collections.Generic;
using UnityEngine;
namespace MLAgents
namespace MLAgents.Sensors
{
/// <summary>
/// Determines which dimensions the sensor will perform the casts in.

/// </summary>
/// <param name="input">Input defining the rays that will be cast.</param>
/// <returns>Output struct containing the raycast results.</returns>
public static RayPerceptionOutput PerceiveStatic(RayPerceptionInput input)
public static RayPerceptionOutput Perceive(RayPerceptionInput input)
{
RayPerceptionOutput output = new RayPerceptionOutput();
output.rayOutputs = new RayPerceptionOutput.RayOutput[input.angles.Count];

3
com.unity.ml-agents/Runtime/Sensors/Observation.cs


using System;
using UnityEngine;
namespace MLAgents
namespace MLAgents.Sensors
{
internal struct Observation
{

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


namespace MLAgents
namespace MLAgents.Sensors
{
/// <summary>
/// The compression setting for visual/camera observations.

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


using UnityEngine;
namespace MLAgents
namespace MLAgents.Sensors
{
/// <summary>
/// A SensorComponent that creates a <see cref="CameraSensor"/>.

20
com.unity.ml-agents/Runtime/Sensors/CameraSensor.cs


using UnityEngine;
namespace MLAgents
namespace MLAgents.Sensors
{
/// <summary>
/// A sensor that wraps a Camera object to generate visual observations for an agent.

var texture = ObservationToTexture(m_Camera, m_Width, m_Height);
// TODO support more types here, e.g. JPG
var compressed = texture.EncodeToPNG();
UnityEngine.Object.Destroy(texture);
DestroyTexture(texture);
return compressed;
}
}

{
var texture = ObservationToTexture(m_Camera, m_Width, m_Height);
var numWritten = Utilities.TextureToTensorProxy(texture, adapter, m_Grayscale);
UnityEngine.Object.Destroy(texture);
DestroyTexture(texture);
return numWritten;
}
}

internal static int[] GenerateShape(int width, int height, bool grayscale)
{
return new[] { height, width, grayscale ? 1 : 3 };
}
static void DestroyTexture(Texture2D texture)
{
if (Application.isEditor)
{
// Edit Mode tests complain if we use Destroy()
// TODO move to extension methods for UnityEngine.Object?
UnityEngine.Object.DestroyImmediate(texture);
}
else
{
UnityEngine.Object.Destroy(texture);
}
}
}
}

3
com.unity.ml-agents/Runtime/Policies/RemotePolicy.cs


using UnityEngine;
using System.Collections.Generic;
using System;
using MLAgents.Sensors;
namespace MLAgents
namespace MLAgents.Policies
{
/// <summary>
/// The Remote Policy only works when training.

3
com.unity.ml-agents/Runtime/Policies/IPolicy.cs


using System;
using System.Collections.Generic;
using MLAgents.Sensors;
namespace MLAgents
namespace MLAgents.Policies
{
/// <summary>
/// IPolicy is connected to a single Agent. Each time the agent needs

92
com.unity.ml-agents/Runtime/Policies/HeuristicPolicy.cs


using System.Collections.Generic;
using System;
using System.Collections;
using MLAgents.Sensors;
namespace MLAgents
namespace MLAgents.Policies
{
/// <summary>
/// The Heuristic Policy uses a hards coded Heuristic method

Func<float[]> m_Heuristic;
float[] m_LastDecision;
WriteAdapter m_WriteAdapter = new WriteAdapter();
NullList m_NullList = new NullList();
/// <inheritdoc />
public HeuristicPolicy(Func<float[]> heuristic)
{

/// <inheritdoc />
public void RequestDecision(AgentInfo info, List<ISensor> sensors)
{
StepSensors(sensors);
m_LastDecision = m_Heuristic.Invoke();
}

public void Dispose()
{
}
/// <summary>
/// Trivial implementation of the IList interface that does nothing.
/// This is only used for "writing" observations that we will discard.
/// </summary>
class NullList : IList<float>
{
public IEnumerator<float> GetEnumerator()
{
throw new NotImplementedException();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public void Add(float item)
{
}
public void Clear()
{
}
public bool Contains(float item)
{
return false;
}
public void CopyTo(float[] array, int arrayIndex)
{
throw new NotImplementedException();
}
public bool Remove(float item)
{
return false;
}
public int Count { get; }
public bool IsReadOnly { get; }
public int IndexOf(float item)
{
return -1;
}
public void Insert(int index, float item)
{
}
public void RemoveAt(int index)
{
}
public float this[int index]
{
get { return 0.0f; }
set { }
}
}
/// <summary>
/// Run ISensor.Write or ISensor.GetCompressedObservation for each sensor
/// The output is currently unused, but this makes the sensor usage consistent
/// between training and inference.
/// </summary>
/// <param name="sensors"></param>
void StepSensors(List<ISensor> sensors)
{
foreach (var sensor in sensors)
{
if (sensor.GetCompressionType() == SensorCompressionType.None)
{
m_WriteAdapter.SetTarget(m_NullList, sensor.GetObservationShape(), 0);
sensor.Write(m_WriteAdapter);
}
else
{
sensor.GetCompressedObservation();
}
}
}
}
}

6
com.unity.ml-agents/Runtime/Policies/BrainParameters.cs


using System;
using UnityEngine;
namespace MLAgents
namespace MLAgents.Policies
public enum SpaceType
internal enum SpaceType
{
/// <summary>
/// Discrete action space: a fixed number of options are available.

/// decision process.
/// </summary>
[Serializable]
public class BrainParameters
internal class BrainParameters
{
/// <summary>
/// If continuous : The length of the float vector that represents the state.

21
com.unity.ml-agents/Runtime/Policies/BehaviorParameters.cs


using UnityEngine;
using UnityEngine.Serialization;
namespace MLAgents
namespace MLAgents.Policies
public class BehaviorParameters : MonoBehaviour
internal class BehaviorParameters : MonoBehaviour
{
[Serializable]
enum BehaviorType

InferenceDevice m_InferenceDevice;
[HideInInspector]
[SerializeField]
// Disable warning /com.unity.ml-agents/Runtime/Policy/BehaviorParameters.cs(...):
// warning CS0649: Field 'BehaviorParameters.m_BehaviorType' is never assigned to,
// and will always have its default value
// This field is set in the custom editor.
#pragma warning disable 0649
#pragma warning restore 0649
[HideInInspector]
[SerializeField]
string m_BehaviorName = "My Behavior";

/// </summary>
[HideInInspector]
[SerializeField]
public int m_TeamID;
[FormerlySerializedAs("m_TeamID")]
public int TeamId;
[FormerlySerializedAs("m_useChildSensors")]
[HideInInspector]
[SerializeField]

/// <summary>
/// The associated <see cref="BrainParameters"/> for this behavior.
/// </summary>
public BrainParameters brainParameters
internal BrainParameters brainParameters
{
get { return m_BrainParameters; }
}

/// </summary>
public string fullyQualifiedBehaviorName
{
get { return m_BehaviorName + "?team=" + m_TeamID; }
get { return m_BehaviorName + "?team=" + TeamId; }
internal IPolicy GeneratePolicy(Func<float[]> heuristic)
public IPolicy GeneratePolicy(Func<float[]> heuristic)
{
switch (m_BehaviorType)
{

7
com.unity.ml-agents/Runtime/Policies/BarracudaPolicy.cs


using UnityEngine;
using MLAgents.InferenceBrain;
using System;
using MLAgents.Inference;
using MLAgents.Sensors;
namespace MLAgents
namespace MLAgents.Policies
{
/// <summary>
/// Where to perform inference.

2
com.unity.ml-agents/Runtime/Inference/Utils/RandomNormal.cs


using System;
namespace MLAgents.InferenceBrain.Utils
namespace MLAgents.Inference.Utils
{
/// <summary>
/// RandomNormal - A random number generator that produces normally distributed random

2
com.unity.ml-agents/Runtime/Inference/Utils/Multinomial.cs


namespace MLAgents.InferenceBrain.Utils
namespace MLAgents.Inference.Utils
{
/// <summary>
/// Multinomial - Draws samples from a multinomial distribution given a (potentially unscaled)

4
com.unity.ml-agents/Runtime/Inference/TensorProxy.cs


using System;
using System.Collections.Generic;
using Barracuda;
using MLAgents.InferenceBrain.Utils;
using MLAgents.Inference.Utils;
namespace MLAgents.InferenceBrain
namespace MLAgents.Inference
{
/// <summary>
/// Tensor - A class to encapsulate a Tensor used for inference.

4
com.unity.ml-agents/Runtime/Inference/TensorNames.cs


namespace MLAgents.InferenceBrain
namespace MLAgents.Inference
{
/// <summary>
/// Contains the names of the input and output tensors for the Inference Brain.

public const string BatchSizePlaceholder = "batch_size";
public const string SequenceLengthPlaceholder = "sequence_length";
public const string VectorObservationPlacholder = "vector_observation";
public const string VectorObservationPlaceholder = "vector_observation";
public const string RecurrentInPlaceholder = "recurrent_in";
public const string recurrentInPlaceholderH = "recurrent_in_h";
public const string recurrentInPlaceholderC = "recurrent_in_c";

5
com.unity.ml-agents/Runtime/Inference/TensorGenerator.cs


using System.Collections.Generic;
using Barracuda;
using MLAgents.Sensors;
namespace MLAgents.InferenceBrain
namespace MLAgents.Inference
{
/// <summary>
/// Mapping between Tensor names and generators.

if (vecObsGen != null)
{
m_Dict[TensorNames.VectorObservationPlacholder] = vecObsGen;
m_Dict[TensorNames.VectorObservationPlaceholder] = vecObsGen;
}
}

4
com.unity.ml-agents/Runtime/Inference/TensorApplier.cs


using System.Collections.Generic;
using Barracuda;
using System;
using MLAgents.Policies;
namespace MLAgents.InferenceBrain
namespace MLAgents.Inference
{
/// <summary>
/// Mapping between the output tensor names and the method that will use the

5
com.unity.ml-agents/Runtime/Inference/ModelRunner.cs


using System.Collections.Generic;
using Barracuda;
using UnityEngine.Profiling;
using System;
using MLAgents.Sensors;
using MLAgents.Policies;
namespace MLAgents.InferenceBrain
namespace MLAgents.Inference
{
internal struct AgentInfoSensorsPair
{

7
com.unity.ml-agents/Runtime/Inference/GeneratorImpl.cs


using System.Collections.Generic;
using System;
using Barracuda;
using MLAgents.InferenceBrain.Utils;
using MLAgents.Inference.Utils;
using MLAgents.Sensors;
namespace MLAgents.InferenceBrain
namespace MLAgents.Inference
{
/// <summary>
/// Reshapes a Tensor so that its first dimension becomes equal to the current batch size

foreach (var infoSensorPair in infos)
{
var agentInfo = infoSensorPair.agentInfo;
var maskList = agentInfo.actionMasks;
var maskList = agentInfo.discreteActionMasks;
for (var j = 0; j < maskSize; j++)
{
var isUnmasked = (maskList != null && maskList[j]) ? 0.0f : 1.0f;

9
com.unity.ml-agents/Runtime/Inference/BarracudaModelParamLoader.cs


using System.Collections.Generic;
using System.Linq;
using Barracuda;
using UnityEngine;
using MLAgents.Sensors;
using MLAgents.Policies;
namespace MLAgents.InferenceBrain
namespace MLAgents.Inference
{
/// <summary>
/// Prepares the Tensors for the Learning Brain and exposes a list of failed checks if Model

// If there is no Vector Observation Input but the Brain Parameters expect one.
if ((brainParameters.vectorObservationSize != 0) &&
(!tensorsNames.Contains(TensorNames.VectorObservationPlacholder)))
(!tensorsNames.Contains(TensorNames.VectorObservationPlaceholder)))
{
failedModelChecks.Add(
"The model does not contain a Vector Observation Placeholder Input. " +

var tensorTester =
new Dictionary<string, Func<BrainParameters, TensorProxy, SensorComponent[], string>>()
{
{TensorNames.VectorObservationPlacholder, CheckVectorObsShape},
{TensorNames.VectorObservationPlaceholder, CheckVectorObsShape},
{TensorNames.PreviousActionPlaceholder, CheckPreviousActionShape},
{TensorNames.RandomNormalEpsilonPlaceholder, ((bp, tensor, scs) => null)},
{TensorNames.ActionMaskPlaceholder, ((bp, tensor, scs) => null)},

4
com.unity.ml-agents/Runtime/Inference/ApplierImpl.cs


using System.Collections.Generic;
using System.Linq;
using Barracuda;
using MLAgents.InferenceBrain.Utils;
using MLAgents.Inference.Utils;
namespace MLAgents.InferenceBrain
namespace MLAgents.Inference
{
/// <summary>
/// The Applier for the Continuous Action output tensor. Tensor is assumed to contain the

5
com.unity.ml-agents/Tests/Editor/DemonstrationTests.cs


using System.IO.Abstractions.TestingHelpers;
using System.Reflection;
using MLAgents.CommunicatorObjects;
using MLAgents.Sensors;
using MLAgents.Demonstrations;
using MLAgents.Policies;
namespace MLAgents.Tests
{

var agentInfo = new AgentInfo
{
reward = 1f,
actionMasks = new[] { false, true },
discreteActionMasks = new[] { false, true },
done = true,
episodeId = 5,
maxStepReached = true,

4
com.unity.ml-agents/Tests/Editor/DiscreteActionOutputApplierTest.cs


using Barracuda;
using NUnit.Framework;
using UnityEngine;
using MLAgents.InferenceBrain;
using MLAgents.InferenceBrain.Utils;
using MLAgents.Inference;
using MLAgents.Inference.Utils;
namespace MLAgents.Tests
{

41
com.unity.ml-agents/Tests/Editor/EditModeTestActionMasker.cs


using NUnit.Framework;
using MLAgents.Policies;
namespace MLAgents.Tests
{

public void Contruction()
{
var bp = new BrainParameters();
var masker = new ActionMasker(bp);
var masker = new DiscreteActionMasker(bp);
Assert.IsNotNull(masker);
}

var bp = new BrainParameters();
bp.vectorActionSpaceType = SpaceType.Continuous;
bp.vectorActionSize = new[] {4};
var masker = new ActionMasker(bp);
masker.SetActionMask(0, new[] {0});
var masker = new DiscreteActionMasker(bp);
masker.SetMask(0, new[] {0});
Assert.Catch<UnityAgentsException>(() => masker.GetMask());
}

var bp = new BrainParameters();
bp.vectorActionSpaceType = SpaceType.Discrete;
var masker = new ActionMasker(bp);
var masker = new DiscreteActionMasker(bp);
var mask = masker.GetMask();
Assert.IsNull(mask);
}

var bp = new BrainParameters();
bp.vectorActionSpaceType = SpaceType.Discrete;
bp.vectorActionSize = new[] {4, 5, 6};
var masker = new ActionMasker(bp);
var masker = new DiscreteActionMasker(bp);
masker.SetActionMask(0, new[] {1, 2, 3});
masker.SetMask(0, new[] {1, 2, 3});
mask = masker.GetMask();
Assert.IsFalse(mask[0]);
Assert.IsTrue(mask[1]);

vectorActionSpaceType = SpaceType.Discrete,
vectorActionSize = new[] { 4, 5, 6 }
};
var masker = new ActionMasker(bp);
masker.SetActionMask(1, new[] {1, 2, 3});
var masker = new DiscreteActionMasker(bp);
masker.SetMask(1, new[] {1, 2, 3});
var mask = masker.GetMask();
Assert.IsFalse(mask[0]);
Assert.IsFalse(mask[4]);

vectorActionSpaceType = SpaceType.Discrete,
vectorActionSize = new[] { 4, 5, 6 }
};
var masker = new ActionMasker(bp);
masker.SetActionMask(1, new[] {1, 2, 3});
var masker = new DiscreteActionMasker(bp);
masker.SetMask(1, new[] {1, 2, 3});
masker.ResetMask();
var mask = masker.GetMask();
for (var i = 0; i < 15; i++)

vectorActionSpaceType = SpaceType.Discrete,
vectorActionSize = new[] { 4, 5, 6 }
};
var masker = new ActionMasker(bp);
var masker = new DiscreteActionMasker(bp);
() => masker.SetActionMask(0, new[] {5}));
() => masker.SetMask(0, new[] {5}));
() => masker.SetActionMask(1, new[] {5}));
masker.SetActionMask(2, new[] {5});
() => masker.SetMask(1, new[] {5}));
masker.SetMask(2, new[] {5});
() => masker.SetActionMask(3, new[] {1}));
() => masker.SetMask(3, new[] {1}));
masker.SetActionMask(0, new[] {0, 1, 2, 3});
masker.SetMask(0, new[] {0, 1, 2, 3});
Assert.Catch<UnityAgentsException>(
() => masker.GetMask());
}

var bp = new BrainParameters();
bp.vectorActionSpaceType = SpaceType.Discrete;
bp.vectorActionSize = new[] {4, 5, 6};
var masker = new ActionMasker(bp);
masker.SetActionMask(0, new[] {0, 1});
masker.SetActionMask(0, new[] {3});
masker.SetActionMask(2, new[] {1});
var masker = new DiscreteActionMasker(bp);
masker.SetMask(0, new[] {0, 1});
masker.SetMask(0, new[] {3});
masker.SetMask(2, new[] {1});
var mask = masker.GetMask();
for (var i = 0; i < 15; i++)
{

5
com.unity.ml-agents/Tests/Editor/EditModeTestInternalBrainTensorApplier.cs


using System.Collections.Generic;
using NUnit.Framework;
using UnityEngine;
using MLAgents.InferenceBrain;
using System;
using MLAgents.Inference;
using MLAgents.Policies;
namespace MLAgents.Tests
{

8
com.unity.ml-agents/Tests/Editor/EditModeTestInternalBrainTensorGenerator.cs


using Barracuda;
using NUnit.Framework;
using UnityEngine;
using MLAgents.InferenceBrain;
using MLAgents.Inference;
using MLAgents.Policies;
namespace MLAgents.Tests
{

var infoA = new AgentInfo
{
storedVectorActions = new[] { 1f, 2f },
actionMasks = null
discreteActionMasks = null
actionMasks = new[] { true, false, false, false, false },
discreteActionMasks = new[] { true, false, false, false, false },
};

58
com.unity.ml-agents/Tests/Editor/MLAgentsEditModeTest.cs


using NUnit.Framework;
using System.Reflection;
using System.Collections.Generic;
using MLAgents.Sensors;
using MLAgents.Policies;
namespace MLAgents.Tests
{

typeof(Agent).GetField("m_Brain", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(this, policy);
}
internal IPolicy GetPolicy()
{
return (IPolicy) typeof(Agent).GetField("m_Brain", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(this);
}
public int initializeAgentCalls;
public int collectObservationsCalls;
public int collectObservationsCallsSinceLastReset;

public int heuristicCalls;
public TestSensor sensor1;
public TestSensor sensor2;
var sensor1 = new TestSensor("testsensor1");
var sensor2 = new TestSensor("testsensor2");
sensor1 = new TestSensor("testsensor1");
sensor2 = new TestSensor("testsensor2");
sensor2.compressionType = SensorCompressionType.PNG;
sensors.Add(sensor2);
sensors.Add(sensor1);

public override void AgentReset()
{
agentResetCalls += 1;
collectObservationsCallsSinceLastReset = 0;
agentActionCallsSinceLastReset = 0;

{
heuristicCalls++;
return new float[0];
}
}

public string sensorName;
public int numWriteCalls;
public int numCompressedCalls;
public SensorCompressionType compressionType = SensorCompressionType.None;
public TestSensor(string n)
{

public int Write(WriteAdapter adapter)
{
numWriteCalls++;
// No-op
return 0;
}

numCompressedCalls++;
return SensorCompressionType.None;
return compressionType;
}
public string GetName()

for (var i = 0; i < 50; i++)
{
expectedAgent1ActionSinceReset += 1;
if (expectedAgent1ActionSinceReset == agent1.maxStep || i == 0){
if (expectedAgent1ActionSinceReset == agent1.maxStep || i == 0)
{
expectedAgent1ActionSinceReset = 0;
}
agent2.RequestAction();

agent1.LazyInitialize();
var expectedAgentStepCount = 0;
var expectedResets= 0;
var expectedResets = 0;
var expectedAgentAction = 0;
var expectedAgentActionSinceReset = 0;
var expectedCollectObsCalls = 0;

// If the next step will put the agent at maxSteps, we expect it to reset
if (agent1.StepCount == maxStep - 1 || (i == 0))
{
expectedResets +=1;
expectedResets += 1;
}
if (agent1.StepCount == maxStep - 1)

Assert.AreEqual(expectedCollectObsCalls, agent1.collectObservationsCalls);
Assert.AreEqual(expectedCollectObsCallsSinceReset, agent1.collectObservationsCallsSinceLastReset);
}
}
[Test]
public void TestHeuristicPolicyStepsSensors()
{
// Make sure that Agents with HeuristicPolicies step their sensors each Academy step.
var agentGo1 = new GameObject("TestAgent");
agentGo1.AddComponent<TestAgent>();
var agent1 = agentGo1.GetComponent<TestAgent>();
var aca = Academy.Instance;
var decisionRequester = agent1.gameObject.AddComponent<DecisionRequester>();
decisionRequester.DecisionPeriod = 1;
decisionRequester.Awake();
agent1.LazyInitialize();
Assert.AreEqual(agent1.GetPolicy().GetType(), typeof(HeuristicPolicy));
var numSteps = 10;
for (var i = 0; i < numSteps; i++)
{
aca.EnvironmentStep();
}
Assert.AreEqual(numSteps, agent1.heuristicCalls);
Assert.AreEqual(numSteps, agent1.sensor1.numWriteCalls);
Assert.AreEqual(numSteps, agent1.sensor2.numCompressedCalls);
}
}
}

2
com.unity.ml-agents/Tests/Editor/MultinomialTest.cs


using NUnit.Framework;
using MLAgents.InferenceBrain.Utils;
using MLAgents.Inference.Utils;
namespace MLAgents.Tests
{

2
com.unity.ml-agents/Tests/Editor/RandomNormalTest.cs


using System;
using NUnit.Framework;
using MLAgents.InferenceBrain.Utils;
using MLAgents.Inference.Utils;
namespace MLAgents.Tests
{

2
com.unity.ml-agents/Tests/Editor/Sensor/FloatVisualSensorTests.cs


using NUnit.Framework;
using UnityEngine;
using MLAgents.Sensors;
namespace MLAgents.Tests
{

1
com.unity.ml-agents/Tests/Editor/Sensor/RayPerceptionSensorTests.cs


using System.Collections.Generic;
using NUnit.Framework;
using UnityEngine;
using MLAgents.Sensors;
namespace MLAgents.Tests
{

部分文件因为文件数量过多而无法显示

正在加载...
取消
保存