比较提交

...
此合并请求有变更与目标分支冲突。
/DevProject/Packages/packages-lock.json
/utils/make_readme_table.py
/.yamato/com.unity.ml-agents-test.yml
/gym-unity/gym_unity/envs/__init__.py
/gym-unity/gym_unity/__init__.py
/Project/Packages/packages-lock.json
/Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/ModelOverrider.cs
/Project/Assets/ML-Agents/Examples/Soccer/Prefabs/SoccerFieldTwos.prefab
/com.unity.ml-agents.extensions/package.json
/com.unity.ml-agents.extensions/Documentation~/com.unity.ml-agents.extensions.md
/com.unity.ml-agents/package.json
/com.unity.ml-agents/Documentation~/com.unity.ml-agents.md
/com.unity.ml-agents/Tests/Runtime/Sensor/BoxOverlapCheckerTests.cs
/com.unity.ml-agents/Runtime/Academy.cs
/com.unity.ml-agents/Runtime/Actuators/IActionReceiver.cs
/com.unity.ml-agents/Runtime/Actuators/IDiscreteActionMask.cs
/com.unity.ml-agents/Runtime/Agent.cs
/com.unity.ml-agents/Runtime/Demonstrations/DemonstrationRecorder.cs
/com.unity.ml-agents/Runtime/Integrations/Match3/Match3SensorComponent.cs
/com.unity.ml-agents/Runtime/Sensors/BoxOverlapChecker.cs
/com.unity.ml-agents/Runtime/Sensors/GridSensorComponent.cs
/com.unity.ml-agents/CHANGELOG.md
/ml-agents-envs/README.md
/ml-agents-envs/mlagents_envs/__init__.py
/docs/Installation-Anaconda-Windows.md
/docs/Installation.md
/docs/Learning-Environment-Design-Agents.md
/docs/Migrating.md
/docs/Training-on-Amazon-Web-Service.md
/docs/Training-on-Microsoft-Azure.md
/docs/Unity-Inference-Engine.md
/ml-agents/setup.py
/ml-agents/README.md
/ml-agents/mlagents/trainers/settings.py
/ml-agents/mlagents/trainers/tests/test_stats.py
/ml-agents/mlagents/trainers/__init__.py
/README.md

5 次代码提交

作者 SHA1 备注 提交日期
Christopher Goy 0968daa8 Test 2021.2. 4 年前
Christopher Goy 383cedee Format. 4 年前
Christopher Goy 5bddb307 Update changelog. 4 年前
Christopher Goy f1efdb46 Update to pre2 4 年前
Christopher Goy 90c6a2d7 Update version to 'pre.1' 4 年前
共有 60 个文件被更改,包括 617 次插入169 次删除
  1. 6
      DevProject/Packages/packages-lock.json
  2. 1
      utils/make_readme_table.py
  3. 2
      utils/validate_versions.py
  4. 4
      gym-unity/gym_unity/__init__.py
  5. 9
      gym-unity/gym_unity/envs/__init__.py
  6. 21
      gym-unity/gym_unity/tests/test_gym.py
  7. 8
      Project/Assets/ML-Agents/Examples/Soccer/Prefabs/SoccerFieldTwos.prefab
  8. 6
      Project/Assets/ML-Agents/Examples/Soccer/Prefabs/StrikersVsGoalieField.prefab
  9. 12
      Project/Assets/ML-Agents/Examples/SharedAssets/Scripts/ModelOverrider.cs
  10. 4
      Project/Assets/ML-Agents/Examples/Match3/Scripts/Match3Drawer.cs
  11. 6
      Project/Assets/ML-Agents/Examples/Match3/Scripts/Match3Agent.cs
  12. 136
      Project/Assets/ML-Agents/Examples/FoodCollector/Prefabs/VisualFoodCollectorArea.prefab
  13. 54
      Project/Assets/ML-Agents/Examples/PushBlock/Prefabs/PushBlockCollabAreaGrid.prefab
  14. 5
      Project/Assets/ML-Agents/Examples/PushBlock/Scenes/PushBlockCollab.unity
  15. 6
      Project/Packages/packages-lock.json
  16. 12
      README.md
  17. 13
      com.unity.ml-agents.extensions/Documentation~/com.unity.ml-agents.extensions.md
  18. 4
      com.unity.ml-agents.extensions/package.json
  19. 4
      com.unity.ml-agents/package.json
  20. 13
      com.unity.ml-agents/CHANGELOG.md
  21. 14
      com.unity.ml-agents/Documentation~/com.unity.ml-agents.md
  22. 8
      com.unity.ml-agents/Editor/Match3ActuatorComponentEditor.cs
  23. 8
      com.unity.ml-agents/Editor/Match3SensorComponentEditor.cs
  24. 1
      com.unity.ml-agents/Editor/GridSensorComponentEditor.cs
  25. 9
      com.unity.ml-agents/Tests/Editor/Integrations/Match3/Match3ActuatorTests.cs
  26. 9
      com.unity.ml-agents/Tests/Editor/Integrations/Match3/Match3SensorTests.cs
  27. 28
      com.unity.ml-agents/Tests/Runtime/Sensor/BoxOverlapCheckerTests.cs
  28. 2
      com.unity.ml-agents/Runtime/Actuators/IActionReceiver.cs
  29. 2
      com.unity.ml-agents/Runtime/Actuators/IDiscreteActionMask.cs
  30. 26
      com.unity.ml-agents/Runtime/Agent.cs
  31. 2
      com.unity.ml-agents/Runtime/Demonstrations/DemonstrationRecorder.cs
  32. 21
      com.unity.ml-agents/Runtime/Sensors/BoxOverlapChecker.cs
  33. 13
      com.unity.ml-agents/Runtime/Sensors/GridSensorComponent.cs
  34. 6
      com.unity.ml-agents/Runtime/Integrations/Match3/Match3ActuatorComponent.cs
  35. 4
      com.unity.ml-agents/Runtime/Integrations/Match3/Match3SensorComponent.cs
  36. 6
      com.unity.ml-agents/Runtime/Academy.cs
  37. 2
      ml-agents-envs/README.md
  38. 4
      ml-agents-envs/mlagents_envs/__init__.py
  39. 8
      docs/Installation-Anaconda-Windows.md
  40. 8
      docs/Installation.md
  41. 2
      docs/Training-on-Amazon-Web-Service.md
  42. 2
      docs/Training-on-Microsoft-Azure.md
  43. 4
      docs/Unity-Inference-Engine.md
  44. 19
      docs/Learning-Environment-Design-Agents.md
  45. 32
      docs/Migrating.md
  46. 2
      ml-agents/setup.py
  47. 2
      ml-agents/README.md
  48. 1
      ml-agents/mlagents/plugins/stats_writer.py
  49. 15
      ml-agents/mlagents/trainers/stats.py
  50. 4
      ml-agents/mlagents/trainers/__init__.py
  51. 11
      ml-agents/mlagents/trainers/torch/networks.py
  52. 35
      ml-agents/mlagents/trainers/settings.py
  53. 25
      ml-agents/mlagents/trainers/tests/test_stats.py
  54. 35
      ml-agents/mlagents/trainers/tests/test_settings.py
  55. 2
      ml-agents/mlagents/trainers/tests/test_trainer_util.py
  56. 1
      ml-agents/mlagents/trainers/trainer/rl_trainer.py
  57. 5
      ml-agents/mlagents/trainers/trainer/trainer_factory.py
  58. 2
      .yamato/com.unity.ml-agents-coverage.yml
  59. 4
      .yamato/com.unity.ml-agents-test.yml
  60. 76
      com.unity.ml-agents.extensions/Documentation~/CustomGridSensors.md

6
DevProject/Packages/packages-lock.json


{
"dependencies": {
"com.unity.barracuda": {
"version": "1.3.3-preview",
"version": "2.0.0-pre.2",
"depth": 1,
"source": "registry",
"dependencies": {

"depth": 0,
"source": "local",
"dependencies": {
"com.unity.barracuda": "1.3.3-preview",
"com.unity.barracuda": "2.0.0-pre.2",
"com.unity.modules.imageconversion": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0"
}

"depth": 0,
"source": "local",
"dependencies": {
"com.unity.ml-agents": "2.0.0-exp.1",
"com.unity.ml-agents": "2.0.0-pre.2",
"com.unity.modules.physics": "1.0.0"
}
},

1
utils/make_readme_table.py


ReleaseInfo("release_14", "1.8.1", "0.24.1", "March 5, 2021"),
ReleaseInfo("release_15", "1.9.0", "0.25.0", "March 17, 2021"),
ReleaseInfo("release_16", "1.9.1", "0.25.1", "April 13, 2021"),
ReleaseInfo("release_17", "2.0.0", "0.26.0", "April 22, 2021"),
# Verified releases
ReleaseInfo("", "1.0.7", "0.16.1", "March 8, 2021", is_verified=True),
ReleaseInfo("", "1.0.6", "0.16.1", "November 16, 2020", is_verified=True),

2
utils/validate_versions.py


f.write(new_contents)
if csharp_version is not None:
package_version = f"{csharp_version}-exp.1"
package_version = f"{csharp_version}-pre.2"
if csharp_extensions_version is not None:
# since this has never been promoted we need to keep
# it in preview forever or CI will fail

4
gym-unity/gym_unity/__init__.py


# Version of the library that will be used to upload to pypi
__version__ = "0.26.0.dev0"
__version__ = "0.26.0"
__release_tag__ = None
__release_tag__ = "release_17"

9
gym-unity/gym_unity/envs/__init__.py


import itertools
import numpy as np
from typing import Any, Dict, List, Tuple, Union
from typing import Any, Dict, List, Optional, Tuple, Union
import gym
from gym import error, spaces

uint8_visual: bool = False,
flatten_branched: bool = False,
allow_multiple_obs: bool = False,
action_space_seed: Optional[int] = None,
):
"""
Environment initialization

containing the visual observations and the last element containing the array of vector observations.
If False, returns a single np.ndarray containing either only a single visual observation or the array of
vector observations.
:param action_space_seed: If non-None, will be used to set the random seed on created gym.Space instances.
"""
self._env = unity_env

"The gym wrapper does not provide explicit support for both discrete "
"and continuous actions."
)
if action_space_seed is not None:
self._action_space.seed(action_space_seed)
# Set observations space
list_spaces: List[gym.Space] = []

return -float("inf"), float("inf")
@property
def action_space(self):
def action_space(self) -> gym.Space:
return self._action_space
@property

21
gym-unity/gym_unity/tests/test_gym.py


mock_env, mock_spec, mock_decision_step, mock_terminal_step
)
env = UnityToGymWrapper(mock_env)
assert isinstance(env, UnityToGymWrapper)
assert isinstance(env.reset(), np.ndarray)
actions = env.action_space.sample()
assert actions.shape[0] == 2

assert env.action_space.n == 5
def test_action_space_seed():
mock_env = mock.MagicMock()
mock_spec = create_mock_group_spec()
mock_decision_step, mock_terminal_step = create_mock_vector_steps(mock_spec)
setup_mock_unityenvironment(
mock_env, mock_spec, mock_decision_step, mock_terminal_step
)
actions = []
for _ in range(0, 2):
env = UnityToGymWrapper(mock_env, action_space_seed=1337)
env.reset()
actions.append(env.action_space.sample())
assert (actions[0] == actions[1]).all()
@pytest.mark.parametrize("use_uint8", [True, False], ids=["float", "uint8"])
def test_gym_wrapper_visual(use_uint8):
mock_env = mock.MagicMock()

env = UnityToGymWrapper(mock_env, uint8_visual=use_uint8)
assert isinstance(env.observation_space, spaces.Box)
assert isinstance(env, UnityToGymWrapper)
assert isinstance(env.reset(), np.ndarray)
actions = env.action_space.sample()
assert actions.shape[0] == 2

)
env = UnityToGymWrapper(mock_env, uint8_visual=use_uint8, allow_multiple_obs=True)
assert isinstance(env, UnityToGymWrapper)
assert isinstance(env.observation_space, spaces.Tuple)
assert len(env.observation_space) == 2
reset_obs = env.reset()

# check behavior for allow_multiple_obs = False
env = UnityToGymWrapper(mock_env, uint8_visual=use_uint8, allow_multiple_obs=False)
assert isinstance(env, UnityToGymWrapper)
assert isinstance(env.observation_space, spaces.Box)
reset_obs = env.reset()
assert isinstance(reset_obs, np.ndarray)

)
env = UnityToGymWrapper(mock_env, uint8_visual=use_uint8, allow_multiple_obs=True)
assert isinstance(env, UnityToGymWrapper)
assert isinstance(env.observation_space, spaces.Tuple)
assert len(env.observation_space) == 3
reset_obs = env.reset()

# check behavior for allow_multiple_obs = False
env = UnityToGymWrapper(mock_env, uint8_visual=use_uint8, allow_multiple_obs=False)
assert isinstance(env, UnityToGymWrapper)
assert isinstance(env.observation_space, spaces.Box)
reset_obs = env.reset()
assert isinstance(reset_obs, np.ndarray)

8
Project/Assets/ML-Agents/Examples/Soccer/Prefabs/SoccerFieldTwos.prefab


agentParameters:
maxStep: 0
hasUpgradedFromAgentParameters: 1
MaxStep: 3000
MaxStep: 0
team: 0
position: 2
agentRb: {fileID: 0}

agentParameters:
maxStep: 0
hasUpgradedFromAgentParameters: 1
MaxStep: 3000
MaxStep: 0
team: 1
position: 2
agentRb: {fileID: 0}

agentParameters:
maxStep: 0
hasUpgradedFromAgentParameters: 1
MaxStep: 3000
MaxStep: 0
team: 0
position: 2
agentRb: {fileID: 0}

agentParameters:
maxStep: 0
hasUpgradedFromAgentParameters: 1
MaxStep: 3000
MaxStep: 0
team: 1
position: 2
agentRb: {fileID: 0}

6
Project/Assets/ML-Agents/Examples/Soccer/Prefabs/StrikersVsGoalieField.prefab


agentParameters:
maxStep: 0
hasUpgradedFromAgentParameters: 1
MaxStep: 3000
MaxStep: 0
team: 0
position: 1
agentRb: {fileID: 0}

agentParameters:
maxStep: 0
hasUpgradedFromAgentParameters: 1
MaxStep: 3000
MaxStep: 0
team: 1
position: 0
agentRb: {fileID: 0}

agentParameters:
maxStep: 0
hasUpgradedFromAgentParameters: 1
MaxStep: 3000
MaxStep: 0
team: 1
position: 0
agentRb: {fileID: 0}

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


// The attached Agent
Agent m_Agent;
// Whether or not the commandline args have already been processed.
// Used to make sure that HasOverrides doesn't spam the logs if it's called multiple times.
private bool m_HaveProcessedCommandLine;
string m_BehaviorNameOverrideDirectory;
private List<string> m_OverrideExtensions = new List<string>();

/// <summary>
/// Get the asset path to use from the commandline arguments.
/// Can be called multiple times - if m_HaveProcessedCommandLine is set, will have no effect.
if (m_HaveProcessedCommandLine)
{
return;
}
var maxEpisodes = 0;
var timeoutSeconds = 0;

{
m_Deadline = DateTime.Now + TimeSpan.FromSeconds(timeoutSeconds);
Debug.Log($"setting deadline to {timeoutSeconds} from now.");
}
}
m_HaveProcessedCommandLine = true;
}
void OnEnable()

4
Project/Assets/ML-Agents/Examples/Match3/Scripts/Match3Drawer.cs


if (!m_Board)
{
m_Board = GetComponent<Match3Board>();
if (m_Board == null)
{
return;
}
}
var currentSize = m_Board.GetCurrentBoardSize();

6
Project/Assets/ML-Agents/Examples/Match3/Scripts/Match3Agent.cs


State m_CurrentState = State.WaitForMove;
float m_TimeUntilMove;
private int m_MovesMade;
private ModelOverrider m_ModelOverrider;
m_ModelOverrider = GetComponent<ModelOverrider>();
}
public override void OnEpisodeBegin()

private void FixedUpdate()
{
if (Academy.Instance.IsCommunicatorOn)
// Make a move every step if we're training, or we're overriding models in CI.
var useFast = Academy.Instance.IsCommunicatorOn || (m_ModelOverrider != null && m_ModelOverrider.HasOverrides);
if (useFast)
{
FastUpdate();
}

136
Project/Assets/ML-Agents/Examples/FoodCollector/Prefabs/VisualFoodCollectorArea.prefab


m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:

m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0

m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:

m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0

m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:

m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0

m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:

m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0

m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:

m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0

m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:

m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0

- component: {fileID: 114380897261200276}
- component: {fileID: 114326390494230518}
- component: {fileID: 4034342608499629224}
- component: {fileID: 3681854374749311046}
m_Layer: 0
m_Name: Agent (3)
m_TagString: agent

m_Width: 84
m_Height: 84
m_Grayscale: 0
m_ObservationType: 0
m_ObservationStacks: 1
m_Compression: 1
--- !u!114 &4034342608499629224

m_EditorClassIdentifier:
DecisionPeriod: 5
TakeActionsBetweenDecisions: 1
--- !u!114 &3681854374749311046
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1165679820726490}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3a6da8f78a394c6ab027688eab81e04d, type: 3}
m_Name:
m_EditorClassIdentifier:
debugCommandLineOverride:
--- !u!1 &1179319070824364
GameObject:
m_ObjectHideFlags: 0

m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:

m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0

m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:

m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0

m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:

m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0

m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:

m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0

m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:

m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0

- component: {fileID: 114869844339180154}
- component: {fileID: 114429222608880102}
- component: {fileID: 7234640249101665162}
- component: {fileID: 3300832746663767942}
m_Layer: 0
m_Name: Agent (1)
m_TagString: agent

m_Width: 84
m_Height: 84
m_Grayscale: 0
m_ObservationType: 0
m_ObservationStacks: 1
m_Compression: 1
--- !u!114 &7234640249101665162

m_EditorClassIdentifier:
DecisionPeriod: 5
TakeActionsBetweenDecisions: 1
--- !u!114 &3300832746663767942
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1317136368302180}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3a6da8f78a394c6ab027688eab81e04d, type: 3}
m_Name:
m_EditorClassIdentifier:
debugCommandLineOverride:
--- !u!1 &1353209702154624
GameObject:
m_ObjectHideFlags: 0

m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:

m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0

m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:

m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0

m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:

m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0

- component: {fileID: 114484596947519388}
- component: {fileID: 114036270357198286}
- component: {fileID: 3164735207755090463}
- component: {fileID: 8027755491947001153}
m_Layer: 0
m_Name: Agent
m_TagString: agent

m_Width: 84
m_Height: 84
m_Grayscale: 0
m_ObservationType: 0
m_ObservationStacks: 1
m_Compression: 1
--- !u!114 &3164735207755090463

m_EditorClassIdentifier:
DecisionPeriod: 5
TakeActionsBetweenDecisions: 1
--- !u!114 &8027755491947001153
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1373801553976666}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3a6da8f78a394c6ab027688eab81e04d, type: 3}
m_Name:
m_EditorClassIdentifier:
debugCommandLineOverride:
--- !u!1 &1399553220224106
GameObject:
m_ObjectHideFlags: 0

m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:

m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0

m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:

m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0

m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:

m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0

m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:

m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0

m_ClearFlags: 2
m_BackGroundColor: {r: 0.46666667, g: 0.5647059, b: 0.60784316, a: 1}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_GateFitMode: 2
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2

m_ClearFlags: 2
m_BackGroundColor: {r: 0.46666667, g: 0.5647059, b: 0.60784316, a: 1}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_GateFitMode: 2
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2

m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:

m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0

m_ClearFlags: 2
m_BackGroundColor: {r: 0.46666667, g: 0.5647059, b: 0.60784316, a: 1}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_GateFitMode: 2
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2

m_ClearFlags: 2
m_BackGroundColor: {r: 0.46666667, g: 0.5647059, b: 0.60784316, a: 1}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_GateFitMode: 2
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2

m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:

m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0

m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:

m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0

m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:

m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0

m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:

m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0

m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:

m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0

m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:

m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0

m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:

m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0

m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:

m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0

m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:

m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0

m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:

m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0

- component: {fileID: 114729119221978826}
- component: {fileID: 114322691115031348}
- component: {fileID: 5903164052970896384}
- component: {fileID: 7317454953167631695}
m_Layer: 0
m_Name: Agent (2)
m_TagString: agent

m_Width: 84
m_Height: 84
m_Grayscale: 0
m_ObservationType: 0
m_ObservationStacks: 1
m_Compression: 1
--- !u!114 &5903164052970896384

m_EditorClassIdentifier:
DecisionPeriod: 5
TakeActionsBetweenDecisions: 1
--- !u!114 &7317454953167631695
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1939112378710628}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3a6da8f78a394c6ab027688eab81e04d, type: 3}
m_Name:
m_EditorClassIdentifier:
debugCommandLineOverride:
--- !u!1 &1971119195936814
GameObject:
m_ObjectHideFlags: 0

m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:

m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0

m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 3
serializedVersion: 4
m_CookingOptions: 14
m_CookingOptions: 30
m_Mesh: {fileID: 4300000, guid: a9d8f499f5b9848438d280dc28b3b52e, type: 3}

54
Project/Assets/ML-Agents/Examples/PushBlock/Prefabs/PushBlockCollabAreaGrid.prefab


m_Modification:
m_TransformParent: {fileID: 8188317207052398481}
m_Modifications:
- target: {fileID: 1548337883655231979, guid: ac01d0f42c5e1463e943632a60d99967,
type: 3}
propertyPath: m_RootReference
value:
objectReference: {fileID: 8190299122290044757}
- target: {fileID: 1548337883655231979, guid: ac01d0f42c5e1463e943632a60d99967,
type: 3}
propertyPath: m_AgentGameObject
value:
objectReference: {fileID: 8190299122290044757}
- target: {fileID: 2598450485826216109, guid: ac01d0f42c5e1463e943632a60d99967,
type: 3}
propertyPath: m_Model

type: 3}
m_PrefabInstance: {fileID: 6067781793364901444}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_GameObject: {fileID: 8190299122290044757}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d94a85eca2e074578943301959c555ba, type: 3}

type: 3}
m_PrefabInstance: {fileID: 6067781793364901444}
m_PrefabAsset: {fileID: 0}
--- !u!1 &8190299122290044757 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 2710286047221272849, guid: ac01d0f42c5e1463e943632a60d99967,
type: 3}
m_PrefabInstance: {fileID: 6067781793364901444}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &6565363751102736699
PrefabInstance:
m_ObjectHideFlags: 0

m_Modifications:
- target: {fileID: 1548337883655231979, guid: ac01d0f42c5e1463e943632a60d99967,
type: 3}
propertyPath: m_RootReference
value:
objectReference: {fileID: 9115291448867436586}
- target: {fileID: 1548337883655231979, guid: ac01d0f42c5e1463e943632a60d99967,
type: 3}
propertyPath: m_AgentGameObject
value:
objectReference: {fileID: 9115291448867436586}
- target: {fileID: 2598450485826216109, guid: ac01d0f42c5e1463e943632a60d99967,
type: 3}
propertyPath: m_Model

type: 3}
m_PrefabInstance: {fileID: 6565363751102736699}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_GameObject: {fileID: 9115291448867436586}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d94a85eca2e074578943301959c555ba, type: 3}

type: 3}
m_PrefabInstance: {fileID: 6565363751102736699}
m_PrefabAsset: {fileID: 0}
--- !u!1 &9115291448867436586 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 2710286047221272849, guid: ac01d0f42c5e1463e943632a60d99967,
type: 3}
m_PrefabInstance: {fileID: 6565363751102736699}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &6716844123244810954
PrefabInstance:
m_ObjectHideFlags: 0

m_Modifications:
- target: {fileID: 1548337883655231979, guid: ac01d0f42c5e1463e943632a60d99967,
type: 3}
propertyPath: m_RootReference
value:
objectReference: {fileID: 8695281997955662811}
- target: {fileID: 1548337883655231979, guid: ac01d0f42c5e1463e943632a60d99967,
type: 3}
propertyPath: m_AgentGameObject
value:
objectReference: {fileID: 8695281997955662811}
- target: {fileID: 2598450485826216109, guid: ac01d0f42c5e1463e943632a60d99967,
type: 3}
propertyPath: m_Model

type: 3}
m_PrefabInstance: {fileID: 6716844123244810954}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_GameObject: {fileID: 8695281997955662811}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d94a85eca2e074578943301959c555ba, type: 3}

type: 3}
m_PrefabInstance: {fileID: 6716844123244810954}
m_PrefabAsset: {fileID: 0}
--- !u!1 &8695281997955662811 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 2710286047221272849, guid: ac01d0f42c5e1463e943632a60d99967,
type: 3}
m_PrefabInstance: {fileID: 6716844123244810954}
m_PrefabAsset: {fileID: 0}

5
Project/Assets/ML-Agents/Examples/PushBlock/Scenes/PushBlockCollab.unity


m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 4704531522807670703, guid: f5bbed44a6ea747a687fbbb738eb1730,
type: 3}
propertyPath: m_ShowGizmos
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8188317207052398481, guid: f5bbed44a6ea747a687fbbb738eb1730,
type: 3}
propertyPath: m_RootOrder

6
Project/Packages/packages-lock.json


{
"dependencies": {
"com.unity.barracuda": {
"version": "1.3.3-preview",
"version": "1.4.0-preview",
"depth": 1,
"source": "registry",
"dependencies": {

"depth": 0,
"source": "local",
"dependencies": {
"com.unity.barracuda": "1.3.3-preview",
"com.unity.barracuda": "1.4.0-preview",
"com.unity.modules.imageconversion": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0"
}

"depth": 0,
"source": "local",
"dependencies": {
"com.unity.ml-agents": "2.0.0-exp.1",
"com.unity.ml-agents": "2.0.0-pre.2",
"com.unity.modules.physics": "1.0.0"
}
},

12
README.md


# Unity ML-Agents Toolkit
[![docs badge](https://img.shields.io/badge/docs-reference-blue.svg)](https://github.com/Unity-Technologies/ml-agents/tree/release_16_docs/docs/)
[![docs badge](https://img.shields.io/badge/docs-reference-blue.svg)](https://github.com/Unity-Technologies/ml-agents/tree/release_17_docs/docs/)
[![license badge](https://img.shields.io/badge/license-Apache--2.0-green.svg)](LICENSE)

## Releases & Documentation
**Our latest, stable release is `Release 16`. Click
[here](https://github.com/Unity-Technologies/ml-agents/tree/release_16_docs/docs/Readme.md)
**Our latest, stable release is `Release 17`. Click
[here](https://github.com/Unity-Technologies/ml-agents/tree/release_17_docs/docs/Readme.md)
to get started with the latest release of ML-Agents.**
The table below lists all our releases, including our `main` branch which is

| **Version** | **Release Date** | **Source** | **Documentation** | **Download** | **Python Package** | **Unity Package** |
|:-------:|:------:|:-------------:|:-------:|:------------:|:------------:|:------------:|
| **main (unstable)** | -- | [source](https://github.com/Unity-Technologies/ml-agents/tree/main) | [docs](https://github.com/Unity-Technologies/ml-agents/tree/main/docs/Readme.md) | [download](https://github.com/Unity-Technologies/ml-agents/archive/main.zip) | -- | -- |
| **Release 16** | **April 13, 2021** | **[source](https://github.com/Unity-Technologies/ml-agents/tree/release_16)** | **[docs](https://github.com/Unity-Technologies/ml-agents/tree/release_16_docs/docs/Readme.md)** | **[download](https://github.com/Unity-Technologies/ml-agents/archive/release_16.zip)** | **[0.25.1](https://pypi.org/project/mlagents/0.25.1/)** | **[1.9.1](https://docs.unity3d.com/Packages/com.unity.ml-agents@1.9/manual/index.html)** |
| **Release 17** | **April 22, 2021** | **[source](https://github.com/Unity-Technologies/ml-agents/tree/release_17)** | **[docs](https://github.com/Unity-Technologies/ml-agents/tree/release_17_docs/docs/Readme.md)** | **[download](https://github.com/Unity-Technologies/ml-agents/archive/release_17.zip)** | **[0.26.0](https://pypi.org/project/mlagents/0.26.0/)** | **[2.0.0](https://docs.unity3d.com/Packages/com.unity.ml-agents@2.0/manual/index.html)** |
| **Release 16** | April 13, 2021 | [source](https://github.com/Unity-Technologies/ml-agents/tree/release_16) | [docs](https://github.com/Unity-Technologies/ml-agents/tree/release_16_docs/docs/Readme.md) | [download](https://github.com/Unity-Technologies/ml-agents/archive/release_16.zip) | [0.25.1](https://pypi.org/project/mlagents/0.25.1/) | [1.9.1](https://docs.unity3d.com/Packages/com.unity.ml-agents@1.9/manual/index.html) |
| **Release 15** | March 17, 2021 | [source](https://github.com/Unity-Technologies/ml-agents/tree/release_15) | [docs](https://github.com/Unity-Technologies/ml-agents/tree/release_15_docs/docs/Readme.md) | [download](https://github.com/Unity-Technologies/ml-agents/archive/release_15.zip) | [0.25.0](https://pypi.org/project/mlagents/0.25.0/) | [1.9.0](https://docs.unity3d.com/Packages/com.unity.ml-agents@1.9/manual/index.html) |
| **Verified Package 1.0.7** | **March 8, 2021** | **[source](https://github.com/Unity-Technologies/ml-agents/tree/com.unity.ml-agents_1.0.7)** | **[docs](https://github.com/Unity-Technologies/ml-agents/blob/release_2_verified_docs/docs/Readme.md)** | **[download](https://github.com/Unity-Technologies/ml-agents/archive/com.unity.ml-agents_1.0.7.zip)** | **[0.16.1](https://pypi.org/project/mlagents/0.16.1/)** | **[1.0.7](https://docs.unity3d.com/Packages/com.unity.ml-agents@1.0/manual/index.html)** |
| **Release 14** | March 5, 2021 | [source](https://github.com/Unity-Technologies/ml-agents/tree/release_14) | [docs](https://github.com/Unity-Technologies/ml-agents/tree/release_14_docs/docs/Readme.md) | [download](https://github.com/Unity-Technologies/ml-agents/archive/release_14.zip) | [0.24.1](https://pypi.org/project/mlagents/0.24.1/) | [1.8.1](https://docs.unity3d.com/Packages/com.unity.ml-agents@1.8/manual/index.html) |

| **Release 10** | November 18, 2020 | [source](https://github.com/Unity-Technologies/ml-agents/tree/release_10) | [docs](https://github.com/Unity-Technologies/ml-agents/tree/release_10_docs/docs/Readme.md) | [download](https://github.com/Unity-Technologies/ml-agents/archive/release_10.zip) | [0.22.0](https://pypi.org/project/mlagents/0.22.0/) | [1.6.0](https://docs.unity3d.com/Packages/com.unity.ml-agents@1.6/manual/index.html) |
| **Verified Package 1.0.6** | November 16, 2020 | [source](https://github.com/Unity-Technologies/ml-agents/tree/com.unity.ml-agents_1.0.6) | [docs](https://github.com/Unity-Technologies/ml-agents/blob/release_2_verified_docs/docs/Readme.md) | [download](https://github.com/Unity-Technologies/ml-agents/archive/com.unity.ml-agents_1.0.6.zip) | [0.16.1](https://pypi.org/project/mlagents/0.16.1/) | [1.0.6](https://docs.unity3d.com/Packages/com.unity.ml-agents@1.0/manual/index.html) |
If you are a researcher interested in a discussion of Unity as an AI platform,
see a pre-print of our

13
com.unity.ml-agents.extensions/Documentation~/com.unity.ml-agents.extensions.md


The Runtime directory currently contains these features:
* Physics-based sensors
* [Input System Package Integration](InputActuatorComponent.md)
* [Custom Grid-based Sensors](CustomGridSensors.md)
## Installation
The ML-Agents Extensions package is not currently available in the Package Manager. There are two

[Clone the repository](https://github.com/Unity-Technologies/ml-agents/tree/release_16_docs/docs/Installation.md#clone-the-ml-agents-toolkit-repository-optional) and follow the
[Local Installation for Development](https://github.com/Unity-Technologies/ml-agents/tree/release_16_docs/docs/Installation.md#advanced-local-installation-for-development-1)
[Clone the repository](https://github.com/Unity-Technologies/ml-agents/tree/release_17_docs/docs/Installation.md#clone-the-ml-agents-toolkit-repository-optional) and follow the
[Local Installation for Development](https://github.com/Unity-Technologies/ml-agents/tree/release_17_docs/docs/Installation.md#advanced-local-installation-for-development-1)
![Package Manager git URL](https://github.com/Unity-Technologies/ml-agents/blob/release_16_docs/docs/images/unity_package_manager_git_url.png)
![Package Manager git URL](https://github.com/Unity-Technologies/ml-agents/blob/release_17_docs/docs/images/unity_package_manager_git_url.png)
git+https://github.com/Unity-Technologies/ml-agents.git?path=com.unity.ml-agents.extensions#release_16
git+https://github.com/Unity-Technologies/ml-agents.git?path=com.unity.ml-agents.extensions#release_17
"com.unity.ml-agents.extensions": "git+https://github.com/Unity-Technologies/ml-agents.git?path=com.unity.ml-agents.extensions#release_16",
"com.unity.ml-agents.extensions": "git+https://github.com/Unity-Technologies/ml-agents.git?path=com.unity.ml-agents.extensions#release_17",
```
See [Git dependencies](https://docs.unity3d.com/Manual/upm-git.html#subfolder) for more information. Note that this
may take several minutes to resolve the packages the first time that you add it.

- No way to customize the action space of the `InputActuatorComponent`
## Need Help?
The main [README](https://github.com/Unity-Technologies/ml-agents/tree/release_16_docs/README.md) contains links for contacting the team or getting support.
The main [README](https://github.com/Unity-Technologies/ml-agents/tree/release_17_docs/README.md) contains links for contacting the team or getting support.

4
com.unity.ml-agents.extensions/package.json


{
"name": "com.unity.ml-agents.extensions",
"displayName": "ML Agents Extensions",
"version": "0.3.1-preview",
"version": "0.4.0-preview",
"com.unity.ml-agents": "2.0.0-exp.1",
"com.unity.ml-agents": "2.0.0-pre.2",
"com.unity.modules.physics": "1.0.0"
}
}

4
com.unity.ml-agents/package.json


{
"name": "com.unity.ml-agents",
"displayName": "ML Agents",
"version": "2.0.0-exp.1",
"version": "2.0.0-pre.2",
"com.unity.barracuda": "1.3.3-preview",
"com.unity.barracuda": "2.0.0-pre.2",
"com.unity.modules.imageconversion": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0"
}

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


and this project adheres to
[Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [2.0.0-exp.1] - 2021-04-22
## [2.0.0-pre.2] - 2021-04-22
[Migration Guide](https://github.com/Unity-Technologies/ml-agents/blob/release_14_docs/docs/Migrating.md) for more
[Migration Guide](https://github.com/Unity-Technologies/ml-agents/blob/release_17_docs/docs/Migrating.md) for more
details.
- Some methods previously marked as `Obsolete` have been removed. If you were using these methods, you need to replace them with their supported counterpart.
- The interface for disabling discrete actions in `IDiscreteActionMask` has changed.

sizes and will need to be retrained. (#5181)
- The `AbstractBoard` class for integration with Match-3 games was changed to make it easier to support boards with
different sizes using the same model. For a summary of the interface changes, please see the Migration Guide. (##5189)
- Updated the Barracuda package to version `1.3.3-preview`(#5236)
- Updated the Barracuda package to version `1.4.0-preview`(#5236)
- `GridSensor` has been refactored and moved to main package, with changes to both sensor interfaces and behaviors.
Exsisting GridSensor created by extension package will not work in newer version. Previously trained models will
need to be retrained. Please see the Migration Guide for more details. (#5256)

#### ml-agents / ml-agents-envs / gym-unity (Python)
- Some console output have been moved from `info` to `debug` and will not be printed by default. If you want all messages to be printed, you can run `mlagents-learn` with the `--debug` option or add the line `debug: true` at the top of the yaml config file. (#5211)
- When using a configuration YAML, it is required to define all behaviors found in a Unity
executable in the trainer configuration YAML, or specify `default_settings`. (#5210)
- The embedding size of attention layers used when a BufferSensor is in the scene has been changed. It is now fixed to 128 units. It might be impossible to resume training from a checkpoint of a previous version. (#5272)
### Bug Fixes

#### ml-agents / ml-agents-envs / gym-unity (Python)
- Fixed a bug where --results-dir has no effect. (#5269)
- Fixed a bug where old `.pt` checkpoints were not deleted during training. (#5271)
- The `UnityToGymWrapper` initializer now accepts an optional `action_space_seed` seed. If this is specified, it will
be used to set the random seed on the resulting action space. (#5303)
## [1.9.1-preview] - 2021-04-13
### Major Changes

14
com.unity.ml-agents/Documentation~/com.unity.ml-agents.md


In Unity 2019.4 or later, open the Package Manager, hit the "+" button, and select "Add package from git URL".
![Package Manager git URL](https://github.com/Unity-Technologies/ml-agents/blob/release_16_docs/docs/images/unity_package_manager_git_url.png)
![Package Manager git URL](https://github.com/Unity-Technologies/ml-agents/blob/release_17_docs/docs/images/unity_package_manager_git_url.png)
git+https://github.com/Unity-Technologies/ml-agents.git?path=com.unity.ml-agents#release_16
git+https://github.com/Unity-Technologies/ml-agents.git?path=com.unity.ml-agents#release_17
"com.unity.ml-agents": "git+https://github.com/Unity-Technologies/ml-agents.git?path=com.unity.ml-agents#release_16",
"com.unity.ml-agents": "git+https://github.com/Unity-Technologies/ml-agents.git?path=com.unity.ml-agents#release_17",
```
See [Git dependencies](https://docs.unity3d.com/Manual/upm-git.html#subfolder) for more information. Note that this
may take several minutes to resolve the packages the first time that you add it.

[Clone the repository](https://github.com/Unity-Technologies/ml-agents/tree/release_16_docs/docs/Installation.md#clone-the-ml-agents-toolkit-repository-optional) and follow the
[Local Installation for Development](https://github.com/Unity-Technologies/ml-agents/tree/release_16_docs/docs/Installation.md#advanced-local-installation-for-development-1)
[Clone the repository](https://github.com/Unity-Technologies/ml-agents/tree/release_17_docs/docs/Installation.md#clone-the-ml-agents-toolkit-repository-optional) and follow the
[Local Installation for Development](https://github.com/Unity-Technologies/ml-agents/tree/release_17_docs/docs/Installation.md#advanced-local-installation-for-development-1)
directions.
## Requirements

[unity ML-Agents Toolkit]: https://github.com/Unity-Technologies/ml-agents
[unity inference engine]: https://docs.unity3d.com/Packages/com.unity.barracuda@latest/index.html
[package manager documentation]: https://docs.unity3d.com/Manual/upm-ui-install.html
[installation instructions]: https://github.com/Unity-Technologies/ml-agents/blob/release_16_docs/docs/Installation.md
[installation instructions]: https://github.com/Unity-Technologies/ml-agents/blob/release_17_docs/docs/Installation.md
[ML-Agents GitHub repo]: https://github.com/Unity-Technologies/ml-agents/blob/release_16_docs/com.unity.ml-agents.extensions
[ML-Agents GitHub repo]: https://github.com/Unity-Technologies/ml-agents/blob/release_17_docs/com.unity.ml-agents.extensions

8
com.unity.ml-agents/Editor/Match3ActuatorComponentEditor.cs


var so = serializedObject;
so.Update();
var component = (Match3ActuatorComponent)target;
var board = component.GetComponent<AbstractBoard>();
if (board == null)
{
EditorGUILayout.HelpBox("You must provide an implementation of an AbstractBoard.", MessageType.Warning);
return;
}
// Drawing the RenderTextureComponent
EditorGUI.BeginChangeCheck();

8
com.unity.ml-agents/Editor/Match3SensorComponentEditor.cs


var so = serializedObject;
so.Update();
var component = (Match3SensorComponent)target;
var board = component.GetComponent<AbstractBoard>();
if (board == null)
{
EditorGUILayout.HelpBox("You must provide an implementation of an AbstractBoard.", MessageType.Warning);
return;
}
// Drawing the RenderTextureComponent
EditorGUI.BeginChangeCheck();

1
com.unity.ml-agents/Editor/GridSensorComponentEditor.cs


gridSize.vector3IntValue = new Vector3Int(newGridSize.x, 1, newGridSize.z);
}
EditorGUI.EndDisabledGroup();
EditorGUILayout.PropertyField(so.FindProperty(nameof(GridSensorComponent.m_AgentGameObject)), true);
EditorGUILayout.PropertyField(so.FindProperty(nameof(GridSensorComponent.m_RotateWithAgent)), true);
EditorGUI.BeginDisabledGroup(!EditorUtilities.CanUpdateModelProperties());

9
com.unity.ml-agents/Tests/Editor/Integrations/Match3/Match3ActuatorTests.cs


// And they should add up to all the potential moves
Assert.AreEqual(validIndices.Count + masks.HashSets[0].Count, board.NumMoves());
}
[Test]
public void TestNoBoardReturnsEmptyActuators()
{
var gameObj = new GameObject("board");
var actuatorComponent = gameObj.AddComponent<Match3ActuatorComponent>();
var actuators = actuatorComponent.CreateActuators();
Assert.AreEqual(0, actuators.Length);
}
}
}

9
com.unity.ml-agents/Tests/Editor/Integrations/Match3/Match3SensorTests.cs


return bytesOut.ToArray();
}
[Test]
public void TestNoBoardReturnsEmptySensors()
{
var gameObj = new GameObject("board");
var sensorComponent = gameObj.AddComponent<Match3SensorComponent>();
var sensors = sensorComponent.CreateSensors();
Assert.AreEqual(0, sensors.Length);
}
}
}

28
com.unity.ml-agents/Tests/Runtime/Sensor/BoxOverlapCheckerTests.cs


Vector3Int gridSize,
bool rotateWithAgent,
LayerMask colliderMask,
GameObject rootReference,
GameObject centerObject,
GameObject agentGameObject,
string[] detectableTags,
int initialColliderBufferSize,
int maxColliderBufferSize

rotateWithAgent,
colliderMask,
rootReference,
centerObject,
agentGameObject,
detectableTags,
initialColliderBufferSize,
maxColliderBufferSize)

int gridSizeX = 10,
int gridSizeZ = 10,
bool rotateWithAgent = true,
GameObject rootReference = null,
GameObject centerObject = null,
GameObject agentGameObject = null,
string[] detectableTags = null,
int initialColliderBufferSize = 4,
int maxColliderBufferSize = 500)

new Vector3Int(gridSizeX, 1, gridSizeZ),
rotateWithAgent,
LayerMask.GetMask("Default"),
rootReference,
centerObject,
agentGameObject,
detectableTags,
initialColliderBufferSize,
maxColliderBufferSize);

{
var testGo = new GameObject("test");
testGo.transform.position = Vector3.zero;
var boxOverlapSquare = TestBoxOverlapChecker.CreateChecker(gridSizeX: 10, gridSizeZ: 10, rotateWithAgent: false, rootReference: testGo);
var boxOverlapSquare = TestBoxOverlapChecker.CreateChecker(gridSizeX: 10, gridSizeZ: 10, rotateWithAgent: false, agentGameObject: testGo);
var localPos = boxOverlapSquare.CellLocalPositions;
Assert.AreEqual(new Vector3(-4.5f, 0, -4.5f), localPos[0]);

var testGo2 = new GameObject("test");
testGo2.transform.position = new Vector3(3.5f, 8f, 17f); // random, should have no effect on local positions
var boxOverlapRect = TestBoxOverlapChecker.CreateChecker(gridSizeX: 5, gridSizeZ: 15, rotateWithAgent: true, rootReference: testGo);
var boxOverlapRect = TestBoxOverlapChecker.CreateChecker(gridSizeX: 5, gridSizeZ: 15, rotateWithAgent: true, agentGameObject: testGo);
localPos = boxOverlapRect.CellLocalPositions;
Assert.AreEqual(new Vector3(-2f, 0, -7f), localPos[0]);

var testGo = new GameObject("test");
var position = new Vector3(3.5f, 8f, 17f);
testGo.transform.position = position;
var boxOverlap = TestBoxOverlapChecker.CreateChecker(gridSizeX: 10, gridSizeZ: 10, rotateWithAgent: false, rootReference: testGo);
var boxOverlap = TestBoxOverlapChecker.CreateChecker(gridSizeX: 10, gridSizeZ: 10, rotateWithAgent: false, agentGameObject: testGo, centerObject: testGo);
Assert.AreEqual(new Vector3(-4.5f, 0, -4.5f) + position, boxOverlap.GetCellGlobalPosition(0));
Assert.AreEqual(new Vector3(-4.5f, 0, 4.5f) + position, boxOverlap.GetCellGlobalPosition(9));

var testGo = new GameObject("test");
var position = new Vector3(15f, 6f, 13f);
testGo.transform.position = position;
var boxOverlap = TestBoxOverlapChecker.CreateChecker(gridSizeX: 5, gridSizeZ: 15, rotateWithAgent: true, rootReference: testGo);
var boxOverlap = TestBoxOverlapChecker.CreateChecker(gridSizeX: 5, gridSizeZ: 15, rotateWithAgent: true, agentGameObject: testGo, centerObject: testGo);
Assert.AreEqual(new Vector3(-2f, 0, -7f) + position, boxOverlap.GetCellGlobalPosition(0));
Assert.AreEqual(new Vector3(-2f, 0, 7f) + position, boxOverlap.GetCellGlobalPosition(14));

var testGo = new GameObject("test");
testGo.transform.position = Vector3.zero;
testObjects.Add(testGo);
var boxOverlap = TestBoxOverlapChecker.CreateChecker(rootReference: testGo, initialColliderBufferSize: 2, maxColliderBufferSize: 5);
var boxOverlap = TestBoxOverlapChecker.CreateChecker(agentGameObject: testGo, centerObject: testGo, initialColliderBufferSize: 2, maxColliderBufferSize: 5);
boxOverlap.Update();
Assert.AreEqual(2, boxOverlap.ColliderBuffer.Length);

cellScaleZ: 10f,
gridSizeX: 2,
gridSizeZ: 2,
rootReference: testGo,
agentGameObject: testGo,
centerObject: testGo,
detectableTags: new [] { tag1 });
var helper = new VerifyParseCollidersHelper();
boxOverlap.GridOverlapDetectedClosest += helper.DetectedAction;

cellScaleZ: 10f,
gridSizeX: 2,
gridSizeZ: 2,
rootReference: testGo,
agentGameObject: testGo,
centerObject: testGo,
detectableTags: new [] { tag1 });
var helper = new VerifyParseCollidersHelper();
boxOverlap.GridOverlapDetectedAll += helper.DetectedAction;

2
com.unity.ml-agents/Runtime/Actuators/IActionReceiver.cs


///
/// See [Agents - Actions] for more information on masking actions.
///
/// [Agents - Actions]: https://github.com/Unity-Technologies/ml-agents/blob/release_16_docs/docs/Learning-Environment-Design-Agents.md#actions
/// [Agents - Actions]: https://github.com/Unity-Technologies/ml-agents/blob/release_17_docs/docs/Learning-Environment-Design-Agents.md#actions
/// </remarks>
/// <seealso cref="IActionReceiver.OnActionReceived"/>
void WriteDiscreteActionMask(IDiscreteActionMask actionMask);

2
com.unity.ml-agents/Runtime/Actuators/IDiscreteActionMask.cs


///
/// See [Agents - Actions] for more information on masking actions.
///
/// [Agents - Actions]: https://github.com/Unity-Technologies/ml-agents/blob/release_16_docs/docs/Learning-Environment-Design-Agents.md#actions
/// [Agents - Actions]: https://github.com/Unity-Technologies/ml-agents/blob/release_17_docs/docs/Learning-Environment-Design-Agents.md#actions
/// </remarks>
/// <param name="branch">The branch for which the actions will be masked.</param>
/// <param name="actionIndex">Index of the action</param>

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


/// [OnDisable()]: https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnDisable.html]
/// [OnBeforeSerialize()]: https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnBeforeSerialize.html
/// [OnAfterSerialize()]: https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnAfterSerialize.html
/// [Agents]: https://github.com/Unity-Technologies/ml-agents/blob/release_16_docs/docs/Learning-Environment-Design-Agents.md
/// [Reinforcement Learning in Unity]: https://github.com/Unity-Technologies/ml-agents/blob/release_16_docs/docs/Learning-Environment-Design.md
/// [Agents]: https://github.com/Unity-Technologies/ml-agents/blob/release_17_docs/docs/Learning-Environment-Design-Agents.md
/// [Reinforcement Learning in Unity]: https://github.com/Unity-Technologies/ml-agents/blob/release_17_docs/docs/Learning-Environment-Design.md
/// [Unity ML-Agents Toolkit manual]: https://github.com/Unity-Technologies/ml-agents/blob/release_16_docs/docs/Readme.md
/// [Unity ML-Agents Toolkit manual]: https://github.com/Unity-Technologies/ml-agents/blob/release_17_docs/docs/Readme.md
[HelpURL("https://github.com/Unity-Technologies/ml-agents/blob/release_16_docs/" +
[HelpURL("https://github.com/Unity-Technologies/ml-agents/blob/release_17_docs/" +
"docs/Learning-Environment-Design-Agents.md")]
[Serializable]
[RequireComponent(typeof(BehaviorParameters))]

/// for information about mixing reward signals from curiosity and Generative Adversarial
/// Imitation Learning (GAIL) with rewards supplied through this method.
///
/// [Agents - Rewards]: https://github.com/Unity-Technologies/ml-agents/blob/release_16_docs/docs/Learning-Environment-Design-Agents.md#rewards
/// [Reward Signals]: https://github.com/Unity-Technologies/ml-agents/blob/release_16_docs/docs/ML-Agents-Overview.md#a-quick-note-on-reward-signals
/// [Agents - Rewards]: https://github.com/Unity-Technologies/ml-agents/blob/release_17_docs/docs/Learning-Environment-Design-Agents.md#rewards
/// [Reward Signals]: https://github.com/Unity-Technologies/ml-agents/blob/release_17_docs/docs/ML-Agents-Overview.md#a-quick-note-on-reward-signals
/// </remarks>
/// <param name="reward">The new value of the reward.</param>
public void SetReward(float reward)

/// for information about mixing reward signals from curiosity and Generative Adversarial
/// Imitation Learning (GAIL) with rewards supplied through this method.
///
/// [Agents - Rewards]: https://github.com/Unity-Technologies/ml-agents/blob/release_16_docs/docs/Learning-Environment-Design-Agents.md#rewards
/// [Reward Signals]: https://github.com/Unity-Technologies/ml-agents/blob/release_16_docs/docs/ML-Agents-Overview.md#a-quick-note-on-reward-signals
/// [Agents - Rewards]: https://github.com/Unity-Technologies/ml-agents/blob/release_17_docs/docs/Learning-Environment-Design-Agents.md#rewards
/// [Reward Signals]: https://github.com/Unity-Technologies/ml-agents/blob/release_17_docs/docs/ML-Agents-Overview.md#a-quick-note-on-reward-signals
///</remarks>
/// <param name="increment">Incremental reward value.</param>
public void AddReward(float increment)

/// implementing a simple heuristic function can aid in debugging agent actions and interactions
/// with its environment.
///
/// [Demonstration Recorder]: https://github.com/Unity-Technologies/ml-agents/blob/release_16_docs/docs/Learning-Environment-Design-Agents.md#recording-demonstrations
/// [Actions]: https://github.com/Unity-Technologies/ml-agents/blob/release_16_docs/docs/Learning-Environment-Design-Agents.md#actions
/// [Demonstration Recorder]: https://github.com/Unity-Technologies/ml-agents/blob/release_17_docs/docs/Learning-Environment-Design-Agents.md#recording-demonstrations
/// [Actions]: https://github.com/Unity-Technologies/ml-agents/blob/release_17_docs/docs/Learning-Environment-Design-Agents.md#actions
/// [GameObject]: https://docs.unity3d.com/Manual/GameObjects.html
/// </remarks>
/// <example>

/// For more information about observations, see [Observations and Sensors].
///
/// [GameObject]: https://docs.unity3d.com/Manual/GameObjects.html
/// [Observations and Sensors]: https://github.com/Unity-Technologies/ml-agents/blob/release_16_docs/docs/Learning-Environment-Design-Agents.md#observations-and-sensors
/// [Observations and Sensors]: https://github.com/Unity-Technologies/ml-agents/blob/release_17_docs/docs/Learning-Environment-Design-Agents.md#observations-and-sensors
/// </remarks>
public virtual void CollectObservations(VectorSensor sensor)
{

///
/// See [Agents - Actions] for more information on masking actions.
///
/// [Agents - Actions]: https://github.com/Unity-Technologies/ml-agents/blob/release_16_docs/docs/Learning-Environment-Design-Agents.md#actions
/// [Agents - Actions]: https://github.com/Unity-Technologies/ml-agents/blob/release_17_docs/docs/Learning-Environment-Design-Agents.md#actions
/// </remarks>
/// <seealso cref="IActionReceiver.OnActionReceived"/>
public virtual void WriteDiscreteActionMask(IDiscreteActionMask actionMask) { }

///
/// For more information about implementing agent actions see [Agents - Actions].
///
/// [Agents - Actions]: https://github.com/Unity-Technologies/ml-agents/blob/release_16_docs/docs/Learning-Environment-Design-Agents.md#actions
/// [Agents - Actions]: https://github.com/Unity-Technologies/ml-agents/blob/release_17_docs/docs/Learning-Environment-Design-Agents.md#actions
/// </remarks>
/// <param name="actions">
/// Struct containing the buffers of actions to be executed at this step.

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


/// See [Imitation Learning - Recording Demonstrations] for more information.
///
/// [GameObject]: https://docs.unity3d.com/Manual/GameObjects.html
/// [Imitation Learning - Recording Demonstrations]: https://github.com/Unity-Technologies/ml-agents/blob/release_16_docs/docs//Learning-Environment-Design-Agents.md#recording-demonstrations
/// [Imitation Learning - Recording Demonstrations]: https://github.com/Unity-Technologies/ml-agents/blob/release_17_docs/docs//Learning-Environment-Design-Agents.md#recording-demonstrations
/// </remarks>
[RequireComponent(typeof(Agent))]
[AddComponentMenu("ML Agents/Demonstration Recorder", (int)MenuGroup.Default)]

21
com.unity.ml-agents/Runtime/Sensors/BoxOverlapChecker.cs


Vector3Int m_GridSize;
bool m_RotateWithAgent;
LayerMask m_ColliderMask;
GameObject m_RootReference;
GameObject m_CenterObject;
GameObject m_AgentGameObject;
string[] m_DetectableTags;
int m_InitialColliderBufferSize;
int m_MaxColliderBufferSize;

Vector3Int gridSize,
bool rotateWithAgent,
LayerMask colliderMask,
GameObject rootReference,
GameObject centerObject,
GameObject agentGameObject,
string[] detectableTags,
int initialColliderBufferSize,
int maxColliderBufferSize)

m_RotateWithAgent = rotateWithAgent;
m_ColliderMask = colliderMask;
m_RootReference = rootReference;
m_CenterObject = centerObject;
m_AgentGameObject = agentGameObject;
m_DetectableTags = detectableTags;
m_InitialColliderBufferSize = initialColliderBufferSize;
m_MaxColliderBufferSize = maxColliderBufferSize;

{
if (m_RotateWithAgent)
{
return m_RootReference.transform.TransformPoint(m_CellLocalPositions[cellIndex]);
return m_CenterObject.transform.TransformPoint(m_CellLocalPositions[cellIndex]);
return m_CellLocalPositions[cellIndex] + m_RootReference.transform.position;
return m_CellLocalPositions[cellIndex] + m_CenterObject.transform.position;
return m_RotateWithAgent ? m_RootReference.transform.rotation : Quaternion.identity;
return m_RotateWithAgent ? m_CenterObject.transform.rotation : Quaternion.identity;
}
/// <summary>

var currentColliderGo = foundColliders[i].gameObject;
// Continue if the current collider go is the root reference
if (ReferenceEquals(currentColliderGo, m_RootReference))
if (ReferenceEquals(currentColliderGo, m_AgentGameObject))
var currentDistanceSquared = (closestColliderPoint - m_RootReference.transform.position).sqrMagnitude;
var currentDistanceSquared = (closestColliderPoint - m_CenterObject.transform.position).sqrMagnitude;
if (currentDistanceSquared >= minDistanceSquared)
{

for (int i = 0; i < numFound; i++)
{
var currentColliderGo = foundColliders[i].gameObject;
if (!ReferenceEquals(currentColliderGo, m_RootReference))
if (!ReferenceEquals(currentColliderGo, m_AgentGameObject))
{
detectedAction.Invoke(currentColliderGo, cellIndex);
}

13
com.unity.ml-agents/Runtime/Sensors/GridSensorComponent.cs


}
[HideInInspector, SerializeField]
internal GameObject m_AgentGameObject;
/// <summary>
/// The reference of the root of the agent. This is used to disambiguate objects with
/// the same tag as the agent. Defaults to current GameObject.
/// </summary>
public GameObject AgentGameObject
{
get { return (m_AgentGameObject == null ? gameObject : m_AgentGameObject); }
set { m_AgentGameObject = value; }
}
[HideInInspector, SerializeField]
internal string[] m_DetectableTags;
/// <summary>
/// List of tags that are detected.

m_RotateWithAgent,
m_ColliderMask,
gameObject,
AgentGameObject,
m_DetectableTags,
m_InitialColliderBufferSize,
m_MaxColliderBufferSize

6
com.unity.ml-agents/Runtime/Integrations/Match3/Match3ActuatorComponent.cs


using System;
using Unity.MLAgents.Actuators;
using UnityEngine;
using UnityEngine.Serialization;

public override IActuator[] CreateActuators()
{
var board = GetComponent<AbstractBoard>();
if (!board)
{
return Array.Empty<IActuator>();
}
var seed = m_RandomSeed == -1 ? gameObject.GetInstanceID() : m_RandomSeed + 1;
return new IActuator[] { new Match3Actuator(board, m_ForceHeuristic, seed, m_ActuatorName) };
}

4
com.unity.ml-agents/Runtime/Integrations/Match3/Match3SensorComponent.cs


Dispose();
var board = GetComponent<AbstractBoard>();
if (!board)
{
return Array.Empty<ISensor>();
}
var cellSensor = Match3Sensor.CellTypeSensor(board, m_ObservationType, m_SensorName + " (cells)");
// This can be null if numSpecialTypes is 0
var specialSensor = Match3Sensor.SpecialTypeSensor(board, m_ObservationType, m_SensorName + " (special)");

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


* API. For more information on each of these entities, in addition to how to
* set-up a learning environment and train the behavior of characters in a
* Unity scene, please browse our documentation pages on GitHub:
* https://github.com/Unity-Technologies/ml-agents/tree/release_16_docs/docs/
* https://github.com/Unity-Technologies/ml-agents/tree/release_17_docs/docs/
*/
namespace Unity.MLAgents

/// fall back to inference or heuristic decisions. (You can also set agents to always use
/// inference or heuristics.)
/// </remarks>
[HelpURL("https://github.com/Unity-Technologies/ml-agents/tree/release_16_docs/" +
[HelpURL("https://github.com/Unity-Technologies/ml-agents/tree/release_17_docs/" +
"docs/Learning-Environment-Design.md")]
public class Academy : IDisposable
{

/// 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 = "2.0.0-exp.1";
internal const string k_PackageVersion = "2.0.0-pre.2";
const int k_EditorTrainingPort = 5004;

2
ml-agents-envs/README.md


Install the `mlagents_envs` package with:
```sh
python -m pip install mlagents_envs==0.25.1
python -m pip install mlagents_envs==0.26.0
```
## Usage & More Information

4
ml-agents-envs/mlagents_envs/__init__.py


# Version of the library that will be used to upload to pypi
__version__ = "0.26.0.dev0"
__version__ = "0.26.0"
__release_tag__ = None
__release_tag__ = "release_17"

8
docs/Installation-Anaconda-Windows.md


the ml-agents Conda environment by typing `activate ml-agents`)_:
```sh
git clone --branch release_16 https://github.com/Unity-Technologies/ml-agents.git
git clone --branch release_17 https://github.com/Unity-Technologies/ml-agents.git
The `--branch release_16` option will switch to the tag of the latest stable
The `--branch release_17` option will switch to the tag of the latest stable
release. Omitting that will get the `main` branch which is potentially
unstable.

connected to the Internet and then type in the Anaconda Prompt:
```console
python -m pip install mlagents==0.25.1
python -m pip install mlagents==0.26.0
```
This will complete the installation of all the required Python packages to run

this, you can try:
```console
python -m pip install mlagents==0.25.1 --no-cache-dir
python -m pip install mlagents==0.26.0 --no-cache-dir
```
This `--no-cache-dir` tells the pip to disable the cache.

8
docs/Installation.md


the repository if you would like to explore more examples.
```sh
git clone --branch release_16 https://github.com/Unity-Technologies/ml-agents.git
git clone --branch release_17 https://github.com/Unity-Technologies/ml-agents.git
The `--branch release_16` option will switch to the tag of the latest stable
The `--branch release_17` option will switch to the tag of the latest stable
release. Omitting that will get the `main` branch which is potentially unstable.
#### Advanced: Local Installation for Development

back, make sure to clone the `main` branch (by omitting `--branch release_16`
back, make sure to clone the `main` branch (by omitting `--branch release_17`
from the command above). See our
[Contributions Guidelines](../com.unity.ml-agents/CONTRIBUTING.md) for more
information on contributing to the ML-Agents Toolkit.

run from the command line:
```sh
python -m pip install mlagents==0.25.1
python -m pip install mlagents==0.26.0
```
Note that this will install `mlagents` from PyPi, _not_ from the cloned

2
docs/Training-on-Amazon-Web-Service.md


2. Clone the ML-Agents repo and install the required Python packages
```sh
git clone --branch release_16 https://github.com/Unity-Technologies/ml-agents.git
git clone --branch release_17 https://github.com/Unity-Technologies/ml-agents.git
cd ml-agents/ml-agents/
pip3 install -e .
```

2
docs/Training-on-Microsoft-Azure.md


instance, and set it as the working directory.
2. Install the required packages:
Torch: `pip3 install torch==1.7.0 -f https://download.pytorch.org/whl/torch_stable.html` and
MLAgents: `python -m pip install mlagents==0.25.1`
MLAgents: `python -m pip install mlagents==0.26.0`
## Testing

4
docs/Unity-Inference-Engine.md


loading expects certain conventions for constants and tensor names. While it is
possible to construct a model that follows these conventions, we don't provide
any additional help for this. More details can be found in
[TensorNames.cs](https://github.com/Unity-Technologies/ml-agents/blob/release_16_docs/com.unity.ml-agents/Runtime/Inference/TensorNames.cs)
[TensorNames.cs](https://github.com/Unity-Technologies/ml-agents/blob/release_17_docs/com.unity.ml-agents/Runtime/Inference/TensorNames.cs)
[BarracudaModelParamLoader.cs](https://github.com/Unity-Technologies/ml-agents/blob/release_16_docs/com.unity.ml-agents/Runtime/Inference/BarracudaModelParamLoader.cs).
[BarracudaModelParamLoader.cs](https://github.com/Unity-Technologies/ml-agents/blob/release_17_docs/com.unity.ml-agents/Runtime/Inference/BarracudaModelParamLoader.cs).
If you wish to run inference on an externally trained model, you should use
Barracuda directly, instead of trying to run it through ML-Agents.

19
docs/Learning-Environment-Design-Agents.md


runtime. It must be attached to the same `GameObject` as the `Agent`, or to a
child `GameObject`.
There are several SensorComponents provided in the API:
- `CameraSensorComponent` - Allows image from `Camera` to be used as
observation.
- `RenderTextureSensorComponent` - Allows content of `RenderTexture` to be used
as observation.
- `RayPerceptionSensorComponent` - Allows information from set of ray-casts to
be used as observation.
There are several SensorComponents provided in the API, including:
- `CameraSensorComponent` - Uses images from a `Camera` as observations.
- `RenderTextureSensorComponent` - Uses the content of a `RenderTexture` as
observations.
- `RayPerceptionSensorComponent` - Uses the information from set of ray casts
as observations.
- `Match3SensorComponent` - Uses the board of a [Match-3 game](Integrations-Match3.md)
as observations.
- `GridSensorComponent` - Uses a set of box queries in a grid shape as
observations.
`Behavior Parameters` when using an ISensor SensorComponents.
`Behavior Parameters` when using `SensorComponents`s.
Internally, both `Agent.CollectObservations` and `[Observable]` attribute use an
ISensors to write observations, although this is mostly abstracted from the user.

32
docs/Migrating.md


# Upgrading
## :warning: Warning :warning:
The C# editor code and python trainer code are not compatible between releases.
This means that if you upgrade one, you _must_ upgrade the other as well. If you
experience new errors or unable to connect to training after updating, please
double-check that the versions are in the same. The versions can be found in
- `Academy.k_ApiVersion` in Academy.cs
([example](https://github.com/Unity-Technologies/ml-agents/blob/b255661084cb8f701c716b040693069a3fb9a257/UnitySDK/Assets/ML-Agents/Scripts/Academy.cs#L95))
- `UnityEnvironment.API_VERSION` in environment.py
([example](https://github.com/Unity-Technologies/ml-agents/blob/b255661084cb8f701c716b040693069a3fb9a257/ml-agents-envs/mlagents/envs/environment.py#L45))
# Migrating
## Migrating the package to version 2.0
- The official version of Unity ML-Agents supports is now 2019.4 LTS. If you run

deprecated APIs have been removed. See the migration steps bellow for specific API replacements.
### Deprecated methods removed
| **Deprecated API** | **Suggested Replacement** |
|:-------:|:------:|
| `IActuator ActuatorComponent.CreateActuator()` | `IActuator[] ActuatorComponent.CreateActuators()` |
| `IActionReceiver.PackActions(in float[] destination)` | none |
| `Agent.CollectDiscreteActionMasks(DiscreteActionMasker actionMasker)` | `Agent.WriteDiscreteActionMask(IDiscreteActionMask actionMask)` |
| `Agent.Heuristic(float[] actionsOut)` | `Agent.Heuristic(in ActionBuffers actionsOut)` |
| `Agent.OnActionReceived(float[] vectorAction)` | `Agent.OnActionReceived(ActionBuffers actions)` |
| `Agent.GetAction()` | `Agent.GetStoredActionBuffers()` |
| `BrainParameters.SpaceType`, `VectorActionSize`, `VectorActionSpaceType`, and `NumActions` | `BrainParameters.ActionSpec` |
| `ObservationWriter.AddRange(IEnumerable<float> data, int writeOffset = 0)` | `ObservationWriter. AddList(IList<float> data, int writeOffset = 0` |
| `SensorComponent.IsVisual()` and `IsVector()` | none |
| `VectorSensor.AddObservation(IEnumerable<float> observation)` | `VectorSensor.AddObservation(IList<float> observation)` |
| `SideChannelsManager` | `SideChannelManager` |
### IDiscreteActionMask changes
- The interface for disabling specific discrete actions has changed. `IDiscreteActionMask.WriteMask()` was removed,
and replaced with `SetActionEnabled()`. Instead of returning an IEnumerable with indices to disable, you can

You'll need to remove the old sensor and create a new GridSensor.
* These parameters names have changed but still refer to the same concept in the sensor: `GridNumSide` -> `GridSize`,
`RotateToAgent` -> `RotateWithAgent`, `ObserveMask` -> `ColliderMask`, `DetectableObjects` -> `DetectableTags`
* `RootReference` is removed and the sensor component's GameObject will always be ignored for hit results.
* `DepthType` (`ChanelBase`/`ChannelHot`) option and `ChannelDepth` are removed. Now the default is
one-hot encoding for detected tag. If you were using original GridSensor without overriding any method,
switching to new GridSensor will produce similar effect for training although the actual observations

- The Parameter Randomization feature has been merged with the Curriculum feature. It is now possible to specify a sampler
in the lesson of a Curriculum. Curriculum has been refactored and is now specified at the level of the parameter, not the
behavior. More information
[here](https://github.com/Unity-Technologies/ml-agents/blob/release_16_docs/docs/Training-ML-Agents.md).(#4160)
[here](https://github.com/Unity-Technologies/ml-agents/blob/release_17_docs/docs/Training-ML-Agents.md).(#4160)
### Steps to Migrate
- The configuration format for curriculum and parameter randomization has changed. To upgrade your configuration files,

2
ml-agents/setup.py


"protobuf>=3.6",
"pyyaml>=3.1.0",
# Windows ver. of PyTorch doesn't work from PyPi. Installation:
# https://github.com/Unity-Technologies/ml-agents/blob/release_16_docs/docs/Installation.md#windows-installing-pytorch
# https://github.com/Unity-Technologies/ml-agents/blob/release_17_docs/docs/Installation.md#windows-installing-pytorch
# Torch only working on python 3.9 for 1.8.0 and above. Details see:
# https://github.com/pytorch/pytorch/issues/50014
"torch>=1.8.0,<1.9.0;(platform_system!='Windows' and python_version>='3.9')",

2
ml-agents/README.md


Install the `mlagents` package with:
```sh
python -m pip install mlagents==0.25.1
python -m pip install mlagents==0.26.0
```
## Usage & More Information

1
ml-agents/mlagents/plugins/stats_writer.py


TensorboardWriter(
checkpoint_settings.write_path,
clear_past_data=not checkpoint_settings.resume,
hidden_keys=["Is Training", "Step"],
),
GaugeWriter(),
ConsoleWriter(),

15
ml-agents/mlagents/trainers/stats.py


from collections import defaultdict
from enum import Enum
from typing import List, Dict, NamedTuple, Any
from typing import List, Dict, NamedTuple, Any, Optional
import numpy as np
import abc
import os

from mlagents_envs.timers import set_gauge
from torch.utils.tensorboard import SummaryWriter
from mlagents.torch_utils.globals import get_rank
logger = get_logger(__name__)

class TensorboardWriter(StatsWriter):
def __init__(self, base_dir: str, clear_past_data: bool = False):
def __init__(
self,
base_dir: str,
clear_past_data: bool = False,
hidden_keys: Optional[List[str]] = None,
):
"""
A StatsWriter that writes to a Tensorboard summary.

category.
:param hidden_keys: If provided, Tensorboard Writer won't write statistics identified with these Keys in
Tensorboard summary.
self.hidden_keys: List[str] = hidden_keys if hidden_keys is not None else []
def write_stats(
self, category: str, values: Dict[str, StatsSummary], step: int

if key in self.hidden_keys:
continue
self.summary_writers[category].add_scalar(
f"{key}", value.aggregated_value, step
)

4
ml-agents/mlagents/trainers/__init__.py


# Version of the library that will be used to upload to pypi
__version__ = "0.26.0.dev0"
__version__ = "0.26.0"
__release_tag__ = None
__release_tag__ = "release_17"

11
ml-agents/mlagents/trainers/torch/networks.py


class MultiAgentNetworkBody(torch.nn.Module):
ATTENTION_EMBEDDING_SIZE = 128
"""
A network body that uses a self attention layer to handle state
and action input from a potentially variable number of agents that

+ self.action_spec.continuous_size
)
attention_embeding_size = self.h_size
obs_only_ent_size, None, self.ATTENTION_EMBEDDING_SIZE
obs_only_ent_size, None, attention_embeding_size
q_ent_size, None, self.ATTENTION_EMBEDDING_SIZE
q_ent_size, None, attention_embeding_size
self.self_attn = ResidualSelfAttention(self.ATTENTION_EMBEDDING_SIZE)
self.self_attn = ResidualSelfAttention(attention_embeding_size)
self.ATTENTION_EMBEDDING_SIZE,
attention_embeding_size,
network_settings.num_layers,
self.h_size,
kernel_gain=(0.125 / self.h_size) ** 0.5,

35
ml-agents/mlagents/trainers/settings.py


)
@staticmethod
def dict_to_defaultdict(d: Dict, t: type) -> DefaultDict:
def dict_to_trainerdict(d: Dict, t: type) -> >"TrainerSettings.DefaultTrainerDict":
return TrainerSettings.DefaultTrainerDict(
cattr.structure(d, Dict[str, TrainerSettings])
)

super().__init__(*args)
else:
super().__init__(TrainerSettings, *args)
self._config_specified = True
def set_config_specified(self, require_config_specified: bool) -> None:
self._config_specified = require_config_specified
return copy.deepcopy(TrainerSettings.default_override)
self[key] = copy.deepcopy(TrainerSettings.default_override)
elif self._config_specified:
raise TrainerConfigError(
f"The behavior name {key} has not been specified in the trainer configuration. "
f"Please add an entry in the configuration file for {key}, or set default_settings."
)
return TrainerSettings()
logger.warn(
f"Behavior name {key} does not match any behaviors specified "
f"in the trainer configuration file. A default configuration will be used."
)
self[key] = TrainerSettings()
return self[key]
# COMMAND LINE #########################################################################

@attr.s(auto_attribs=True)
class RunOptions(ExportableSettings):
default_settings: Optional[TrainerSettings] = None
behaviors: DefaultDict[str, TrainerSettings] = attr.ib(
behaviors: TrainerSettings.DefaultTrainerDict = attr.ib(
factory=TrainerSettings.DefaultTrainerDict
)
env_settings: EnvironmentSettings = attr.ib(factory=EnvironmentSettings)

# These are options that are relevant to the run itself, and not the engine or environment.
# They will be left here.
debug: bool = parser.get_default("debug")
# Strict conversion
# Convert to settings while making sure all fields are valid
cattr.register_structure_hook(EnvironmentSettings, strict_to_cls)
cattr.register_structure_hook(EngineSettings, strict_to_cls)
cattr.register_structure_hook(CheckpointSettings, strict_to_cls)

)
cattr.register_structure_hook(TrainerSettings, TrainerSettings.structure)
cattr.register_structure_hook(
DefaultDict[str, TrainerSettings], TrainerSettings.dict_to_defaultdict
TrainerSettings.DefaultTrainerDict, TrainerSettings.dict_to_trainerdict
)
cattr.register_unstructure_hook(collections.defaultdict, defaultdict_to_dict)

"engine_settings": {},
"torch_settings": {},
}
_require_all_behaviors = True
else:
# If we're not loading from a file, we don't require all behavior names to be specified.
_require_all_behaviors = False
# Use the YAML file values for all values not specified in the CLI.
for key in configured_dict.keys():

configured_dict[key] = val
final_runoptions = RunOptions.from_dict(configured_dict)
# Need check to bypass type checking but keep structure on dict working
if isinstance(final_runoptions.behaviors, TrainerSettings.DefaultTrainerDict):
# configure whether or not we should require all behavior names to be found in the config YAML
final_runoptions.behaviors.set_config_specified(_require_all_behaviors)
return final_runoptions
@staticmethod

25
ml-agents/mlagents/trainers/tests/test_stats.py


assert len(os.listdir(os.path.join(tmp_path, "category1"))) == 1
@mock.patch("mlagents.trainers.stats.SummaryWriter")
def test_tensorboard_writer_hidden_keys(mock_summary):
# Test write_stats
category = "category1"
with tempfile.TemporaryDirectory(prefix="unittest-") as base_dir:
tb_writer = TensorboardWriter(
base_dir, clear_past_data=False, hidden_keys="hiddenKey"
)
statssummary1 = StatsSummary(
full_dist=[1.0], aggregation_method=StatsAggregationMethod.AVERAGE
)
tb_writer.write_stats("category1", {"hiddenKey": statssummary1}, 10)
# Test that the filewriter has been created and the directory has been created.
filewriter_dir = "{basedir}/{category}".format(
basedir=base_dir, category=category
)
assert os.path.exists(filewriter_dir)
mock_summary.assert_called_once_with(filewriter_dir)
# Test that the filewriter was not written to since we used the hidden key.
mock_summary.return_value.add_scalar.assert_not_called()
mock_summary.return_value.flush.assert_not_called()
def test_gauge_stat_writer_sanitize():
assert GaugeWriter.sanitize_string("Policy/Learning Rate") == "Policy.LearningRate"
assert (

35
ml-agents/mlagents/trainers/tests/test_settings.py


Verify that a new config will have a PPO trainer with extrinsic rewards.
"""
blank_runoptions = RunOptions()
blank_runoptions.behaviors.set_config_specified(False)
assert (
RewardSignalType.EXTRINSIC in blank_runoptions.behaviors["test"].reward_signals
)

default_settings_cls = cattr.structure(default_settings, TrainerSettings)
check_if_different(default_settings_cls, run_options.behaviors["test2"])
# Check that an existing beehavior overrides the defaults in specified fields
# Check that an existing behavior overrides the defaults in specified fields
test1_settings = run_options.behaviors["test1"]
assert test1_settings.max_steps == 2
assert test1_settings.network_settings.hidden_units == 2000

test1_settings.network_settings.hidden_units == default_settings_cls.network_settings.hidden_units
check_if_different(test1_settings, default_settings_cls)
def test_config_specified():
# Test require all behavior names to be specified (or not)
# Remove any pre-set defaults
TrainerSettings.default_override = None
behaviors = {"test1": {"max_steps": 2, "network_settings": {"hidden_units": 2000}}}
run_options_dict = {"behaviors": behaviors}
ro = RunOptions.from_dict(run_options_dict)
# Don't require all behavior names
ro.behaviors.set_config_specified(False)
# Test that we can grab an entry that is not in the dict.
assert isinstance(ro.behaviors["test2"], TrainerSettings)
# Create strict RunOptions with no defualt_settings
run_options_dict = {"behaviors": behaviors}
ro = RunOptions.from_dict(run_options_dict)
# Require all behavior names
ro.behaviors.set_config_specified(True)
with pytest.raises(TrainerConfigError):
# Variable must be accessed otherwise Python won't query the dict
print(ro.behaviors["test2"])
# Create strict RunOptions with default settings
default_settings = {"max_steps": 1, "network_settings": {"num_layers": 1000}}
run_options_dict = {"default_settings": default_settings, "behaviors": behaviors}
ro = RunOptions.from_dict(run_options_dict)
# Require all behavior names
ro.behaviors.set_config_specified(True)
# Test that we can grab an entry that is not in the dict.
assert isinstance(ro.behaviors["test2"], TrainerSettings)
def test_pickle():

2
ml-agents/mlagents/trainers/tests/test_trainer_util.py


"""
brain_name = "testbrain"
no_default_config = RunOptions().behaviors
# Pretend this was created without a YAML file
no_default_config.set_config_specified(False)
trainer_factory = TrainerFactory(
trainer_config=no_default_config,

1
ml-agents/mlagents/trainers/trainer/rl_trainer.py


p = self.get_policy(name_behavior_id)
if p:
p.increment_step(n_steps)
self.stats_reporter.set_stat("Step", float(self.get_step))
def _get_next_interval_step(self, interval: int) -> int:
"""

5
ml-agents/mlagents/trainers/trainer/trainer_factory.py


self.ghost_controller = GhostController()
def generate(self, behavior_name: str) -> Trainer:
if behavior_name not in self.trainer_config.keys():
logger.warning(
f"Behavior name {behavior_name} does not match any behaviors specified"
f"in the trainer configuration file: {sorted(self.trainer_config.keys())}"
)
trainer_settings = self.trainer_config[behavior_name]
return TrainerFactory._initialize_trainer(
trainer_settings,

2
.yamato/com.unity.ml-agents-coverage.yml


{% if package.name == "com.unity.ml-agents.extensions" %}
pull_request.changes.any match "com.unity.ml-agents.extensions/**" OR
{% endif %}
pull_request.changes.any match ".yamato/com.unity.ml-agents-test.yml")
pull_request.changes.any match ".yamato/com.unity.ml-agents-coverage.yml")
{% endif %}
{% endfor %}
{% endfor %}

4
.yamato/com.unity.ml-agents-test.yml


- version: 2020.2
testProject: DevProject
enableNoDefaultPackages: !!bool true
- version: 2021.1
- version: 2021.2
testProject: DevProject
enableNoDefaultPackages: !!bool true

flavor: {{ platform.flavor}}
commands:
- npm install upm-ci-utils@stable -g --registry https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-npm
- upm-ci project test -u {{ editor.version }} --project-path {{ editor.testProject }} --package-filter {{ package.name }} {{ noDefaultPackagesOptions }} --extra-utr-arg "reruncount=2"
- upm-ci package test -u {{ editor.version }} --package-path {{ package.name }} {{ noDefaultPackagesOptions }} --warnings-as-errors --extra-utr-arg "reruncount=2"
artifacts:
logs:
paths:

76
com.unity.ml-agents.extensions/Documentation~/CustomGridSensors.md


# Extending Grid Sensors
## Overview
Grid Sensor provides a 2D observation that detects objects around an agent from a top-down view. Compared to RayCasts, it receives a full observation in a grid area without gaps, and the detection is not blocked by objects around the agents. This gives a more granular view while requiring a higher usage of compute resources.
One extra feature with Grid Sensors is that you can derive from the Grid Sensor base class to collect custom data besides the object tags, to include custom attributes as observations. This allows more flexibility for the use of GridSensor. This doc will elaborate how to create custom grid-based sensor class, and the sensors implementations provided in ml-agents package.
## Customized Grid Sensor
To create a custom grid sensor, you'll need to derive from two classes: `GridSensorBase` and `GridSensorComponent`.
### Deriving from `GridSensorBase`
This is the implementation of your sensor. This defines how your sensor process detected colliders,
what the data looks like, and how the observations are constructed from the detected objects.
Consider overriding the following methods depending on your use case:
* `protected virtual int GetCellObservationSize()`: Return the observation size per cell. Default to `1`.
* `protected virtual void GetObjectData(GameObject detectedObject, int tagIndex, float[] dataBuffer)`: Constructs observations from the detected object. The input provides the detected GameObject and the index of its tag (0-indexed). The observations should be written to the given `dataBuffer` and the buffer size is defined in `GetCellObservationSize()`. This data will be gathered from each cell and sent to the trainer as observation.
* `protected virtual bool IsDataNormalized()`: Return whether the observation is normalized to 0~1. This affects whether you're able to use compressed observations as compressed data only supports normalized data. Return `true` if all the values written in `GetObjectData` are within the range of (0, 1), otherwise return `false`. Default to `false`.
There might be cases when your data is not in the range of (0, 1) but you still wish to use compressed data to speed up training. If your data is naturally bounded within a range, normalize your data first to the possible range and fill the buffer with normalized data. For example, since the angle of rotation is bounded within `0 ~ 360`, record an angle `x` as `x/360` instead of `x`. If your data value is not bounded (position, velocity, etc.), consider setting a reasonable min/max value and use that to normalize your data.
* `protected internal virtual ProcessCollidersMethod GetProcessCollidersMethod()`: Return the method to process colliders detected in a cell. This defines the sensor behavior when multiple objects with detectable tags are detected within a cell.
Currently two methods are provided:
* `ProcessCollidersMethod.ProcessClosestColliders` (Default): Process the closest collider to the agent. In this case each cell's data is represented by one object.
* `ProcessCollidersMethod.ProcessAllColliders`: Process all detected colliders. This is useful when the data from each cell is additive, for instance, the count of detected objects in a cell. When using this option, the input `dataBuffer` in `GetObjectData()` will contain processed data from other colliders detected in the cell. You'll more likely want to add/subtract values from the buffer instead of overwrite it completely.
### Deriving from `GridSensorComponent`
To create your sensor, you need to override the sensor component and add your sensor to the creation.
Specifically, you need to override `GetGridSensors()` and return an array of grid sensors you want to use in the component.
It can be used to create multiple different customized grid sensors, or you can also include the ones provided in our package (listed in the next section).
Example:
```
public class CustomGridSensorComponent : GridSensorComponent
{
protected override GridSensorBase[] GetGridSensors()
{
return new GridSensorBase[] { new CustomGridSensor(...)};
}
}
```
## Grid Sensor Types
Here we list out two types of grid sensor we provide in our package: `OneHotGridSensor` and `CountingGridSensor`.
Their implementations are also a good reference for making you own ones.
### OneHotGridSensor (provided in `com.unity.ml-agents`)
This is the default sensor used by `GridSensorComponent`. It detects objects with detectable tags and the observation is the one-hot representation of the detected tag index.
The implementation of the sensor is defined as following:
* `GetCellObservationSize()`: `detectableTags.Length`
* `IsDataNormalized()`: `true`
* `ProcessCollidersMethod()`: `ProcessCollidersMethod.ProcessClosestColliders`
* `GetObjectData()`:
```
protected override void GetObjectData(GameObject detectedObject, int tagIndex, float[] dataBuffer)
{
dataBuffer[tagIndex] = 1;
}
```
### CountingGridSensor (provided in `com.unity.ml-agents.extensions`)
This is an example of using all colliders detected in a cell. It counts the number of objects detected for each detectable tag. The sensor cannot be used with data compression.
The implementation of the sensor is defined as following:
* `GetCellObservationSize()`: `detectableTags.Length`
* `IsDataNormalized()`: `false`
* `ProcessCollidersMethod()`: `ProcessCollidersMethod.ProcessAllColliders`
* `GetObjectData()`:
```
protected override void GetObjectData(GameObject detectedObject, int tagIndex, float[] dataBuffer)
{
dataBuffer[tagIndex] += 1;
}
```
正在加载...
取消
保存