浏览代码

Revamp Crawler & Walker (#841)

* Revamps agent code for walker and crawler environments to use shared JointDriveController system.
* Crawler has been reworked to be very cute.
* Crawler & Walker environments have been reworked to be visually consistent.
* Added Dynamic Crawler scene.
* All scenes re-trained and new models added.
* Documentation changes.
/develop-generalizationTraining-TrainerController
GitHub 7 年前
当前提交
c9c9e147
共有 104 个文件被更改,包括 11335 次插入3314 次删除
  1. 1
      .gitignore
  2. 13
      docs/Learning-Environment-Examples.md
  3. 999
      docs/images/crawler.png
  4. 999
      docs/images/walker.png
  5. 7
      python/trainer_config.yaml
  6. 5
      unity-environment/Assets/ML-Agents/Examples/Crawler.meta
  7. 2
      unity-environment/Assets/ML-Agents/Examples/Crawler/Prefabs.meta
  8. 881
      unity-environment/Assets/ML-Agents/Examples/Crawler/Prefabs/Crawler.prefab
  9. 5
      unity-environment/Assets/ML-Agents/Examples/Crawler/Prefabs/Crawler.prefab.meta
  10. 2
      unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts.meta
  11. 8
      unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAcademy.cs
  12. 5
      unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAcademy.cs.meta
  13. 5
      unity-environment/Assets/ML-Agents/Examples/Crawler/TFModels.meta
  14. 5
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Agent.mat.meta
  15. 15
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Ball.mat
  16. 4
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Ball.mat.meta
  17. 2
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Black.mat.meta
  18. 4
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Block.mat.meta
  19. 6
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/BlueAgent.mat
  20. 2
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/CheckerGoal.mat.meta
  21. 2
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/CheckerMany.mat.meta
  22. 2
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/CheckerRectangle.mat.meta
  23. 16
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/CheckerSquare.mat
  24. 2
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/FailGround.mat.meta
  25. 5
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Goal.mat.meta
  26. 2
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Grass.mat.meta
  27. 2
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Ground.mat.meta
  28. 2
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Obstacle.mat.meta
  29. 2
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/SuccessGround.mat.meta
  30. 5
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/UIDefault.mat.meta
  31. 12
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Wall.mat
  32. 4
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Wall.mat.meta
  33. 32
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Scripts/GroundContact.cs
  34. 5
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Scripts/GroundContact.cs.meta
  35. 132
      unity-environment/Assets/ML-Agents/Examples/Walker/Prefabs/WalkerAgent.prefab
  36. 935
      unity-environment/Assets/ML-Agents/Examples/Walker/Scenes/Walker.unity
  37. 6
      unity-environment/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAcademy.cs
  38. 237
      unity-environment/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAgent.cs
  39. 985
      unity-environment/Assets/ML-Agents/Examples/Walker/TFModels/Walker.bytes
  40. 2
      unity-environment/Assets/ML-Agents/Examples/Walker/TFModels/Walker.bytes.meta
  41. 1
      unity-environment/ProjectSettings/EditorBuildSettings.asset
  42. 14
      unity-environment/ProjectSettings/ProjectSettings.asset
  43. 8
      unity-environment/Assets/ML-Agents/Examples/Crawler/Materials.meta
  44. 1001
      unity-environment/Assets/ML-Agents/Examples/Crawler/Prefabs/DynamicPlatform.prefab
  45. 8
      unity-environment/Assets/ML-Agents/Examples/Crawler/Prefabs/DynamicPlatform.prefab.meta
  46. 1001
      unity-environment/Assets/ML-Agents/Examples/Crawler/Prefabs/FixedPlatform.prefab
  47. 8
      unity-environment/Assets/ML-Agents/Examples/Crawler/Prefabs/FixedPlatform.prefab.meta
  48. 8
      unity-environment/Assets/ML-Agents/Examples/Crawler/Scenes.meta
  49. 269
      unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAgent.cs
  50. 13
      unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAgent.cs.meta
  51. 1001
      unity-environment/Assets/ML-Agents/Examples/Crawler/TFModels/DynamicCrawler.bytes
  52. 7
      unity-environment/Assets/ML-Agents/Examples/Crawler/TFModels/DynamicCrawler.bytes.meta
  53. 1001
      unity-environment/Assets/ML-Agents/Examples/Crawler/TFModels/FixedCrawler.bytes
  54. 7
      unity-environment/Assets/ML-Agents/Examples/Crawler/TFModels/FixedCrawler.bytes.meta
  55. 76
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/DarkGridFloor.mat
  56. 8
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/DarkGridFloor.mat.meta
  57. 76
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/LightGridFloor.mat
  58. 8
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/LightGridFloor.mat.meta
  59. 76
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/LightGridFloorSquare.mat
  60. 8
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/LightGridFloorSquare.mat.meta
  61. 76
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/White.mat
  62. 8
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/White.mat.meta
  63. 3
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/gridTexture.png
  64. 84
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/gridTexture.png.meta
  65. 195
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/gridTextureWhite.psd
  66. 84
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/gridTextureWhite.psd.meta
  67. 76
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/groundGreen.mat
  68. 8
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/groundGreen.mat.meta
  69. 76
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/groundGrey.mat
  70. 8
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/groundGrey.mat.meta
  71. 76
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/groundRed.mat
  72. 8
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/groundRed.mat.meta
  73. 58
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Scripts/AdjustTrainingTimescale.cs
  74. 11
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Scripts/AdjustTrainingTimescale.cs.meta
  75. 178
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Scripts/JointDriveController.cs
  76. 11
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Scripts/JointDriveController.cs.meta
  77. 40
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Scripts/TargetContact.cs
  78. 11
      unity-environment/Assets/ML-Agents/Examples/SharedAssets/Scripts/TargetContact.cs.meta
  79. 76
      unity-environment/Assets/ML-Agents/Examples/Walker/Materials/LightGridFloorWalker.mat
  80. 8
      unity-environment/Assets/ML-Agents/Examples/Walker/Materials/LightGridFloorWalker.mat.meta
  81. 180
      unity-environment/Assets/ML-Agents/Examples/Walker/Prefabs/TARGET.prefab
  82. 8
      unity-environment/Assets/ML-Agents/Examples/Walker/Prefabs/TARGET.prefab.meta
  83. 1001
      unity-environment/Assets/ML-Agents/Examples/Walker/Prefabs/WalkerPair.prefab
  84. 8
      unity-environment/Assets/ML-Agents/Examples/Walker/Prefabs/WalkerPair.prefab.meta
  85. 76
      unity-environment/Assets/ML-Agents/Examples/Crawler/Materials/DarkGridFloorMovingTargetCrawler.mat
  86. 8
      unity-environment/Assets/ML-Agents/Examples/Crawler/Materials/DarkGridFloorMovingTargetCrawler.mat.meta
  87. 76
      unity-environment/Assets/ML-Agents/Examples/Crawler/Materials/DarkGridFloorStaticCrawler.mat
  88. 8
      unity-environment/Assets/ML-Agents/Examples/Crawler/Materials/DarkGridFloorStaticCrawler.mat.meta
  89. 1001
      unity-environment/Assets/ML-Agents/Examples/Crawler/Scenes/CrawlerDynamicTarget.unity
  90. 7
      unity-environment/Assets/ML-Agents/Examples/Crawler/Scenes/CrawlerDynamicTarget.unity.meta
  91. 1001
      unity-environment/Assets/ML-Agents/Examples/Crawler/Scenes/CrawlerStaticTarget.unity
  92. 8
      unity-environment/Assets/ML-Agents/Examples/Crawler/Scenes/CrawlerStaticTarget.unity.meta
  93. 12
      unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAgentConfigurable.cs.meta
  94. 19
      unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerBodyContact.cs
  95. 12
      unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerBodyContact.cs.meta
  96. 21
      unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerLegContact.cs
  97. 12
      unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerLegContact.cs.meta
  98. 137
      unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAgentConfigurable.cs

1
.gitignore


/unity-environment/[Uu]nity[Pp]ackage[Mm]anager/
/unity-environment/Assets/AssetStoreTools*
/unity-environment/Assets/Plugins*
/unity-environment/Assets/Gizmos*
# Tensorflow Model Info
/models

13
docs/Learning-Environment-Examples.md


![Crawler](images/crawler.png)
* Set-up: A creature with 4 arms and 4 forearms.
* Goal: The agents must move its body along the x axis without falling.
* Goal: The agents must move its body toward the goal direction without falling.
* `CrawlerStaticTarget` - Goal direction is always forward.
* `CrawlerDynamicTarget`- Goal direction is randomized.
* +1 times velocity in the x direction
* -1 for falling.
* -0.01 times the action squared
* -0.05 times y position change
* -0.05 times velocity in the z direction
* +0.03 times body velocity in the goal direction.
* +0.01 times body direction alignment with goal direction.
* Vector Action space: (Continuous) Size of 12, corresponding to torque applicable to 12 joints.
* Vector Action space: (Continuous) Size of 20, corresponding to target rotations for joints.
* Visual Observations: None.
* Reset Parameters: None
* Benchmark Mean Reward: 2000

999
docs/images/crawler.png
文件差异内容过多而无法显示
查看文件

999
docs/images/walker.png
文件差异内容过多而无法显示
查看文件

7
python/trainer_config.yaml


gamma: 0.995
max_steps: 1e6
summary_freq: 3000
num_layers: 3
hidden_units: 512
WalkerBrain:
normalize: true

buffer_size: 20480
beta: 0.001
num_layers: 2
hidden_units: 256
num_layers: 3
hidden_units: 512
ReacherBrain:
normalize: true

5
unity-environment/Assets/ML-Agents/Examples/Crawler.meta


fileFormatVersion: 2
guid: f156237910cf946e78a82c48410fef52
guid: 3aea709eb8dc04856aaa6d93573fb0df
timeCreated: 1517447132
licenseType: Free
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

2
unity-environment/Assets/ML-Agents/Examples/Crawler/Prefabs.meta


fileFormatVersion: 2
guid: f444e57207b384a2e868d864d2bae755
guid: c9cb9a4fa201d4f579ff66de92b0317f
folderAsset: yes
timeCreated: 1508478093
licenseType: Free

881
unity-environment/Assets/ML-Agents/Examples/Crawler/Prefabs/Crawler.prefab
文件差异内容过多而无法显示
查看文件

5
unity-environment/Assets/ML-Agents/Examples/Crawler/Prefabs/Crawler.prefab.meta


fileFormatVersion: 2
guid: 3db4283e33af74336bfedb01d0e011bf
timeCreated: 1508548205
licenseType: Free
guid: 0e8a62cb7c8f0483ebd12046bae9ca05
externalObjects: {}
mainObjectFileID: 100100000
userData:
assetBundleName:

2
unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts.meta


fileFormatVersion: 2
guid: 464b7b589acd8464c8c447efa71f95ed
guid: be27b48ac06d945b5865f65f96d7d008
folderAsset: yes
timeCreated: 1508478093
licenseType: Free

8
unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAcademy.cs


public override void InitializeAcademy()
{
Monitor.verticalOffset = 1f;
Physics.defaultSolverIterations = 12;
Physics.defaultSolverVelocityIterations = 12;
Time.fixedDeltaTime = 0.01333f; // (75fps). default is .2 (60fps)
Time.maximumDeltaTime = .15f; // Default is .33
}
}

5
unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAcademy.cs.meta


fileFormatVersion: 2
guid: 19a3d2012efe74376a579f7f8fbfe13d
timeCreated: 1507584900
licenseType: Free
guid: 05e76ca0a155e48caa36ee60e64ee9c9
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0

5
unity-environment/Assets/ML-Agents/Examples/Crawler/TFModels.meta


fileFormatVersion: 2
guid: 4a3b975c6f9424f52aa1d7b9b87b6e1a
guid: 0b737d19c4232404389d1325808e5b4d
timeCreated: 1508478093
licenseType: Free
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

5
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Agent.mat.meta


fileFormatVersion: 2
guid: 260483cdfc6b14e26823a02f23bd8baa
timeCreated: 1506189720
licenseType: Pro
mainObjectFileID: 2100000
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

15
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Ball.mat


m_PrefabInternal: {fileID: 0}
m_Name: Ball
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords: _EMISSION
m_ShaderKeywords: _ALPHAPREMULTIPLY_ON _EMISSION
m_CustomRenderQueue: -1
stringTagMap: {}
m_CustomRenderQueue: 3000
stringTagMap:
RenderType: Transparent
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3

- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _DstBlend: 10
- _Mode: 0
- _Mode: 3
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0

- _ZWrite: 1
- _ZWrite: 0
- _EmissionColor: {r: 0.96862745, g: 0.5764706, b: 0.11764706, a: 1}
- _EmissionColor: {r: 1.4980392, g: 0.6902509, b: 0.18823531, a: 1}

4
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Ball.mat.meta


fileFormatVersion: 2
guid: edd958d75ed1448138de86f3335ea4fa
timeCreated: 1497123463
licenseType: Pro
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

2
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Black.mat.meta


fileFormatVersion: 2
guid: 866f7a84824d141dbbe50dd1893207d9
timeCreated: 1513128297
licenseType: Pro
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0

4
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Block.mat.meta


fileFormatVersion: 2
guid: f4abcb290251940948a31b349a6f9995
timeCreated: 1506379314
licenseType: Pro
mainObjectFileID: 2100000
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

6
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/BlueAgent.mat


m_PrefabInternal: {fileID: 0}
m_Name: BlueAgent
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0

- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0
- _GlossyReflections: 1
- _GlossyReflections: 0
- _SpecularHighlights: 1
- _SpecularHighlights: 0
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1

2
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/CheckerGoal.mat.meta


guid: f886179ad71d3416f9af88e90f7043a1
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

2
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/CheckerMany.mat.meta


guid: 5cfafc0a2c7ae4dd58cb312c821d3cfe
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

2
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/CheckerRectangle.mat.meta


guid: 55476c25feb2b443c98c5f6b5aaddf3c
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

16
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/CheckerSquare.mat


m_PrefabInternal: {fileID: 0}
m_Name: CheckerSquare
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords: _EMISSION
m_LightmapFlags: 1
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1

m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 2800000, guid: ec59c5ad7c2314165b1ac93a5773ebae, type: 3}
m_Scale: {x: 1, y: 1}
m_Scale: {x: 200, y: 100}
m_Scale: {x: 1, y: 1}
m_Scale: {x: 200, y: 100}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}

- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Glossiness: 0
- _GlossyReflections: 0
- _SpecularHighlights: 1
- _SpecularHighlights: 0
- _Color: {r: 0, g: 0, b: 0, a: 1}
- _Color: {r: 0.764151, g: 0.764151, b: 0.764151, a: 1}
- _EmissionColor: {r: 1, g: 1, b: 1, a: 1}

2
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/FailGround.mat.meta


guid: 882d882b99bce44c6863ec8d3760e9ca
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

5
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Goal.mat.meta


fileFormatVersion: 2
guid: 624b24bbec31f44babfb57ef2dfbc537
timeCreated: 1506189863
licenseType: Pro
mainObjectFileID: 2100000
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

2
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Grass.mat.meta


guid: 0fa85a3e5d58d44a08d19064187ac064
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

2
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Ground.mat.meta


guid: ea4e6e61f90ae46daaf643b945c080ed
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

2
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Obstacle.mat.meta


guid: 0483e5b320b23418b8318497c636bf8e
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

2
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/SuccessGround.mat.meta


guid: 80ffa2c5b96364e4b80fbb2e42b0af3d
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

5
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/UIDefault.mat.meta


fileFormatVersion: 2
guid: 463606e709fd24f29ac1096d0aade647
timeCreated: 1503267725
licenseType: Free
mainObjectFileID: 2100000
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

12
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Wall.mat


m_PrefabInternal: {fileID: 0}
m_Name: Wall
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords:
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0

- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _GlossMapScale: 0
- _Glossiness: 0
- _GlossyReflections: 0
- _SpecularHighlights: 1
- _SpecularHighlights: 0
- _Color: {r: 0.7411765, g: 0.7411765, b: 0.7529412, a: 1}
- _Color: {r: 0.3679245, g: 0.3679245, b: 0.3679245, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

4
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/Wall.mat.meta


fileFormatVersion: 2
guid: 214660f4189b04cada2137381f5c3607
timeCreated: 1497379290
licenseType: Pro
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

32
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Scripts/GroundContact.cs


namespace MLAgents
{
[DisallowMultipleComponent]
public Agent agent;
public float contactPenalty;
public bool touchingGround;
public bool penalizeOnContact;
private const string Ground = "ground";
[HideInInspector] public Agent agent;
/// <summary>
/// Obtain reference to agent.
/// </summary>
void Start()
{
agent = transform.root.GetComponent<Agent>();
}
[Header("Ground Check")] public bool agentDoneOnGroundContact; // Whether to reset agent on ground contact.
public bool penalizeGroundContact; // Whether to penalize on contact.
public float groundContactPenalty; // Penalty amount (ex: -1).
public bool touchingGround;
private const string Ground = "ground"; // Tag of ground object.
void OnCollisionEnter(Collision other)
void OnCollisionEnter(Collision col)
if (other.transform.CompareTag(Ground))
if (col.transform.CompareTag(Ground))
if (penalizeOnContact)
if (penalizeGroundContact)
{
agent.SetReward(groundContactPenalty);
}
if (agentDoneOnGroundContact)
agent.SetReward(contactPenalty);
}
}
}

5
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Scripts/GroundContact.cs.meta


fileFormatVersion: 2
guid: 33d834e5248d246138ae30cd155021d1
timeCreated: 1507591712
licenseType: Free
guid: 2666e257ea992476cae0f7f163165e71
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0

132
unity-environment/Assets/ML-Agents/Examples/Walker/Prefabs/WalkerAgent.prefab


m_Component:
- component: {fileID: 4149577599396768}
- component: {fileID: 114095122263002928}
- component: {fileID: 114914427405044950}
m_Layer: 0
m_Name: WalkerAgent
m_TagString: Untagged

m_GameObject: {fileID: 1951139309579916}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 33d834e5248d246138ae30cd155021d1, type: 3}
m_Script: {fileID: 11500000, guid: 2666e257ea992476cae0f7f163165e71, type: 3}
contactPenalty: -1
agentDoneOnGroundContact: 0
penalizeGroundContact: 0
groundContactPenalty: 0
penalizeOnContact: 0
--- !u!114 &114085264024212618
MonoBehaviour:
m_ObjectHideFlags: 1

m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 33d834e5248d246138ae30cd155021d1, type: 3}
m_Script: {fileID: 11500000, guid: 2666e257ea992476cae0f7f163165e71, type: 3}
contactPenalty: -1
agentDoneOnGroundContact: 1
penalizeGroundContact: 1
groundContactPenalty: -1
penalizeOnContact: 1
--- !u!114 &114095122263002928
MonoBehaviour:
m_ObjectHideFlags: 1

maxStep: 5000
resetOnDone: 1
onDemandDecision: 0
numberOfActionsBetweenDecisions: 5
goalDirection: {x: 1, y: 0, z: 0}
numberOfActionsBetweenDecisions: 3
target: {fileID: 0}
hips: {fileID: 4178980744778630}
chest: {fileID: 4210128103550454}
spine: {fileID: 4786283472884902}

m_GameObject: {fileID: 1075018522438980}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 33d834e5248d246138ae30cd155021d1, type: 3}
m_Script: {fileID: 11500000, guid: 2666e257ea992476cae0f7f163165e71, type: 3}
contactPenalty: -1
agentDoneOnGroundContact: 1
penalizeGroundContact: 1
groundContactPenalty: -1
penalizeOnContact: 1
--- !u!114 &114266008813542904
MonoBehaviour:
m_ObjectHideFlags: 1

m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 33d834e5248d246138ae30cd155021d1, type: 3}
m_Script: {fileID: 11500000, guid: 2666e257ea992476cae0f7f163165e71, type: 3}
contactPenalty: -1
agentDoneOnGroundContact: 1
penalizeGroundContact: 1
groundContactPenalty: -1
penalizeOnContact: 1
--- !u!114 &114274132433101900
MonoBehaviour:
m_ObjectHideFlags: 1

m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 33d834e5248d246138ae30cd155021d1, type: 3}
m_Script: {fileID: 11500000, guid: 2666e257ea992476cae0f7f163165e71, type: 3}
contactPenalty: -1
agentDoneOnGroundContact: 1
penalizeGroundContact: 1
groundContactPenalty: -1
penalizeOnContact: 1
--- !u!114 &114298444411495568
MonoBehaviour:
m_ObjectHideFlags: 1

m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 33d834e5248d246138ae30cd155021d1, type: 3}
m_Script: {fileID: 11500000, guid: 2666e257ea992476cae0f7f163165e71, type: 3}
contactPenalty: -1
agentDoneOnGroundContact: 1
penalizeGroundContact: 1
groundContactPenalty: -1
penalizeOnContact: 1
--- !u!114 &114442414695609972
MonoBehaviour:
m_ObjectHideFlags: 1

m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 33d834e5248d246138ae30cd155021d1, type: 3}
m_Script: {fileID: 11500000, guid: 2666e257ea992476cae0f7f163165e71, type: 3}
contactPenalty: -1
agentDoneOnGroundContact: 1
penalizeGroundContact: 1
groundContactPenalty: -1
penalizeOnContact: 0
--- !u!114 &114500231387513536
MonoBehaviour:
m_ObjectHideFlags: 1

m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 33d834e5248d246138ae30cd155021d1, type: 3}
m_Script: {fileID: 11500000, guid: 2666e257ea992476cae0f7f163165e71, type: 3}
contactPenalty: -1
agentDoneOnGroundContact: 1
penalizeGroundContact: 1
groundContactPenalty: -1
penalizeOnContact: 1
--- !u!114 &114542353308541564
MonoBehaviour:
m_ObjectHideFlags: 1

m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 33d834e5248d246138ae30cd155021d1, type: 3}
m_Script: {fileID: 11500000, guid: 2666e257ea992476cae0f7f163165e71, type: 3}
contactPenalty: -1
agentDoneOnGroundContact: 1
penalizeGroundContact: 1
groundContactPenalty: -1
penalizeOnContact: 0
--- !u!114 &114584838863670294
MonoBehaviour:
m_ObjectHideFlags: 1

m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 33d834e5248d246138ae30cd155021d1, type: 3}
m_Script: {fileID: 11500000, guid: 2666e257ea992476cae0f7f163165e71, type: 3}
contactPenalty: -1
agentDoneOnGroundContact: 1
penalizeGroundContact: 1
groundContactPenalty: -1
penalizeOnContact: 1
--- !u!114 &114625213176808800
MonoBehaviour:
m_ObjectHideFlags: 1

m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 33d834e5248d246138ae30cd155021d1, type: 3}
m_Script: {fileID: 11500000, guid: 2666e257ea992476cae0f7f163165e71, type: 3}
contactPenalty: -1
agentDoneOnGroundContact: 1
penalizeGroundContact: 1
groundContactPenalty: -1
penalizeOnContact: 0
--- !u!114 &114690090025059694
MonoBehaviour:
m_ObjectHideFlags: 1

m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 33d834e5248d246138ae30cd155021d1, type: 3}
m_Script: {fileID: 11500000, guid: 2666e257ea992476cae0f7f163165e71, type: 3}
contactPenalty: -1
agentDoneOnGroundContact: 0
penalizeGroundContact: 0
groundContactPenalty: 0
penalizeOnContact: 0
--- !u!114 &114713577680667666
MonoBehaviour:
m_ObjectHideFlags: 1

m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 33d834e5248d246138ae30cd155021d1, type: 3}
m_Script: {fileID: 11500000, guid: 2666e257ea992476cae0f7f163165e71, type: 3}
contactPenalty: -1
agentDoneOnGroundContact: 1
penalizeGroundContact: 1
groundContactPenalty: -1
penalizeOnContact: 1
--- !u!114 &114787271536612966
MonoBehaviour:
m_ObjectHideFlags: 1

m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 33d834e5248d246138ae30cd155021d1, type: 3}
m_Script: {fileID: 11500000, guid: 2666e257ea992476cae0f7f163165e71, type: 3}
contactPenalty: -1
agentDoneOnGroundContact: 1
penalizeGroundContact: 1
groundContactPenalty: -1
penalizeOnContact: 1
--- !u!114 &114859585539225818
MonoBehaviour:
m_ObjectHideFlags: 1

m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 33d834e5248d246138ae30cd155021d1, type: 3}
m_Script: {fileID: 11500000, guid: 2666e257ea992476cae0f7f163165e71, type: 3}
contactPenalty: -1
agentDoneOnGroundContact: 1
penalizeGroundContact: 1
groundContactPenalty: -1
penalizeOnContact: 1
--- !u!114 &114914427405044950
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1857740238369858}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1b29724baddfa457da6eeab446fa49ca, type: 3}
m_Name:
m_EditorClassIdentifier:
maxJointSpring: 10000
jointDampen: 50
maxJointForceLimit: 25000
bodyPartsList: []
--- !u!114 &114983967692796378
MonoBehaviour:
m_ObjectHideFlags: 1

m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 33d834e5248d246138ae30cd155021d1, type: 3}
m_Script: {fileID: 11500000, guid: 2666e257ea992476cae0f7f163165e71, type: 3}
contactPenalty: -1
agentDoneOnGroundContact: 1
penalizeGroundContact: 1
groundContactPenalty: -1
penalizeOnContact: 1
--- !u!135 &135315403538457256
SphereCollider:
m_ObjectHideFlags: 1

935
unity-environment/Assets/ML-Agents/Examples/Walker/Scenes/Walker.unity
文件差异内容过多而无法显示
查看文件

6
unity-environment/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAcademy.cs


public override void InitializeAcademy()
{
Monitor.verticalOffset = 1f;
Time.fixedDeltaTime = 0.01333f; //(75fps). default is .2 (60fps)
Time.maximumDeltaTime = .15f; // Default is .33
}
}

237
unity-environment/Assets/ML-Agents/Examples/Walker/Scripts/WalkerAgent.cs


public class WalkerAgent : Agent
{
[Header("Specific to Walker")]
public Vector3 goalDirection;
[Header("Specific to Walker")] [Header("Target To Walk Towards")] [Space(10)]
public Transform target;
Vector3 dirToTarget;
public Transform hips;
public Transform chest;
public Transform spine;

public Transform armR;
public Transform forearmR;
public Transform handR;
public Dictionary<Transform, BodyPart> bodyParts = new Dictionary<Transform, BodyPart>();
/// <summary>
/// Used to store relevant information for acting and learning for each body part in agent.
/// </summary>
[System.Serializable]
public class BodyPart
{
public ConfigurableJoint joint;
public Rigidbody rb;
public Vector3 startingPos;
public Quaternion startingRot;
public GroundContact groundContact;
/// <summary>
/// Reset body part to initial configuration.
/// </summary>
public void Reset()
{
rb.transform.position = startingPos;
rb.transform.rotation = startingRot;
rb.velocity = Vector3.zero;
rb.angularVelocity = Vector3.zero;
}
/// <summary>
/// Apply torque according to defined goal `x, y, z` angle and force `strength`.
/// </summary>
public void SetNormalizedTargetRotation(float x, float y, float z, float strength)
{
// Transform values from [-1, 1] to [0, 1]
x = (x + 1f) * 0.5f;
y = (y + 1f) * 0.5f;
z = (z + 1f) * 0.5f;
var xRot = Mathf.Lerp(joint.lowAngularXLimit.limit, joint.highAngularXLimit.limit, x);
var yRot = Mathf.Lerp(-joint.angularYLimit.limit, joint.angularYLimit.limit, y);
var zRot = Mathf.Lerp(-joint.angularZLimit.limit, joint.angularZLimit.limit, z);
joint.targetRotation = Quaternion.Euler(xRot, yRot, zRot);
var jd = new JointDrive
{
positionSpring = ((strength + 1f) * 0.5f) * 10000f,
maximumForce = 250000f
};
joint.slerpDrive = jd;
}
}
/// <summary>
/// Create BodyPart object and add it to dictionary.
/// </summary>
public void SetupBodyPart(Transform t)
{
BodyPart bp = new BodyPart
{
rb = t.GetComponent<Rigidbody>(),
joint = t.GetComponent<ConfigurableJoint>(),
startingPos = t.position,
startingRot = t.rotation
};
bodyParts.Add(t, bp);
bp.groundContact = t.GetComponent<GroundContact>();
}
JointDriveController jdController;
bool isNewDecisionStep;
int currentDecisionStep;
SetupBodyPart(hips);
SetupBodyPart(chest);
SetupBodyPart(spine);
SetupBodyPart(head);
SetupBodyPart(thighL);
SetupBodyPart(shinL);
SetupBodyPart(footL);
SetupBodyPart(thighR);
SetupBodyPart(shinR);
SetupBodyPart(footR);
SetupBodyPart(armL);
SetupBodyPart(forearmL);
SetupBodyPart(handL);
SetupBodyPart(armR);
SetupBodyPart(forearmR);
SetupBodyPart(handR);
}
/// <summary>
/// Obtains joint rotation (in Quaternion) from joint.
/// </summary>
public static Quaternion GetJointRotation(ConfigurableJoint joint)
{
return (Quaternion.FromToRotation(joint.axis, joint.connectedBody.transform.rotation.eulerAngles));
jdController = GetComponent<JointDriveController>();
jdController.SetupBodyPart(hips);
jdController.SetupBodyPart(chest);
jdController.SetupBodyPart(spine);
jdController.SetupBodyPart(head);
jdController.SetupBodyPart(thighL);
jdController.SetupBodyPart(shinL);
jdController.SetupBodyPart(footL);
jdController.SetupBodyPart(thighR);
jdController.SetupBodyPart(shinR);
jdController.SetupBodyPart(footR);
jdController.SetupBodyPart(armL);
jdController.SetupBodyPart(forearmL);
jdController.SetupBodyPart(handL);
jdController.SetupBodyPart(armR);
jdController.SetupBodyPart(forearmR);
jdController.SetupBodyPart(handR);
}
/// <summary>

{
var rb = bp.rb;
AddVectorObs(bp.groundContact.touchingGround ? 1 : 0); // Is this bp touching the ground
bp.groundContact.touchingGround = false;
if (bp.joint && (bp.rb.transform != handL && bp.rb.transform != handR))
if (bp.rb.transform != hips && bp.rb.transform != handL && bp.rb.transform != handR &&
bp.rb.transform != footL && bp.rb.transform != footR && bp.rb.transform != head)
var jointRotation = GetJointRotation(bp.joint);
AddVectorObs(jointRotation); // Get the joint rotation
AddVectorObs(bp.currentXNormalizedRot);
AddVectorObs(bp.currentYNormalizedRot);
AddVectorObs(bp.currentZNormalizedRot);
AddVectorObs(bp.currentStrength / jdController.maxJointForceLimit);
}
}

public override void CollectObservations()
{
AddVectorObs(goalDirection);
foreach (var bodyPart in bodyParts.Values)
jdController.GetCurrentJointForces();
AddVectorObs(dirToTarget.normalized);
AddVectorObs(jdController.bodyPartsDict[hips].rb.position);
AddVectorObs(hips.forward);
AddVectorObs(hips.up);
foreach (var bodyPart in jdController.bodyPartsDict.Values)
{
CollectObservationBodyPart(bodyPart);
}

{
dirToTarget = target.position - jdController.bodyPartsDict[hips].rb.position;
bodyParts[chest].SetNormalizedTargetRotation(vectorAction[0], vectorAction[1], vectorAction[2],
vectorAction[26]);
bodyParts[spine].SetNormalizedTargetRotation(vectorAction[3], vectorAction[4], vectorAction[5],
vectorAction[27]);
if (isNewDecisionStep)
{
var bpDict = jdController.bodyPartsDict;
int i = -1;
bpDict[chest].SetJointTargetRotation(vectorAction[++i], vectorAction[++i], vectorAction[++i]);
bpDict[spine].SetJointTargetRotation(vectorAction[++i], vectorAction[++i], vectorAction[++i]);
bpDict[thighL].SetJointTargetRotation(vectorAction[++i], vectorAction[++i], 0);
bpDict[thighR].SetJointTargetRotation(vectorAction[++i], vectorAction[++i], 0);
bpDict[shinL].SetJointTargetRotation(vectorAction[++i], 0, 0);
bpDict[shinR].SetJointTargetRotation(vectorAction[++i], 0, 0);
bpDict[footR].SetJointTargetRotation(vectorAction[++i], vectorAction[++i], vectorAction[++i]);
bpDict[footL].SetJointTargetRotation(vectorAction[++i], vectorAction[++i], vectorAction[++i]);
bodyParts[thighL].SetNormalizedTargetRotation(vectorAction[6], vectorAction[7], 0, vectorAction[28]);
bodyParts[shinL].SetNormalizedTargetRotation(vectorAction[8], 0, 0, vectorAction[29]);
bodyParts[footL].SetNormalizedTargetRotation(vectorAction[9], vectorAction[10], vectorAction[11],
vectorAction[30]);
bodyParts[thighR].SetNormalizedTargetRotation(vectorAction[12], vectorAction[13], 0, vectorAction[31]);
bodyParts[shinR].SetNormalizedTargetRotation(vectorAction[14], 0, 0, vectorAction[32]);
bodyParts[footR].SetNormalizedTargetRotation(vectorAction[15], vectorAction[16], vectorAction[17],
vectorAction[33]);
bodyParts[armL].SetNormalizedTargetRotation(vectorAction[18], vectorAction[19], 0, vectorAction[34]);
bodyParts[forearmL].SetNormalizedTargetRotation(vectorAction[20], 0, 0, vectorAction[34]);
bodyParts[armR].SetNormalizedTargetRotation(vectorAction[21], vectorAction[22], 0, vectorAction[36]);
bodyParts[forearmR].SetNormalizedTargetRotation(vectorAction[23], 0, 0, vectorAction[37]);
bodyParts[head].SetNormalizedTargetRotation(vectorAction[24], vectorAction[25], 0, vectorAction[38]);
bpDict[armL].SetJointTargetRotation(vectorAction[++i], vectorAction[++i], 0);
bpDict[armR].SetJointTargetRotation(vectorAction[++i], vectorAction[++i], 0);
bpDict[forearmL].SetJointTargetRotation(vectorAction[++i], 0, 0);
bpDict[forearmR].SetJointTargetRotation(vectorAction[++i], 0, 0);
bpDict[head].SetJointTargetRotation(vectorAction[++i], vectorAction[++i], 0);
//update joint strength settings
bpDict[chest].SetJointStrength(vectorAction[++i]);
bpDict[spine].SetJointStrength(vectorAction[++i]);
bpDict[head].SetJointStrength(vectorAction[++i]);
bpDict[thighL].SetJointStrength(vectorAction[++i]);
bpDict[shinL].SetJointStrength(vectorAction[++i]);
bpDict[footL].SetJointStrength(vectorAction[++i]);
bpDict[thighR].SetJointStrength(vectorAction[++i]);
bpDict[shinR].SetJointStrength(vectorAction[++i]);
bpDict[footR].SetJointStrength(vectorAction[++i]);
bpDict[armL].SetJointStrength(vectorAction[++i]);
bpDict[forearmL].SetJointStrength(vectorAction[++i]);
bpDict[armR].SetJointStrength(vectorAction[++i]);
bpDict[forearmR].SetJointStrength(vectorAction[++i]);
}
IncrementDecisionTimer();
// Set reward for this step according to mixture of the following elements.
// a. Velocity alignment with goal direction.

AddReward(
+ 0.03f * Vector3.Dot(goalDirection, bodyParts[hips].rb.velocity)
+ 0.01f * Vector3.Dot(goalDirection, hips.forward)
+ 0.01f * (head.position.y - hips.position.y)
- 0.01f * Vector3.Distance(bodyParts[head].rb.velocity, bodyParts[hips].rb.velocity)
+0.03f * Vector3.Dot(dirToTarget.normalized, jdController.bodyPartsDict[hips].rb.velocity)
+ 0.01f * Vector3.Dot(dirToTarget.normalized, hips.forward)
+ 0.02f * (head.position.y - hips.position.y)
- 0.01f * Vector3.Distance(jdController.bodyPartsDict[head].rb.velocity,
jdController.bodyPartsDict[hips].rb.velocity)
/// Only change the joint settings based on decision frequency.
/// </summary>
public void IncrementDecisionTimer()
{
if (currentDecisionStep == agentParameters.numberOfActionsBetweenDecisions ||
agentParameters.numberOfActionsBetweenDecisions == 1)
{
currentDecisionStep = 1;
isNewDecisionStep = true;
}
else
{
currentDecisionStep++;
isNewDecisionStep = false;
}
}
/// <summary>
transform.rotation = Quaternion.LookRotation(goalDirection);
foreach (var bodyPart in bodyParts.Values)
if (dirToTarget != Vector3.zero)
bodyPart.Reset();
transform.rotation = Quaternion.LookRotation(dirToTarget);
foreach (var bodyPart in jdController.bodyPartsDict.Values)
{
bodyPart.Reset(bodyPart);
}
isNewDecisionStep = true;
currentDecisionStep = 1;
}
}

985
unity-environment/Assets/ML-Agents/Examples/Walker/TFModels/Walker.bytes
文件差异内容过多而无法显示
查看文件

2
unity-environment/Assets/ML-Agents/Examples/Walker/TFModels/Walker.bytes.meta


fileFormatVersion: 2
guid: 6f158a795796a47a68104cc5eff941a1
guid: 8d3f9a4b927984343b18c82559165047
TextScriptImporter:
externalObjects: {}
userData:

1
unity-environment/ProjectSettings/EditorBuildSettings.asset


EditorBuildSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Scenes: []
m_configObjects: {}

14
unity-environment/ProjectSettings/ProjectSettings.asset


xboxOneLoggingLevel: 1
xboxOneDisableEsram: 0
xboxOnePresentImmediateThreshold: 0
switchQueueCommandMemory: 0
videoMemoryForVertexBuffers: 0
psp2PowerMode: 0
psp2AcquireBGM: 1

appleDeveloperTeamID:
iOSManualSigningProvisioningProfileID:
tvOSManualSigningProvisioningProfileID:
iOSManualSigningProvisioningProfileType: 0
tvOSManualSigningProvisioningProfileType: 0
appleEnableAutomaticSigning: 0
iOSRequireARKit: 0
appleEnableProMotion: 0

webGLLinkerTarget: 0
scriptingDefineSymbols:
1:
7: UNITY_POST_PROCESSING_STACK_V2
13: UNITY_POST_PROCESSING_STACK_V2
14: UNITY_POST_PROCESSING_STACK_V2
17: UNITY_POST_PROCESSING_STACK_V2
18: UNITY_POST_PROCESSING_STACK_V2
19: UNITY_POST_PROCESSING_STACK_V2
21: UNITY_POST_PROCESSING_STACK_V2
23: UNITY_POST_PROCESSING_STACK_V2
25: UNITY_POST_PROCESSING_STACK_V2
26: UNITY_POST_PROCESSING_STACK_V2
27: UNITY_POST_PROCESSING_STACK_V2
platformArchitecture: {}
scriptingBackend: {}
il2cppCompilerConfiguration: {}

8
unity-environment/Assets/ML-Agents/Examples/Crawler/Materials.meta


fileFormatVersion: 2
guid: 1b2e258570af540139c1ef84be60b3ea
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

1001
unity-environment/Assets/ML-Agents/Examples/Crawler/Prefabs/DynamicPlatform.prefab
文件差异内容过多而无法显示
查看文件

8
unity-environment/Assets/ML-Agents/Examples/Crawler/Prefabs/DynamicPlatform.prefab.meta


fileFormatVersion: 2
guid: 0058b366f9d6d44a3ba35beb06b0174b
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 100100000
userData:
assetBundleName:
assetBundleVariant:

1001
unity-environment/Assets/ML-Agents/Examples/Crawler/Prefabs/FixedPlatform.prefab
文件差异内容过多而无法显示
查看文件

8
unity-environment/Assets/ML-Agents/Examples/Crawler/Prefabs/FixedPlatform.prefab.meta


fileFormatVersion: 2
guid: 1b9d167a4e71146a883212e4f08bda88
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 100100000
userData:
assetBundleName:
assetBundleVariant:

8
unity-environment/Assets/ML-Agents/Examples/Crawler/Scenes.meta


fileFormatVersion: 2
guid: 60c86839d191546c9bf58ce6a2824987
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

269
unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAgent.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MLAgents;
[RequireComponent(typeof(JointDriveController))] // Required to set joint forces
public class CrawlerAgent : Agent
{
[Header("Target To Walk Towards")] [Space(10)]
public Transform target;
public Transform ground;
public bool detectTargets;
public bool respawnTargetWhenTouched;
public float targetSpawnRadius;
[Header("Body Parts")] [Space(10)] public Transform body;
public Transform leg0Upper;
public Transform leg0Lower;
public Transform leg1Upper;
public Transform leg1Lower;
public Transform leg2Upper;
public Transform leg2Lower;
public Transform leg3Upper;
public Transform leg3Lower;
[Header("Joint Settings")] [Space(10)] JointDriveController jdController;
Vector3 dirToTarget;
float movingTowardsDot;
float facingDot;
[Header("Reward Functions To Use")] [Space(10)]
public bool rewardMovingTowardsTarget; // Agent should move towards target
public bool rewardFacingTarget; // Agent should face the target
public bool rewardUseTimePenalty; // Hurry up
[Header("Foot Grounded Visualization")] [Space(10)]
public bool useFootGroundedVisualization;
public MeshRenderer foot0;
public MeshRenderer foot1;
public MeshRenderer foot2;
public MeshRenderer foot3;
public Material groundedMaterial;
public Material unGroundedMaterial;
bool isNewDecisionStep;
int currentDecisionStep;
public override void InitializeAgent()
{
jdController = GetComponent<JointDriveController>();
currentDecisionStep = 1;
//Setup each body part
jdController.SetupBodyPart(body);
jdController.SetupBodyPart(leg0Upper);
jdController.SetupBodyPart(leg0Lower);
jdController.SetupBodyPart(leg1Upper);
jdController.SetupBodyPart(leg1Lower);
jdController.SetupBodyPart(leg2Upper);
jdController.SetupBodyPart(leg2Lower);
jdController.SetupBodyPart(leg3Upper);
jdController.SetupBodyPart(leg3Lower);
}
/// <summary>
/// We only need to change the joint settings based on decision freq.
/// </summary>
public void IncrementDecisionTimer()
{
if (currentDecisionStep == agentParameters.numberOfActionsBetweenDecisions
|| agentParameters.numberOfActionsBetweenDecisions == 1)
{
currentDecisionStep = 1;
isNewDecisionStep = true;
}
else
{
currentDecisionStep++;
isNewDecisionStep = false;
}
}
/// <summary>
/// Add relevant information on each body part to observations.
/// </summary>
public void CollectObservationBodyPart(BodyPart bp)
{
var rb = bp.rb;
AddVectorObs(bp.groundContact.touchingGround ? 1 : 0); // Whether the bp touching the ground
AddVectorObs(rb.velocity);
AddVectorObs(rb.angularVelocity);
if (bp.rb.transform != body)
{
Vector3 localPosRelToBody = body.InverseTransformPoint(rb.position);
AddVectorObs(localPosRelToBody);
AddVectorObs(bp.currentXNormalizedRot); // Current x rot
AddVectorObs(bp.currentYNormalizedRot); // Current y rot
AddVectorObs(bp.currentZNormalizedRot); // Current z rot
AddVectorObs(bp.currentStrength / jdController.maxJointForceLimit);
}
}
public override void CollectObservations()
{
jdController.GetCurrentJointForces();
// Normalize dir vector to help generalize
AddVectorObs(dirToTarget.normalized);
// Forward & up to help with orientation
AddVectorObs(body.transform.position.y);
AddVectorObs(body.forward);
AddVectorObs(body.up);
foreach (var bodyPart in jdController.bodyPartsDict.Values)
{
CollectObservationBodyPart(bodyPart);
}
}
/// <summary>
/// Agent touched the target
/// </summary>
public void TouchedTarget()
{
AddReward(1f);
if (respawnTargetWhenTouched)
{
GetRandomTargetPos();
}
}
/// <summary>
/// Moves target to a random position within specified radius.
/// </summary>
public void GetRandomTargetPos()
{
Vector3 newTargetPos = Random.insideUnitSphere * targetSpawnRadius;
newTargetPos.y = 5;
target.position = newTargetPos + ground.position;
}
public override void AgentAction(float[] vectorAction, string textAction)
{
if (detectTargets)
{
foreach (var bodyPart in jdController.bodyPartsDict.Values)
{
if (bodyPart.targetContact && !IsDone() && bodyPart.targetContact.touchingTarget)
{
TouchedTarget();
}
}
}
// Update pos to target
dirToTarget = target.position - jdController.bodyPartsDict[body].rb.position;
// If enabled the feet will light up green when the foot is grounded.
// This is just a visualization and isn't necessary for function
if (useFootGroundedVisualization)
{
foot0.material = jdController.bodyPartsDict[leg0Lower].groundContact.touchingGround
? groundedMaterial
: unGroundedMaterial;
foot1.material = jdController.bodyPartsDict[leg1Lower].groundContact.touchingGround
? groundedMaterial
: unGroundedMaterial;
foot2.material = jdController.bodyPartsDict[leg2Lower].groundContact.touchingGround
? groundedMaterial
: unGroundedMaterial;
foot3.material = jdController.bodyPartsDict[leg3Lower].groundContact.touchingGround
? groundedMaterial
: unGroundedMaterial;
}
// Joint update logic only needs to happen when a new decision is made
if (isNewDecisionStep)
{
// The dictionary with all the body parts in it are in the jdController
var bpDict = jdController.bodyPartsDict;
int i = -1;
// Pick a new target joint rotation
bpDict[leg0Upper].SetJointTargetRotation(vectorAction[++i], vectorAction[++i], 0);
bpDict[leg1Upper].SetJointTargetRotation(vectorAction[++i], vectorAction[++i], 0);
bpDict[leg2Upper].SetJointTargetRotation(vectorAction[++i], vectorAction[++i], 0);
bpDict[leg3Upper].SetJointTargetRotation(vectorAction[++i], vectorAction[++i], 0);
bpDict[leg0Lower].SetJointTargetRotation(vectorAction[++i], 0, 0);
bpDict[leg1Lower].SetJointTargetRotation(vectorAction[++i], 0, 0);
bpDict[leg2Lower].SetJointTargetRotation(vectorAction[++i], 0, 0);
bpDict[leg3Lower].SetJointTargetRotation(vectorAction[++i], 0, 0);
// Update joint strength
bpDict[leg0Upper].SetJointStrength(vectorAction[++i]);
bpDict[leg1Upper].SetJointStrength(vectorAction[++i]);
bpDict[leg2Upper].SetJointStrength(vectorAction[++i]);
bpDict[leg3Upper].SetJointStrength(vectorAction[++i]);
bpDict[leg0Lower].SetJointStrength(vectorAction[++i]);
bpDict[leg1Lower].SetJointStrength(vectorAction[++i]);
bpDict[leg2Lower].SetJointStrength(vectorAction[++i]);
bpDict[leg3Lower].SetJointStrength(vectorAction[++i]);
}
// Set reward for this step according to mixture of the following elements.
if (rewardMovingTowardsTarget)
{
RewardFunctionMovingTowards();
}
if (rewardFacingTarget)
{
RewardFunctionFacingTarget();
}
if (rewardUseTimePenalty)
{
RewardFunctionTimePenalty();
}
IncrementDecisionTimer();
}
/// <summary>
/// Reward moving towards target & Penalize moving away from target.
/// </summary>
void RewardFunctionMovingTowards()
{
movingTowardsDot = Vector3.Dot(jdController.bodyPartsDict[body].rb.velocity, dirToTarget.normalized);
AddReward(0.03f * movingTowardsDot);
}
/// <summary>
/// Reward facing target & Penalize facing away from target
/// </summary>
void RewardFunctionFacingTarget()
{
facingDot = Vector3.Dot(dirToTarget.normalized, body.forward);
AddReward(0.01f * facingDot);
}
/// <summary>
/// Existential penalty for time-contrained tasks.
/// </summary>
void RewardFunctionTimePenalty()
{
AddReward(-0.001f);
}
/// <summary>
/// Loop over body parts and reset them to initial conditions.
/// </summary>
public override void AgentReset()
{
if (dirToTarget != Vector3.zero)
{
transform.rotation = Quaternion.LookRotation(dirToTarget);
}
foreach (var bodyPart in jdController.bodyPartsDict.Values)
{
bodyPart.Reset(bodyPart);
}
isNewDecisionStep = true;
currentDecisionStep = 1;
}
}

13
unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAgent.cs.meta


fileFormatVersion: 2
guid: 2f37c30a5e8d04117947188818902ef3
timeCreated: 1525902546
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

1001
unity-environment/Assets/ML-Agents/Examples/Crawler/TFModels/DynamicCrawler.bytes
文件差异内容过多而无法显示
查看文件

7
unity-environment/Assets/ML-Agents/Examples/Crawler/TFModels/DynamicCrawler.bytes.meta


fileFormatVersion: 2
guid: 310a6ef92323640b48a7342988a69466
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

1001
unity-environment/Assets/ML-Agents/Examples/Crawler/TFModels/FixedCrawler.bytes
文件差异内容过多而无法显示
查看文件

7
unity-environment/Assets/ML-Agents/Examples/Crawler/TFModels/FixedCrawler.bytes.meta


fileFormatVersion: 2
guid: 24ef4b74625ba4c53b782ec33ad9f7d6
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

76
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/DarkGridFloor.mat


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: DarkGridFloor
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords: _GLOSSYREFLECTIONS_OFF _SPECULARHIGHLIGHTS_OFF
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 200, y: 100}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: eb3fbc74cf5a94322bfcd3a9136f2d57, type: 3}
m_Scale: {x: 200, y: 100}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0
- _GlossyReflections: 0
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 0
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 0, g: 0.7255683, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

8
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/DarkGridFloor.mat.meta

<

fileFormatVersion: 2
guid: f79af4fbbccd341578da68fd5d3c7e0d
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName: