浏览代码

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 6 年前
当前提交
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:
assetBundleVariant:

76
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/LightGridFloor.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: LightGridFloor
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: 150, y: 5}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: 9f297c7b7df5644da8b28a9b44692230, type: 3}
m_Scale: {x: 150, y: 5}
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: 0
- _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.735849, g: 0.735849, b: 0.735849, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

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


fileFormatVersion: 2
guid: 7c6faed37a5e84a94aa60c2eb61dd263
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

76
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/LightGridFloorSquare.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: LightGridFloorSquare
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: 5, y: 5}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: 9f297c7b7df5644da8b28a9b44692230, type: 3}
m_Scale: {x: 5, y: 5}
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: 0
- _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.735849, g: 0.735849, b: 0.735849, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

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


fileFormatVersion: 2
guid: 97796528aca714d159b1093f49bca242
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

76
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/White.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: White
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: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
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.107
- _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.8962264, g: 0.8962264, b: 0.8962264, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

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


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

3
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/gridTexture.png
文件差异内容过多而无法显示
查看文件

84
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/gridTexture.png.meta


fileFormatVersion: 2
guid: eb3fbc74cf5a94322bfcd3a9136f2d57
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 5
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -1
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

195
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/gridTextureWhite.psd
文件差异内容过多而无法显示
查看文件

84
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/gridTextureWhite.psd.meta


fileFormatVersion: 2
guid: 9f297c7b7df5644da8b28a9b44692230
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 5
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -1
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:

76
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/groundGreen.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: groundGreen
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: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
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.64005125, g: 0.755, b: 0.517175, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

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


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

76
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/groundGrey.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: groundGrey
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: 0}
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: 0
- _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.56766325, g: 0.6431373, b: 0.38652548, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

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


fileFormatVersion: 2
guid: 45a6675c4c7774fbdaf694dff79b2f7a
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

76
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Materials/groundRed.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: groundRed
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: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
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.703, g: 0.30088398, b: 0.30088398, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

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


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

58
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Scripts/AdjustTrainingTimescale.cs


//This script lets you change time scale during training. It is not a required script for this demo to function
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MLAgents
{
public class AdjustTrainingTimescale : MonoBehaviour {
// Update is called once per frame
void Update ()
{
if (Input.GetKeyDown(KeyCode.Alpha1))
{
Time.timeScale = 1f;
}
if (Input.GetKeyDown(KeyCode.Alpha2))
{
Time.timeScale = 2f;
}
if (Input.GetKeyDown(KeyCode.Alpha3))
{
Time.timeScale = 3f;
}
if (Input.GetKeyDown(KeyCode.Alpha4))
{
Time.timeScale = 4f;
}
if (Input.GetKeyDown(KeyCode.Alpha5))
{
Time.timeScale = 5f;
}
if (Input.GetKeyDown(KeyCode.Alpha6))
{
Time.timeScale = 6f;
}
if (Input.GetKeyDown(KeyCode.Alpha7))
{
Time.timeScale = 7f;
}
if (Input.GetKeyDown(KeyCode.Alpha8))
{
Time.timeScale = 8f;
}
if (Input.GetKeyDown(KeyCode.Alpha9))
{
Time.timeScale = 9f;
}
if (Input.GetKeyDown(KeyCode.Alpha0))
{
Time.timeScale *= 2f;
}
}
}
}

11
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Scripts/AdjustTrainingTimescale.cs.meta


fileFormatVersion: 2
guid: 3d6f3eab3776b4fb79724ac4216dfd7b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

178
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Scripts/JointDriveController.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MLAgents
{
/// <summary>
/// Used to store relevant information for acting and learning for each body part in agent.
/// </summary>
[System.Serializable]
public class BodyPart
{
[Header("Body Part Info")] [Space(10)] public ConfigurableJoint joint;
public Rigidbody rb;
[HideInInspector] public Vector3 startingPos;
[HideInInspector] public Quaternion startingRot;
[Header("Ground & Target Contact")] [Space(10)]
public GroundContact groundContact;
public TargetContact targetContact;
[HideInInspector] public JointDriveController thisJDController;
[Header("Current Joint Settings")] [Space(10)]
public Vector3 currentEularJointRotation;
[HideInInspector] public float currentStrength;
public float currentXNormalizedRot;
public float currentYNormalizedRot;
public float currentZNormalizedRot;
[Header("Other Debug Info")] [Space(10)]
public Vector3 currentJointForce;
public float currentJointForceSqrMag;
public Vector3 currentJointTorque;
public float currentJointTorqueSqrMag;
public AnimationCurve jointForceCurve = new AnimationCurve();
public AnimationCurve jointTorqueCurve = new AnimationCurve();
/// <summary>
/// Reset body part to initial configuration.
/// </summary>
public void Reset(BodyPart bp)
{
bp.rb.transform.position = bp.startingPos;
bp.rb.transform.rotation = bp.startingRot;
bp.rb.velocity = Vector3.zero;
bp.rb.angularVelocity = Vector3.zero;
if (bp.groundContact)
{
bp.groundContact.touchingGround = false;
}
if (bp.targetContact)
{
bp.targetContact.touchingTarget = false;
}
}
/// <summary>
/// Apply torque according to defined goal `x, y, z` angle and force `strength`.
/// </summary>
public void SetJointTargetRotation(float x, float y, float z)
{
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);
currentXNormalizedRot =
Mathf.InverseLerp(joint.lowAngularXLimit.limit, joint.highAngularXLimit.limit, xRot);
currentYNormalizedRot = Mathf.InverseLerp(-joint.angularYLimit.limit, joint.angularYLimit.limit, yRot);
currentZNormalizedRot = Mathf.InverseLerp(-joint.angularZLimit.limit, joint.angularZLimit.limit, zRot);
joint.targetRotation = Quaternion.Euler(xRot, yRot, zRot);
currentEularJointRotation = new Vector3(xRot, yRot, zRot);
}
public void SetJointStrength(float strength)
{
var rawVal = (strength + 1f) * 0.5f * thisJDController.maxJointForceLimit;
var jd = new JointDrive
{
positionSpring = thisJDController.maxJointSpring,
positionDamper = thisJDController.jointDampen,
maximumForce = rawVal
};
joint.slerpDrive = jd;
currentStrength = jd.maximumForce;
}
}
public class JointDriveController : MonoBehaviour
{
[Header("Joint Drive Settings")] [Space(10)]
public float maxJointSpring;
public float jointDampen;
public float maxJointForceLimit;
float facingDot;
[HideInInspector] public Dictionary<Transform, BodyPart> bodyPartsDict = new Dictionary<Transform, BodyPart>();
[HideInInspector] public List<BodyPart> bodyPartsList = new List<BodyPart>();
/// <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
};
bp.rb.maxAngularVelocity = 100;
// Add & setup the ground contact script
bp.groundContact = t.GetComponent<GroundContact>();
if (!bp.groundContact)
{
bp.groundContact = t.gameObject.AddComponent<GroundContact>();
bp.groundContact.agent = gameObject.GetComponent<Agent>();
}
else
{
bp.groundContact.agent = gameObject.GetComponent<Agent>();
}
// Add & setup the target contact script
bp.targetContact = t.GetComponent<TargetContact>();
if (!bp.targetContact)
{
bp.targetContact = t.gameObject.AddComponent<TargetContact>();
}
bp.thisJDController = this;
bodyPartsDict.Add(t, bp);
bodyPartsList.Add(bp);
}
public void GetCurrentJointForces()
{
foreach (var bodyPart in bodyPartsDict.Values)
{
if (bodyPart.joint)
{
bodyPart.currentJointForce = bodyPart.joint.currentForce;
bodyPart.currentJointForceSqrMag = bodyPart.joint.currentForce.magnitude;
bodyPart.currentJointTorque = bodyPart.joint.currentTorque;
bodyPart.currentJointTorqueSqrMag = bodyPart.joint.currentTorque.magnitude;
if (Application.isEditor)
{
if (bodyPart.jointForceCurve.length > 1000)
{
bodyPart.jointForceCurve = new AnimationCurve();
}
if (bodyPart.jointTorqueCurve.length > 1000)
{
bodyPart.jointTorqueCurve = new AnimationCurve();
}
bodyPart.jointForceCurve.AddKey(Time.time, bodyPart.currentJointForceSqrMag);
bodyPart.jointTorqueCurve.AddKey(Time.time, bodyPart.currentJointTorqueSqrMag);
}
}
}
}
}
}

11
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Scripts/JointDriveController.cs.meta


fileFormatVersion: 2
guid: 1b29724baddfa457da6eeab446fa49ca
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

40
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Scripts/TargetContact.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace MLAgents
{
/// <summary>
/// This class contains logic for locomotion agents with joints which might make contact with a target.
/// By attaching this as a component to those joints, their contact with the ground can be used as
/// an observation for that agent.
/// </summary>
[DisallowMultipleComponent]
public class TargetContact : MonoBehaviour
{
[Header("Detect Targets")] public bool touchingTarget;
private const string Target = "target"; // Tag on target object.
/// <summary>
/// Check for collision with a target.
/// </summary>
void OnCollisionEnter(Collision col)
{
if (col.transform.CompareTag(Target))
{
touchingTarget = true;
}
}
/// <summary>
/// Check for end of ground collision and reset flag appropriately.
/// </summary>
void OnCollisionExit(Collision other)
{
if (other.transform.CompareTag(Target))
{
touchingTarget = false;
}
}
}
}

11
unity-environment/Assets/ML-Agents/Examples/SharedAssets/Scripts/TargetContact.cs.meta


fileFormatVersion: 2
guid: 5086c435d3e8b44ffa8262a5c124661f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

76
unity-environment/Assets/ML-Agents/Examples/Walker/Materials/LightGridFloorWalker.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: LightGridFloorWalker
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: 75}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: 9f297c7b7df5644da8b28a9b44692230, type: 3}
m_Scale: {x: 200, y: 75}
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: 0
- _Glossiness: 1
- _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: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

8
unity-environment/Assets/ML-Agents/Examples/Walker/Materials/LightGridFloorWalker.mat.meta


fileFormatVersion: 2
guid: 11fc213bb7ed74bfaadd6ac3a2ca6213
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

180
unity-environment/Assets/ML-Agents/Examples/Walker/Prefabs/TARGET.prefab


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 1278435835893344}
m_IsPrefabParent: 1
--- !u!1 &1004696678722388
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4445455656062608}
- component: {fileID: 108207800777520784}
m_Layer: 0
m_Name: Point Light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1278435835893344
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4160558395918834}
- component: {fileID: 33482419447541750}
- component: {fileID: 65421899250293674}
- component: {fileID: 23182017856683736}
- component: {fileID: 54584795304850826}
m_Layer: 0
m_Name: TARGET
m_TagString: target
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4160558395918834
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1278435835893344}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 1000, y: 4, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 4445455656062608}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4445455656062608
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1004696678722388}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 4160558395918834}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &23182017856683736
MeshRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1278435835893344}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 4294967295
m_Materials:
- {fileID: 2100000, guid: edd958d75ed1448138de86f3335ea4fa, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!33 &33482419447541750
MeshFilter:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1278435835893344}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!54 &54584795304850826
Rigidbody:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1278435835893344}
serializedVersion: 2
m_Mass: 5
m_Drag: 0
m_AngularDrag: 0.05
m_UseGravity: 1
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!65 &65421899250293674
BoxCollider:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1278435835893344}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!108 &108207800777520784
Light:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1004696678722388}
m_Enabled: 1
serializedVersion: 8
m_Type: 2
m_Color: {r: 1, g: 0.85834146, b: 0.472, a: 1}
m_Intensity: 2
m_Range: 15
m_SpotAngle: 30
m_CookieSize: 10
m_Shadows:
m_Type: 0
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0

8
unity-environment/Assets/ML-Agents/Examples/Walker/Prefabs/TARGET.prefab.meta


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

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

8
unity-environment/Assets/ML-Agents/Examples/Walker/Prefabs/WalkerPair.prefab.meta


fileFormatVersion: 2
guid: 94dced9d2186d4a76b970fb18ef6d7a6
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 100100000
userData:
assetBundleName:
assetBundleVariant:

76
unity-environment/Assets/ML-Agents/Examples/Crawler/Materials/DarkGridFloorMovingTargetCrawler.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: DarkGridFloorMovingTargetCrawler
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: 5, y: 5}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: eb3fbc74cf5a94322bfcd3a9136f2d57, type: 3}
m_Scale: {x: 5, y: 5}
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: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

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


fileFormatVersion: 2
guid: 82789c563353741debf1645e133f6d29
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

76
unity-environment/Assets/ML-Agents/Examples/Crawler/Materials/DarkGridFloorStaticCrawler.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: DarkGridFloorStaticCrawler
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: 50, y: 2.5}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: eb3fbc74cf5a94322bfcd3a9136f2d57, type: 3}
m_Scale: {x: 50, y: 2.5}
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: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

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


fileFormatVersion: 2
guid: b7f3bd8fd3ae84ccfabb8a9421031bcd
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

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

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


fileFormatVersion: 2
guid: cb09636e2bfd74254939fe22b12c28e1
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

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

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


fileFormatVersion: 2
guid: d9a4e7d08037d49c895555d4fe344764
timeCreated: 1508521562
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

12
unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAgentConfigurable.cs.meta


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

19
unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerBodyContact.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CrawlerBodyContact : MonoBehaviour {
CrawlerAgentConfigurable agent;
void Start(){
agent = gameObject.transform.parent.gameObject.GetComponent<CrawlerAgentConfigurable>();
}
void OnTriggerEnter(Collider other){
if (other.gameObject.name == "Ground")
{
agent.fell = true;
}
}
}

12
unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerBodyContact.cs.meta


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

21
unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerLegContact.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CrawlerLegContact : MonoBehaviour {
public int index;
public CrawlerAgentConfigurable agent;
void Start(){
}
void OnCollisionStay(Collision other){
if (other.gameObject.name == "Ground")
{
agent.leg_touching[index] = true;
}
}
}

12
unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerLegContact.cs.meta


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

137
unity-environment/Assets/ML-Agents/Examples/Crawler/Scripts/CrawlerAgentConfigurable.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MLAgents;
public class CrawlerAgentConfigurable : Agent
{
public float strength;
float x_position;
[HideInInspector]
public bool[] leg_touching;
[HideInInspector]
public bool fell;
Vector3 past_velocity;
Transform body;
Rigidbody bodyRB;
public Transform[] limbs;
Rigidbody[] limbRBs;
Dictionary<GameObject, Vector3> transformsPosition;
Dictionary<GameObject, Quaternion> transformsRotation;
public override void InitializeAgent()
{
body = transform.Find("Sphere");
bodyRB = body.GetComponent<Rigidbody>();
transformsPosition = new Dictionary<GameObject, Vector3>();
transformsRotation = new Dictionary<GameObject, Quaternion>();
Transform[] allChildren = GetComponentsInChildren<Transform>();
foreach (Transform child in allChildren)
{
transformsPosition[child.gameObject] = child.position;
transformsRotation[child.gameObject] = child.rotation;
}
leg_touching = new bool[4];
limbRBs = new Rigidbody[limbs.Length];
for (int i = 0; i < limbs.Length; i++)
{
limbRBs[i] = limbs[i].gameObject.GetComponent<Rigidbody>();
}
}
public override void CollectObservations()
{
AddVectorObs(body.transform.rotation.eulerAngles);
AddVectorObs(bodyRB.velocity);
AddVectorObs((bodyRB.velocity - past_velocity) / Time.fixedDeltaTime);
past_velocity = bodyRB.velocity;
for (int i = 0; i < limbs.Length; i++)
{
AddVectorObs(limbs[i].localPosition);
AddVectorObs(limbs[i].localRotation);
AddVectorObs(limbRBs[i].velocity);
AddVectorObs(limbRBs[i].angularVelocity);
}
for (int index = 0; index < 4; index++)
{
if (leg_touching[index])
{
AddVectorObs(1);
}
else
{
AddVectorObs(0);
}
leg_touching[index] = false;
}
}
public override void AgentAction(float[] vectorAction, string textAction)
{
var toUse = new float[vectorAction.Length];
var torquePenalty = 0f;
for (int k = 0; k < vectorAction.Length; k++)
{
toUse[k] = 1.5f * Mathf.Clamp(vectorAction[k], -1f, 1f);
torquePenalty += toUse[k] * toUse[k];
}
limbRBs[0].AddTorque(-limbs[0].transform.right * strength * toUse[0]);
limbRBs[1].AddTorque(-limbs[1].transform.right * strength * toUse[1]);
limbRBs[2].AddTorque(-limbs[2].transform.right * strength * toUse[2]);
limbRBs[3].AddTorque(-limbs[3].transform.right * strength * toUse[3]);
limbRBs[0].AddTorque(-body.transform.up * strength * toUse[4]);
limbRBs[1].AddTorque(-body.transform.up * strength * toUse[5]);
limbRBs[2].AddTorque(-body.transform.up * strength * toUse[6]);
limbRBs[3].AddTorque(-body.transform.up * strength * toUse[7]);
limbRBs[4].AddTorque(-limbs[4].transform.right * strength * toUse[8]);
limbRBs[5].AddTorque(-limbs[5].transform.right * strength * toUse[9]);
limbRBs[6].AddTorque(-limbs[6].transform.right * strength * toUse[10]);
limbRBs[7].AddTorque(-limbs[7].transform.right * strength * toUse[11]);
if (!IsDone())
{
SetReward(- 0.01f * torquePenalty
+ 1.0f * bodyRB.velocity.x
- 0.05f * Mathf.Abs(body.transform.position.z - body.transform.parent.transform.position.z)
- 0.05f * Mathf.Abs(bodyRB.velocity.y)
);
}
if (fell)
{
Done();
AddReward(-1f);
}
}
public override void AgentReset()
{
fell = false;
Transform[] allChildren = GetComponentsInChildren<Transform>();
foreach (Transform child in allChildren)
{
if (child.gameObject.name.Contains("Crawler")
|| child.gameObject.name.Contains("parent"))
{
continue;
}
child.position = transformsPosition[child.gameObject];
child.rotation = transformsRotation[child.gameObject];
child.gameObject.GetComponent<Rigidbody>().velocity = default(Vector3);
child.gameObject.GetComponent<Rigidbody>().angularVelocity = default(Vector3);
}
gameObject.transform.rotation = Quaternion.Euler(new Vector3(0, Random.value * 90 - 45, 0));
}
public override void AgentOnDone()
{
}
}

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

正在加载...
取消
保存