浏览代码

Fix Code convention warnings in Rider. (#2801)

/develop-gpu-test
GitHub 5 年前
当前提交
5d2e466f
共有 68 个文件被更改,包括 335 次插入345 次删除
  1. 1
      UnitySDK/Assets/ML-Agents/Editor/AgentEditor.cs
  2. 24
      UnitySDK/Assets/ML-Agents/Editor/BehaviorParametersEditor.cs
  3. 26
      UnitySDK/Assets/ML-Agents/Editor/BrainParametersDrawer.cs
  4. 2
      UnitySDK/Assets/ML-Agents/Editor/DemonstrationImporter.cs
  5. 16
      UnitySDK/Assets/ML-Agents/Editor/ResetParameterDrawer.cs
  6. 6
      UnitySDK/Assets/ML-Agents/Editor/Tests/DemonstrationTests.cs
  7. 4
      UnitySDK/Assets/ML-Agents/Editor/Tests/EditModeTestInternalBrainTensorApplier.cs
  8. 5
      UnitySDK/Assets/ML-Agents/Editor/Tests/EditModeTestInternalBrainTensorGenerator.cs
  9. 12
      UnitySDK/Assets/ML-Agents/Editor/Tests/MLAgentsEditModeTest.cs
  10. 6
      UnitySDK/Assets/ML-Agents/Editor/Tests/RandomNormalTest.cs
  11. 3
      UnitySDK/Assets/ML-Agents/Editor/Tests/RayPerceptionTests.cs
  12. 4
      UnitySDK/Assets/ML-Agents/Examples/3DBall/Scripts/Ball3DAgent.cs
  13. 4
      UnitySDK/Assets/ML-Agents/Examples/3DBall/Scripts/Ball3DHardAgent.cs
  14. 6
      UnitySDK/Assets/ML-Agents/Examples/Basic/Scripts/BasicAgent.cs
  15. 4
      UnitySDK/Assets/ML-Agents/Examples/Bouncer/Scripts/BouncerAgent.cs
  16. 2
      UnitySDK/Assets/ML-Agents/Examples/Bouncer/Scripts/BouncerTarget.cs
  17. 8
      UnitySDK/Assets/ML-Agents/Examples/FoodCollector/Scripts/FoodCollectorAgent.cs
  18. 18
      UnitySDK/Assets/ML-Agents/Examples/GridWorld/Scripts/GridAgent.cs
  19. 4
      UnitySDK/Assets/ML-Agents/Examples/GridWorld/Scripts/GridArea.cs
  20. 2
      UnitySDK/Assets/ML-Agents/Examples/Hallway/Scripts/HallwayAgent.cs
  21. 4
      UnitySDK/Assets/ML-Agents/Examples/PushBlock/Scripts/PushAgentBasic.cs
  22. 12
      UnitySDK/Assets/ML-Agents/Examples/Pyramids/Scripts/PyramidAgent.cs
  23. 2
      UnitySDK/Assets/ML-Agents/Examples/Pyramids/Scripts/PyramidArea.cs
  24. 12
      UnitySDK/Assets/ML-Agents/Examples/Pyramids/Scripts/PyramidSwitch.cs
  25. 14
      UnitySDK/Assets/ML-Agents/Examples/Reacher/Scripts/ReacherAgent.cs
  26. 6
      UnitySDK/Assets/ML-Agents/Examples/Reacher/Scripts/ReacherGoal.cs
  27. 6
      UnitySDK/Assets/ML-Agents/Examples/SharedAssets/Scripts/FlyCamera.cs
  28. 2
      UnitySDK/Assets/ML-Agents/Examples/SharedAssets/Scripts/GroundContact.cs
  29. 2
      UnitySDK/Assets/ML-Agents/Examples/SharedAssets/Scripts/RayPerception3D.cs
  30. 2
      UnitySDK/Assets/ML-Agents/Examples/SharedAssets/Scripts/TargetContact.cs
  31. 4
      UnitySDK/Assets/ML-Agents/Examples/Soccer/Scripts/AgentSoccer.cs
  32. 10
      UnitySDK/Assets/ML-Agents/Examples/Tennis/Scripts/HitWall.cs
  33. 16
      UnitySDK/Assets/ML-Agents/Examples/Tennis/Scripts/TennisAgent.cs
  34. 2
      UnitySDK/Assets/ML-Agents/Examples/Tennis/Scripts/TennisArea.cs
  35. 8
      UnitySDK/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAgent.cs
  36. 4
      UnitySDK/Assets/ML-Agents/Examples/WallJump/Scripts/WallJumpAgent.cs
  37. 6
      UnitySDK/Assets/ML-Agents/Plugins/Barracuda.Core/Barracuda/Plugins/Editor/BarracudaEditor/NNModelImporter.cs
  38. 20
      UnitySDK/Assets/ML-Agents/Scripts/Academy.cs
  39. 10
      UnitySDK/Assets/ML-Agents/Scripts/ActionMasker.cs
  40. 40
      UnitySDK/Assets/ML-Agents/Scripts/Agent.cs
  41. 14
      UnitySDK/Assets/ML-Agents/Scripts/DemonstrationRecorder.cs
  42. 24
      UnitySDK/Assets/ML-Agents/Scripts/DemonstrationStore.cs
  43. 41
      UnitySDK/Assets/ML-Agents/Scripts/Grpc/RpcCommunicator.cs
  44. 4
      UnitySDK/Assets/ML-Agents/Scripts/ICommunicator.cs
  45. 12
      UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/ApplierImpl.cs
  46. 25
      UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/BarracudaModelParamLoader.cs
  47. 35
      UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/GeneratorImpl.cs
  48. 36
      UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/ModelRunner.cs
  49. 3
      UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/TensorApplier.cs
  50. 12
      UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/TensorGenerator.cs
  51. 2
      UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/TensorProxy.cs
  52. 2
      UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/Utils/Multinomial.cs
  53. 10
      UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/Utils/RandomNormal.cs
  54. 18
      UnitySDK/Assets/ML-Agents/Scripts/Policy/BarracudaPolicy.cs
  55. 16
      UnitySDK/Assets/ML-Agents/Scripts/Policy/BehaviorParameters.cs
  56. 6
      UnitySDK/Assets/ML-Agents/Scripts/Policy/HeuristicPolicy.cs
  57. 1
      UnitySDK/Assets/ML-Agents/Scripts/Policy/IPolicy.cs
  58. 21
      UnitySDK/Assets/ML-Agents/Scripts/Policy/RemotePolicy.cs
  59. 5
      UnitySDK/Assets/ML-Agents/Scripts/ResetParameters.cs
  60. 12
      UnitySDK/Assets/ML-Agents/Scripts/Sensor/CameraSensor.cs
  61. 2
      UnitySDK/Assets/ML-Agents/Scripts/Sensor/CameraSensorComponent.cs
  62. 1
      UnitySDK/Assets/ML-Agents/Scripts/Sensor/CompressedObservation.cs
  63. 2
      UnitySDK/Assets/ML-Agents/Scripts/Sensor/ISensor.cs
  64. 13
      UnitySDK/Assets/ML-Agents/Scripts/Sensor/RenderTextureSensor.cs
  65. 2
      UnitySDK/Assets/ML-Agents/Scripts/Sensor/RenderTextureSensorComponent.cs
  66. 6
      UnitySDK/Assets/ML-Agents/Scripts/Startup.cs
  67. 15
      UnitySDK/Assets/ML-Agents/Scripts/Timer.cs
  68. 1
      UnitySDK/UnitySDK.sln.DotSettings

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);

6
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()

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


{
public class EditModeTestInternalBrainTensorApplier
{
private class TestAgent : Agent
class TestAgent : Agent
{
public AgentAction GetAction()
{

}
}
private List<Agent> GetFakeAgentInfos()
List<Agent> GetFakeAgentInfos()
{
var goA = new GameObject("goA");
var agentA = goA.AddComponent<TestAgent>();

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


{
public class EditModeTestInternalBrainTensorGenerator
{
private static IEnumerable<Agent> GetFakeAgentInfos()
static IEnumerable<Agent> GetFakeAgentInfos()
{
var goA = new GameObject("goA");
var agentA = goA.AddComponent<TestAgent>();

[Test]
public void Construction()
{
var bp = new BrainParameters();
var tensorGenerator = new TensorGenerator(bp, 0, alloc, mem);
var tensorGenerator = new TensorGenerator(0, alloc, mem);
Assert.IsNotNull(tensorGenerator);
alloc.Dispose();
}

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


{
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()

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()

3
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);
var result = rayPer3D.Perceive(1f, angles, tags);
Debug.Log(result.Count);
Assert.IsTrue(result.Count == angles.Length * (tags.Length + 2));
}

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));
}
}

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.

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


{
Vector3 m_EndPosition;
RaycastHit m_Hit;
private float[] m_SubList;
float[] m_SubList;
/// <summary>
/// Creates perception vector to be used as part of an observation of an agent.

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));
}
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()
{

4
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));
AddVectorObs(m_RayPer.Perceive(
rayDistance, rayAngles, m_DetectableObjects, 2.5f, 2.5f));
var agentPos = m_AgentRb.position - ground.transform.position;

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-10";
const string k_ApiVersion = "API-10";
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 ICommunicator Communicator;
private bool m_Initialized;
private List<ModelRunner> m_ModelRunners = new List<ModelRunner>();
bool m_Initialized;
List<ModelRunner> m_ModelRunners = new List<ModelRunner>();
// Flag used to keep track of the first time the Academy is reset.
bool m_FirstAcademyReset;

}
// Used to read Python-provided environment parameters
private static int ReadArgs()
static int ReadArgs()
{
var args = System.Environment.GetCommandLineArgs();
var inputPort = "";

/// <summary>
/// Initializes the environment, configures it and initialized the Academy.
/// </summary>
private void InitializeEnvironment()
void InitializeEnvironment()
{
m_OriginalGravity = Physics.gravity;
m_OriginalFixedDeltaTime = Time.fixedDeltaTime;

Application.Quit();
}
private void OnResetCommand(EnvironmentResetParameters newResetParameters)
void OnResetCommand(EnvironmentResetParameters newResetParameters)
{
UpdateResetParameters(newResetParameters);
ForcedFullReset();

m_IsInference = !inputParams.isTraining;
}
private void UpdateResetParameters(EnvironmentResetParameters newResetParameters)
void UpdateResetParameters(EnvironmentResetParameters newResetParameters)
{
if (newResetParameters.resetParameters != null)
{

10
UnitySDK/Assets/ML-Agents/Scripts/ActionMasker.cs


{
/// When using discrete control, is the starting indices of the actions
/// when all the branches are concatenated with each other.
private int[] m_StartingActionIndices;
int[] m_StartingActionIndices;
private bool[] m_CurrentMask;
bool[] m_CurrentMask;
private readonly BrainParameters m_BrainParameters;
readonly BrainParameters m_BrainParameters;
public ActionMasker(BrainParameters brainParameters)
{

/// <summary>
/// Makes sure that the current mask is usable.
/// </summary>
private void AssertMask()
void AssertMask()
{
// Action Masks can only be used in Discrete Control.
if (m_BrainParameters.vectorActionSpaceType != SpaceType.Discrete)

/// </summary>
/// <param name="branch"> The index of the branch to check</param>
/// <returns> True if all the actions of the branch are masked</returns>
private bool AreAllActionsMasked(int branch)
bool AreAllActionsMasked(int branch)
{
if (m_CurrentMask == null)
{

40
UnitySDK/Assets/ML-Agents/Scripts/Agent.cs


using UnityEngine;
using Barracuda;
using MLAgents.Sensor;
using UnityEngine.Serialization;
namespace MLAgents
{

[RequireComponent(typeof(BehaviorParameters))]
public abstract class Agent : MonoBehaviour
{
private IPolicy m_Brain;
private BehaviorParameters m_PolicyFactory;
IPolicy m_Brain;
BehaviorParameters m_PolicyFactory;
/// <summary>
/// Agent parameters specified within the Editor via AgentEditor.

int m_Id;
/// Keeps track of the actions that are masked at each step.
private ActionMasker m_ActionMasker;
ActionMasker m_ActionMasker;
private DemonstrationRecorder m_Recorder;
DemonstrationRecorder m_Recorder;
public List<ISensor> m_Sensors;
[FormerlySerializedAs("m_Sensors")]
public List<ISensor> sensors;
/// Monobehavior function that is called when the attached GameObject
/// MonoBehaviour function that is called when the attached GameObject
/// becomes enabled or active.
void OnEnable()
{

{
m_Info = new AgentInfo();
m_Action = new AgentAction();
m_Sensors = new List<ISensor>();
sensors = new List<ISensor>();
if (academy == null)
{

/// will categorize the agent when training.
/// </param>
/// <param name="model"> The model to use for inference.</param>
/// <param name = "inferenceDevide"> Define on what device the model
/// <param name = "inferenceDevice"> Define on what device the model
/// will be run.</param>
public void GiveModel(
string behaviorName,

public void InitializeSensors()
{
var attachedSensorComponents = GetComponents<SensorComponent>();
m_Sensors.Capacity += attachedSensorComponents.Length;
sensors.Capacity += attachedSensorComponents.Length;
m_Sensors.Add(component.CreateSensor());
sensors.Add(component.CreateSensor());
// Sort the sensors by name to ensure determinism
m_Sensors.Sort((x, y) => x.GetName().CompareTo(y.GetName()));
// Sort the Sensors by name to ensure determinism
sensors.Sort((x, y) => x.GetName().CompareTo(y.GetName()));
for (var i = 0; i < m_Sensors.Count - 1; i++)
for (var i = 0; i < sensors.Count - 1; i++)
Debug.Assert(!m_Sensors[i].GetName().Equals(m_Sensors[i + 1].GetName()), "Sensor names must be unique.");
Debug.Assert(!sensors[i].GetName().Equals(sensors[i + 1].GetName()), "Sensor names must be unique.");
}
#endif
}

/// <summary>
/// Generate data for each sensor and store it on the Agent's AgentInfo.
/// NOTE: At the moment, this is only called during training or when using a DemonstrationRecorder;
/// during inference the sensors are used to write directly to the Tensor data. This will likely change in the
/// during inference the Sensors are used to write directly to the Tensor data. This will likely change in the
// Generate data for all sensors
// Generate data for all Sensors
for (var i = 0; i < m_Sensors.Count; i++)
for (var i = 0; i < sensors.Count; i++)
var sensor = m_Sensors[i];
var sensor = sensors[i];
var compressedObs = new CompressedObservation
{
Data = sensor.GetCompressedObservation(),

14
UnitySDK/Assets/ML-Agents/Scripts/DemonstrationRecorder.cs


{
public bool record;
public string demonstrationName;
private Agent m_RecordingAgent;
private string m_FilePath;
private DemonstrationStore m_DemoStore;
Agent m_RecordingAgent;
string m_FilePath;
DemonstrationStore m_DemoStore;
private void Start()
void Start()
{
if (Application.isEditor && record)
{

private void Update()
void Update()
{
if (Application.isEditor && record && m_DemoStore == null)
{

/// <summary>
/// Creates demonstration store for use in recording.
/// </summary>
private void InitializeDemoStore()
void InitializeDemoStore()
{
m_RecordingAgent = GetComponent<Agent>();
m_DemoStore = new DemonstrationStore();

/// <summary>
/// Closes Demonstration store.
/// </summary>
private void OnApplicationQuit()
void OnApplicationQuit()
{
if (Application.isEditor && record && m_DemoStore != null)
{

24
UnitySDK/Assets/ML-Agents/Scripts/DemonstrationStore.cs


public class DemonstrationStore
{
public const int MetaDataBytes = 32; // Number of bytes allocated to metadata in demo file.
private readonly IFileSystem m_FileSystem;
private const string k_DemoDirecory = "Assets/Demonstrations/";
private const string k_ExtensionType = ".demo";
readonly IFileSystem m_FileSystem;
const string k_DemoDirecory = "Assets/Demonstrations/";
const string k_ExtensionType = ".demo";
private string m_FilePath;
private DemonstrationMetaData m_MetaData;
private Stream m_Writer;
private float m_CumulativeReward;
string m_FilePath;
DemonstrationMetaData m_MetaData;
Stream m_Writer;
float m_CumulativeReward;
public DemonstrationStore(IFileSystem fileSystem)
{

/// Checks for the existence of the Demonstrations directory
/// and creates it if it does not exist.
/// </summary>
private void CreateDirectory()
void CreateDirectory()
{
if (!m_FileSystem.Directory.Exists(k_DemoDirecory))
{

/// <summary>
/// Creates demonstration file.
/// </summary>
private void CreateDemonstrationFile(string demonstrationName)
void CreateDemonstrationFile(string demonstrationName)
{
// Creates demonstration file.
var literalName = demonstrationName;

/// <summary>
/// Writes brain parameters to file.
/// </summary>
private void WriteBrainParameters(string brainName, BrainParameters brainParameters)
void WriteBrainParameters(string brainName, BrainParameters brainParameters)
{
// Writes BrainParameters to file.
m_Writer.Seek(MetaDataBytes + 1, 0);

/// <summary>
/// Performs necessary episode-completion steps.
/// </summary>
private void EndEpisode()
void EndEpisode()
{
m_MetaData.numberEpisodes += 1;
}

/// </summary>
private void WriteMetadata()
void WriteMetadata()
{
var metaProto = m_MetaData.ToProto();
var metaProtoBytes = metaProto.ToByteArray();

41
UnitySDK/Assets/ML-Agents/Scripts/Grpc/RpcCommunicator.cs


bool m_IsOpen;
/// The default number of agents in the scene
private const int k_NumAgents = 32;
const int k_NumAgents = 32;
/// Keeps track of the agents of each brain on the current step
Dictionary<string, List<Agent>> m_CurrentAgents =

new Dictionary<string, Dictionary<Agent, AgentAction>>();
// Brains that we have sent over the communicator with agents.
HashSet<string> m_sentBrainKeys = new HashSet<string>();
Dictionary<string, BrainParameters> m_unsentBrainKeys = new Dictionary<string, BrainParameters>();
HashSet<string> m_SentBrainKeys = new HashSet<string>();
Dictionary<string, BrainParameters> m_UnsentBrainKeys = new Dictionary<string, BrainParameters>();
# if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_STANDALONE_LINUX

SendCommandEvent(rlInput.Command, rlInput.EnvironmentParameters);
}
private UnityInputProto Initialize(UnityOutputProto unityOutput,
UnityInputProto Initialize(UnityOutputProto unityOutput,
out UnityInputProto unityInput)
{
# if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_STANDALONE_LINUX

#endregion
#region Sending Events
private void SendCommandEvent(CommandProto command, EnvironmentParametersProto environmentParametersProto)
void SendCommandEvent(CommandProto command, EnvironmentParametersProto environmentParametersProto)
{
switch (command)
{

}
}
private void SendRLInputReceivedEvent(bool isTraining)
void SendRLInputReceivedEvent(bool isTraining)
{
RLInputReceived?.Invoke(new UnityRLInputParameters { isTraining = isTraining });
}

/// <summary>
/// Sends the observations of one Agent.
/// </summary>
/// <param name="key">Batch Key.</param>
/// <param name="agents">Agent info.</param>
/// <param name="brainKey">Batch Key.</param>
/// <param name="agent">Agent info.</param>
public void PutObservations(string brainKey, Agent agent)
{
m_CurrentAgents[brainKey].Add(agent);

/// </summary>
/// <returns>The next UnityInput.</returns>
/// <param name="unityOutput">The UnityOutput to be sent.</param>
private UnityInputProto Exchange(UnityOutputProto unityOutput)
UnityInputProto Exchange(UnityOutputProto unityOutput)
{
# if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_STANDALONE_LINUX
if (!m_IsOpen)

/// <returns>The UnityMessage corresponding.</returns>
/// <param name="content">The UnityOutput to be wrapped.</param>
/// <param name="status">The status of the message.</param>
private static UnityMessageProto WrapMessage(UnityOutputProto content, int status)
static UnityMessageProto WrapMessage(UnityOutputProto content, int status)
{
return new UnityMessageProto
{

}
private void CacheBrainParameters(string brainKey, BrainParameters brainParameters)
void CacheBrainParameters(string brainKey, BrainParameters brainParameters)
if (m_sentBrainKeys.Contains(brainKey))
if (m_SentBrainKeys.Contains(brainKey))
m_unsentBrainKeys[brainKey] = brainParameters;
m_UnsentBrainKeys[brainKey] = brainParameters;
private UnityRLInitializationOutputProto GetTempUnityRlInitializationOutput()
UnityRLInitializationOutputProto GetTempUnityRlInitializationOutput()
foreach (var brainKey in m_unsentBrainKeys.Keys)
foreach (var brainKey in m_UnsentBrainKeys.Keys)
{
if (m_CurrentUnityRlOutput.AgentInfos.ContainsKey(brainKey))
{

}
var brainParameters = m_unsentBrainKeys[brainKey];
var brainParameters = m_UnsentBrainKeys[brainKey];
output.BrainParameters.Add(brainParameters.ToProto(brainKey, true));
}
}

private void UpdateSentBrainParameters(UnityRLInitializationOutputProto output)
void UpdateSentBrainParameters(UnityRLInitializationOutputProto output)
{
if (output == null)
{

foreach (var brainProto in output.BrainParameters)
{
m_sentBrainKeys.Add(brainProto.BrainName);
m_unsentBrainKeys.Remove(brainProto.BrainName);
m_SentBrainKeys.Add(brainProto.BrainName);
m_UnsentBrainKeys.Remove(brainProto.BrainName);
}
}

/// When the editor exits, the communicator must be closed
/// </summary>
/// <param name="state">State.</param>
private void HandleOnPlayModeChanged(PlayModeStateChange state)
void HandleOnPlayModeChanged(PlayModeStateChange state)
{
// This method is run whenever the playmode state is changed.
if (state == PlayModeStateChange.ExitingPlayMode)

4
UnitySDK/Assets/ML-Agents/Scripts/ICommunicator.cs


/// <summary>
/// Sends the observations of one Agent.
/// </summary>
/// <param name="key">Batch Key.</param>
/// <param name="agents">Agent info.</param>
/// <param name="brainKey">Batch Key.</param>
/// <param name="agent">Agent info.</param>
void PutObservations(string brainKey, Agent agent);
/// <summary>

12
UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/ApplierImpl.cs


/// </summary>
public class DiscreteActionOutputApplier : TensorApplier.IApplier
{
private readonly int[] m_ActionSize;
private readonly Multinomial m_Multinomial;
private readonly ITensorAllocator m_Allocator;
readonly int[] m_ActionSize;
readonly Multinomial m_Multinomial;
readonly ITensorAllocator m_Allocator;
public DiscreteActionOutputApplier(int[] actionSize, int seed, ITensorAllocator allocator)
{

public class BarracudaMemoryOutputApplier : TensorApplier.IApplier
{
private readonly int m_MemoriesCount;
private readonly int m_MemoryIndex;
readonly int m_MemoriesCount;
readonly int m_MemoryIndex;
private Dictionary<int, List<float>> m_Memories;
Dictionary<int, List<float>> m_Memories;
public BarracudaMemoryOutputApplier(
int memoriesCount,

25
UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/BarracudaModelParamLoader.cs


/// </summary>
public class BarracudaModelParamLoader
{
private enum ModelActionType
enum ModelActionType
private const long k_ApiVersion = 2;
const long k_ApiVersion = 2;
/// <summary>
/// Generates the Tensor inputs that are expected to be present in the Model.

/// The integer value in the model indicating the type of control
/// </param>
/// <returns>The equivalent ModelActionType</returns>
private static ModelActionType GetActionType(int isContinuousInt)
static ModelActionType GetActionType(int isContinuousInt)
{
ModelActionType isContinuous;
switch (isContinuousInt)

/// </summary>
/// <param name="requiredScalarFields"> Mapping from node names to int values</param>
/// <returns>The list the error messages of the checks that failed</returns>
private static IEnumerable<string> CheckIntScalarPresenceHelper(
static IEnumerable<string> CheckIntScalarPresenceHelper(
Dictionary<string, int> requiredScalarFields)
{
var failedModelChecks = new List<string>();

/// <returns>
/// A IEnumerable of string corresponding to the failed input presence checks.
/// </returns>
private static IEnumerable<string> CheckInputTensorPresence(
static IEnumerable<string> CheckInputTensorPresence(
Model model,
BrainParameters brainParameters,
int memory,

/// <returns>
/// A IEnumerable of string corresponding to the failed output presence checks.
/// </returns>
private static IEnumerable<string> CheckOutputTensorPresence(Model model, int memory)
static IEnumerable<string> CheckOutputTensorPresence(Model model, int memory)
{
var failedModelChecks = new List<string>();
// If there is no Action Output.

/// The BrainParameters that are used verify the compatibility with the InferenceEngine
/// </param>
/// <returns>The list the error messages of the checks that failed</returns>
private static IEnumerable<string> CheckInputTensorShape(
static IEnumerable<string> CheckInputTensorShape(
Model model, BrainParameters brainParameters)
{
var failedModelChecks = new List<string>();

/// If the Check failed, returns a string containing information about why the
/// check failed. If the check passed, returns null.
/// </returns>
private static string CheckVectorObsShape(
static string CheckVectorObsShape(
BrainParameters brainParameters, TensorProxy tensorProxy)
{
var vecObsSizeBp = brainParameters.vectorObservationSize;

/// <param name="tensorProxy"> The tensor that is expected by the model</param>
/// <returns>If the Check failed, returns a string containing information about why the
/// check failed. If the check passed, returns null.</returns>
private static string CheckPreviousActionShape(
static string CheckPreviousActionShape(
BrainParameters brainParameters, TensorProxy tensorProxy)
{
var numberActionsBp = brainParameters.vectorActionSize.Length;

/// A IEnumerable of string corresponding to the incompatible shapes between model
/// and BrainParameters.
/// </returns>
private static IEnumerable<string> CheckOutputTensorShape(
static IEnumerable<string> CheckOutputTensorShape(
Model model,
BrainParameters brainParameters,
ModelActionType isContinuous,

/// If the Check failed, returns a string containing information about why the
/// check failed. If the check passed, returns null.
/// </returns>
private static string CheckDiscreteActionOutputShape(
static string CheckDiscreteActionOutputShape(
BrainParameters brainParameters, TensorShape shape, int modelActionSize)
{
var bpActionSize = brainParameters.vectorActionSize.Sum();

/// </param>
/// <returns>If the Check failed, returns a string containing information about why the
/// check failed. If the check passed, returns null.</returns>
private static string CheckContinuousActionOutputShape(
static string CheckContinuousActionOutputShape(
BrainParameters brainParameters, TensorShape shape, int modelActionSize)
{
var bpActionSize = brainParameters.vectorActionSize[0];

35
UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/GeneratorImpl.cs


using System.Collections.Generic;
using System;
using System.Linq;
using Barracuda;
using MLAgents.InferenceBrain.Utils;

/// </summary>
public class BiDimensionalOutputGenerator : TensorGenerator.IGenerator
{
private readonly ITensorAllocator m_Allocator;
readonly ITensorAllocator m_Allocator;
public BiDimensionalOutputGenerator(ITensorAllocator allocator)
{

/// </summary>
public class BatchSizeGenerator : TensorGenerator.IGenerator
{
private readonly ITensorAllocator m_Allocator;
readonly ITensorAllocator m_Allocator;
public BatchSizeGenerator(ITensorAllocator allocator)
{

/// </summary>
public class SequenceLengthGenerator : TensorGenerator.IGenerator
{
private readonly ITensorAllocator m_Allocator;
readonly ITensorAllocator m_Allocator;
public SequenceLengthGenerator(ITensorAllocator allocator)
{

/// </summary>
public class VectorObservationGenerator : TensorGenerator.IGenerator
{
private readonly ITensorAllocator m_Allocator;
readonly ITensorAllocator m_Allocator;
public VectorObservationGenerator(ITensorAllocator allocator)
{
m_Allocator = allocator;

public class BarracudaRecurrentInputGenerator : TensorGenerator.IGenerator
{
private int m_MemoriesCount;
private readonly int m_MemoryIndex;
private readonly ITensorAllocator m_Allocator;
int m_MemoriesCount;
readonly int m_MemoryIndex;
readonly ITensorAllocator m_Allocator;
private Dictionary<int, List<float>> m_Memories;
Dictionary<int, List<float>> m_Memories;
public BarracudaRecurrentInputGenerator(
int memoryIndex,

foreach (var agent in agents)
{
var offset = memorySize * m_MemoryIndex;
List<float> memory = null;
List<float> memory;
if (!m_Memories.TryGetValue(agent.Info.id, out memory))
{
agentIndex++;

/// </summary>
public class PreviousActionInputGenerator : TensorGenerator.IGenerator
{
private readonly ITensorAllocator m_Allocator;
readonly ITensorAllocator m_Allocator;
public PreviousActionInputGenerator(ITensorAllocator allocator)
{

/// </summary>
public class ActionMaskInputGenerator : TensorGenerator.IGenerator
{
private readonly ITensorAllocator m_Allocator;
readonly ITensorAllocator m_Allocator;
public ActionMaskInputGenerator(ITensorAllocator allocator)
{

/// </summary>
public class RandomNormalInputGenerator : TensorGenerator.IGenerator
{
private readonly RandomNormal m_RandomNormal;
private readonly ITensorAllocator m_Allocator;
readonly RandomNormal m_RandomNormal;
readonly ITensorAllocator m_Allocator;
public RandomNormalInputGenerator(int seed, ITensorAllocator allocator)
{

/// </summary>
public class VisualObservationInputGenerator : TensorGenerator.IGenerator
{
private readonly int m_Index;
private readonly bool m_GrayScale;
private readonly ITensorAllocator m_Allocator;
readonly int m_Index;
readonly bool m_GrayScale;
readonly ITensorAllocator m_Allocator;
public VisualObservationInputGenerator(
int index, ITensorAllocator allocator)

{
// TODO direct access to sensors list here - should we do it differently?
// TODO m_Index here is the visual observation index. Will work for now but not if we add more sensor types.
agent.m_Sensors[m_Index].WriteToTensor(tensorProxy, agentIndex);
agent.sensors[m_Index].WriteToTensor(tensorProxy, agentIndex);
agentIndex++;
}
}

36
UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/ModelRunner.cs


{
public class ModelRunner
{
private List<Agent> m_Agents = new List<Agent>();
private ITensorAllocator m_TensorAllocator;
private TensorGenerator m_TensorGenerator;
private TensorApplier m_TensorApplier;
List<Agent> m_Agents = new List<Agent>();
ITensorAllocator m_TensorAllocator;
TensorGenerator m_TensorGenerator;
TensorApplier m_TensorApplier;
private NNModel m_Model;
private InferenceDevice m_InferenceDevice;
private IWorker m_Engine;
private bool m_Verbose = false;
private string[] m_OutputNames;
private IReadOnlyList<TensorProxy> m_InferenceInputs;
private IReadOnlyList<TensorProxy> m_InferenceOutputs;
private Dictionary<int, List<float>> m_Memories = new Dictionary<int, List<float>>();
NNModel m_Model;
InferenceDevice m_InferenceDevice;
IWorker m_Engine;
bool m_Verbose = false;
string[] m_OutputNames;
IReadOnlyList<TensorProxy> m_InferenceInputs;
IReadOnlyList<TensorProxy> m_InferenceOutputs;
Dictionary<int, List<float>> m_Memories = new Dictionary<int, List<float>>();
private bool m_visualObservationsInitialized = false;
bool m_VisualObservationsInitialized;
/// <summary>
/// Initializes the Brain with the Model that it will use when selecting actions for

m_InferenceInputs = BarracudaModelParamLoader.GetInputTensors(barracudaModel);
m_OutputNames = BarracudaModelParamLoader.GetOutputNames(barracudaModel);
m_TensorGenerator = new TensorGenerator(
brainParameters, seed, m_TensorAllocator, m_Memories, barracudaModel);
seed, m_TensorAllocator, m_Memories, barracudaModel);
private static Dictionary<string, Tensor> PrepareBarracudaInputs(IEnumerable<TensorProxy> infInputs)
static Dictionary<string, Tensor> PrepareBarracudaInputs(IEnumerable<TensorProxy> infInputs)
{
var inputs = new Dictionary<string, Tensor>();
foreach (var inp in infInputs)

m_TensorAllocator?.Reset(false);
}
private List<TensorProxy> FetchBarracudaOutputs(string[] names)
List<TensorProxy> FetchBarracudaOutputs(string[] names)
{
var outputs = new List<TensorProxy>();
foreach (var n in names)

return;
}
if (!m_visualObservationsInitialized)
if (!m_VisualObservationsInitialized)
m_visualObservationsInitialized = true;
m_VisualObservationsInitialized = true;
}
Profiler.BeginSample("LearningBrain.DecideAction");

3
UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/TensorApplier.cs


void Apply(TensorProxy tensorProxy, IEnumerable<Agent> agents);
}
private readonly Dictionary<string, IApplier> m_Dict = new Dictionary<string, IApplier>();
readonly Dictionary<string, IApplier> m_Dict = new Dictionary<string, IApplier>();
/// <summary>
/// Returns a new TensorAppliers object.

/// <param name="seed"> The seed the Appliers will be initialized with.</param>
/// <param name="allocator"> Tensor allocator</param>
/// <param name="memories">Dictionary of AgentInfo.id to memory used to pass to the inference model.</param>
/// <param name="barracudaModel"></param>
public TensorApplier(
BrainParameters bp,

12
UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/TensorGenerator.cs


TensorProxy tensorProxy, int batchSize, IEnumerable<Agent> agents);
}
private readonly Dictionary<string, IGenerator> m_Dict = new Dictionary<string, IGenerator>();
readonly Dictionary<string, IGenerator> m_Dict = new Dictionary<string, IGenerator>();
/// <param name="bp"> The BrainParameters used to determine what Generators will be
/// used</param>
/// <param name="memories">Dictionary of AgentInfo.id to memory for use in the inference model.</param>
BrainParameters bp,
int seed,
ITensorAllocator allocator,
Dictionary<int, List<float>> memories,

if (barracudaModel != null)
{
var model = (Model)barracudaModel;
for (var i = 0; i < model?.memories.Length; i++)
for (var i = 0; i < model.memories.Length; i++)
{
m_Dict[model.memories[i].input] =
new BarracudaRecurrentInputGenerator(i, allocator, memories);

public void InitializeVisualObservations(Agent agent, ITensorAllocator allocator)
{
for (var visIndex = 0; visIndex < agent.m_Sensors.Count; visIndex++)
for (var visIndex = 0; visIndex < agent.sensors.Count; visIndex++)
// TODO handle non-visual sensors too - need to index better
// TODO handle non-visual Sensors too - need to index better
m_Dict[TensorNames.VisualObservationPlaceholderPrefix + visIndex] =
new VisualObservationInputGenerator(visIndex, allocator);
}

2
UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/TensorProxy.cs


FloatingPoint
};
private static readonly Dictionary<TensorType, Type> k_TypeMap =
static readonly Dictionary<TensorType, Type> k_TypeMap =
new Dictionary<TensorType, Type>()
{
{TensorType.FloatingPoint, typeof(float)},

2
UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/Utils/Multinomial.cs


/// </summary>
public class Multinomial
{
private readonly System.Random m_Random;
readonly System.Random m_Random;
/// <summary>
/// Constructor.

10
UnitySDK/Assets/ML-Agents/Scripts/InferenceBrain/Utils/RandomNormal.cs


/// </summary>
public class RandomNormal
{
private readonly double m_Mean;
private readonly double m_Stddev;
private readonly Random m_Random;
readonly double m_Mean;
readonly double m_Stddev;
readonly Random m_Random;
public RandomNormal(int seed, float mean = 0.0f, float stddev = 1.0f)
{

}
// Each iteration produces two numbers. Hold one here for next call
private bool m_HasSpare;
private double m_SpareUnscaled;
bool m_HasSpare;
double m_SpareUnscaled;
/// <summary>
/// Return the next random double number

18
UnitySDK/Assets/ML-Agents/Scripts/Policy/BarracudaPolicy.cs


protected ModelRunner m_ModelRunner;
/// <summary>
/// Sensor shapes for the associated Agents. All Agents must have the same shapes for their sensors.
/// Sensor shapes for the associated Agents. All Agents must have the same shapes for their Sensors.
/// </summary>
List<int[]> m_SensorShapes;

NNModel model,
InferenceDevice inferenceDevice)
{
var aca = GameObject.FindObjectOfType<Academy>();
var aca = Object.FindObjectOfType<Academy>();
aca.LazyInitialization();
var modelRunner = aca.GetOrCreateModelRunner(model, brainParameters, inferenceDevice);
m_ModelRunner = modelRunner;

}
/// <summary>
/// Check that the Agent sensors are the same shape as the the other Agents using the same Brain.
/// Check that the Agent Sensors are the same shape as the the other Agents using the same Brain.
private void ValidateAgentSensorShapes(Agent agent)
void ValidateAgentSensorShapes(Agent agent)
m_SensorShapes = new List<int[]>(agent.m_Sensors.Count);
m_SensorShapes = new List<int[]>(agent.sensors.Count);
foreach (var sensor in agent.m_Sensors)
foreach (var sensor in agent.sensors)
{
m_SensorShapes.Add(sensor.GetFloatObservationShape());
}

// Check for compatibility with the other Agents' sensors
// Check for compatibility with the other Agents' Sensors
Debug.Assert(m_SensorShapes.Count == agent.m_Sensors.Count, $"Number of sensors must match. {m_SensorShapes.Count} != {agent.m_Sensors.Count}");
Debug.Assert(m_SensorShapes.Count == agent.sensors.Count, $"Number of Sensors must match. {m_SensorShapes.Count} != {agent.sensors.Count}");
var sensorShape = agent.m_Sensors[i].GetFloatObservationShape();
var sensorShape = agent.sensors[i].GetFloatObservationShape();
Debug.Assert(cachedShape.Length == sensorShape.Length, "Sensor dimensions must match.");
for (var j = 0; j < cachedShape.Length; j++)
{

16
UnitySDK/Assets/ML-Agents/Scripts/Policy/BehaviorParameters.cs


[HideInInspector]
[SerializeField]
private BrainParameters m_BrainParameters = new BrainParameters();
[HideInInspector] [SerializeField] private NNModel m_Model;
[HideInInspector] [SerializeField] private InferenceDevice m_InferenceDevice;
[HideInInspector] [SerializeField] private bool m_UseHeuristic;
[HideInInspector] [SerializeField] private string m_BehaviorName = "My Behavior";
BrainParameters m_BrainParameters = new BrainParameters();
[HideInInspector] [SerializeField]
NNModel m_Model;
[HideInInspector] [SerializeField]
InferenceDevice m_InferenceDevice;
[HideInInspector] [SerializeField]
bool m_UseHeuristic;
[HideInInspector] [SerializeField]
string m_BehaviorName = "My Behavior";
[HideInInspector]
[HideInInspector]
public string behaviorName
{
get { return m_BehaviorName; }

6
UnitySDK/Assets/ML-Agents/Scripts/Policy/HeuristicPolicy.cs


using UnityEngine;
using Barracuda;
using MLAgents.InferenceBrain;
using System;
namespace MLAgents

/// </summary>
public class HeuristicPolicy : IPolicy
{
private Func<float[]> m_Heuristic;
private Agent m_Agent;
Func<float[]> m_Heuristic;
Agent m_Agent;
/// <inheritdoc />
public HeuristicPolicy(Func<float[]> heuristic)

1
UnitySDK/Assets/ML-Agents/Scripts/Policy/IPolicy.cs


using System;
using System.Collections.Generic;
using UnityEngine;
namespace MLAgents

21
UnitySDK/Assets/ML-Agents/Scripts/Policy/RemotePolicy.cs


/// </summary>
public class RemotePolicy : IPolicy
{
private string m_BehaviorName;
string m_BehaviorName;
/// Sensor shapes for the associated Agents. All Agents must have the same shapes for their sensors.
/// Sensor shapes for the associated Agents. All Agents must have the same shapes for their Sensors.
/// </summary>
List<int[]> m_SensorShapes;

string behaviorName)
{
m_BehaviorName = behaviorName;
var aca = GameObject.FindObjectOfType<Academy>();
var aca = Object.FindObjectOfType<Academy>();
aca.LazyInitialization();
m_Communicator = aca.Communicator;
aca.Communicator.SubscribeBrain(m_BehaviorName, brainParameters);

}
/// <summary>
/// Check that the Agent sensors are the same shape as the the other Agents using the same Brain.
/// Check that the Agent Sensors are the same shape as the the other Agents using the same Brain.
private void ValidateAgentSensorShapes(Agent agent)
void ValidateAgentSensorShapes(Agent agent)
m_SensorShapes = new List<int[]>(agent.m_Sensors.Count);
m_SensorShapes = new List<int[]>(agent.sensors.Count);
foreach (var sensor in agent.m_Sensors)
foreach (var sensor in agent.sensors)
{
m_SensorShapes.Add(sensor.GetFloatObservationShape());
}

// Check for compatibility with the other Agents' sensors
// Check for compatibility with the other Agents' Sensors
Debug.Assert(m_SensorShapes.Count == agent.m_Sensors.Count, $"Number of sensors must match. {m_SensorShapes.Count} != {agent.m_Sensors.Count}");
Debug.Assert(m_SensorShapes.Count == agent.sensors.Count, $"Number of Sensors must match. {m_SensorShapes.Count} != {agent.sensors.Count}");
var sensorShape = agent.m_Sensors[i].GetFloatObservationShape();
var sensorShape = agent.sensors[i].GetFloatObservationShape();
Debug.Assert(cachedShape.Length == sensorShape.Length, "Sensor dimensions must match.");
for (var j = 0; j < cachedShape.Length; j++)
{

5
UnitySDK/Assets/ML-Agents/Scripts/ResetParameters.cs


UpdateResetParameters();
}
private void UpdateResetParameters()
void UpdateResetParameters()
{
m_ResetParameters.Clear();
foreach (var pair in this)

}
[FormerlySerializedAs("resetParameters")]
[SerializeField] private List<ResetParameter> m_ResetParameters = new List<ResetParameter>();
[SerializeField]
List<ResetParameter> m_ResetParameters = new List<ResetParameter>();
public void OnBeforeSerialize()
{

12
UnitySDK/Assets/ML-Agents/Scripts/Sensor/CameraSensor.cs


{
public class CameraSensor : ISensor
{
private Camera m_Camera;
private int m_Width;
private int m_Height;
private bool m_Grayscale;
private string m_Name;
private int[] m_Shape;
Camera m_Camera;
int m_Width;
int m_Height;
bool m_Grayscale;
string m_Name;
int[] m_Shape;
public CameraSensor(Camera camera, int width, int height, bool grayscale, string name)
{

2
UnitySDK/Assets/ML-Agents/Scripts/Sensor/CameraSensorComponent.cs


public string sensorName = "CameraSensor";
public int width = 84;
public int height = 84;
public bool grayscale = false;
public bool grayscale;
public override ISensor CreateSensor()
{

1
UnitySDK/Assets/ML-Agents/Scripts/Sensor/CompressedObservation.cs


using System;
using MLAgents.InferenceBrain;
using UnityEngine;
namespace MLAgents.Sensor

2
UnitySDK/Assets/ML-Agents/Scripts/Sensor/ISensor.cs


public enum CompressionType
{
None,
PNG,
PNG
}
/// <summary>

13
UnitySDK/Assets/ML-Agents/Scripts/Sensor/RenderTextureSensor.cs


using System;
using System.Threading;
using MLAgents.InferenceBrain;
using UnityEngine;

{
private RenderTexture m_RenderTexture;
private int m_Width;
private int m_Height;
private bool m_Grayscale;
private string m_Name;
private int[] m_Shape;
RenderTexture m_RenderTexture;
int m_Width;
int m_Height;
bool m_Grayscale;
string m_Name;
int[] m_Shape;
public RenderTextureSensor(RenderTexture renderTexture, int width, int height, bool grayscale, string name)
{

2
UnitySDK/Assets/ML-Agents/Scripts/Sensor/RenderTextureSensorComponent.cs


public string sensorName = "RenderTextureSensor";
public int width = 84;
public int height = 84;
public bool grayscale = false;
public bool grayscale;
public override ISensor CreateSensor()
{

6
UnitySDK/Assets/ML-Agents/Scripts/Startup.cs


{
public class Startup : MonoBehaviour
{
private const string k_SceneVariableName = "SCENE_NAME";
const string k_SceneVariableName = "SCENE_NAME";
private void Awake()
void Awake()
private static void SwitchScene(string sceneName)
static void SwitchScene(string sceneName)
{
if (sceneName == null)
{

15
UnitySDK/Assets/ML-Agents/Scripts/Timer.cs


using UnityEngine.Profiling;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace MLAgents
{

/// <summary>
/// Custom sampler used to add timings to the profiler.
/// </summary>
private CustomSampler m_Sampler;
CustomSampler m_Sampler;
/// <summary>
/// Number of total ticks elapsed for this node.

/// </remarks>
public class TimerStack : System.IDisposable
{
private static readonly TimerStack k_Instance = new TimerStack();
static readonly TimerStack k_Instance = new TimerStack();
Stack<TimerNode> m_Stack;
TimerNode m_RootNode;

{
}
private TimerStack()
TimerStack()
{
Reset();
}

get { return m_RootNode; }
}
private void Push(string name)
void Push(string name)
{
var current = m_Stack.Peek();
var next = current.GetChild(name);

private void Pop()
void Pop()
{
var node = m_Stack.Pop();
node.End();

1
UnitySDK/UnitySDK.sln.DotSettings


<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CPU/@EntryIndexedValue">CPU</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GPU/@EntryIndexedValue">GPU</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=NN/@EntryIndexedValue">NN</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=PNG/@EntryIndexedValue">PNG</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RL/@EntryIndexedValue">RL</s:String>
<s:Boolean x:Key="/Default/UserDictionary/Words/=BLAS/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Logits/@EntryIndexedValue">True</s:Boolean>

正在加载...
取消
保存