浏览代码

Feature/new wall jump (#446)

* [New Environment] Added the WallJump and its configuration

* [Documentation] Added the WallJump doc

* [Fixes] Now uses switch and added comment
/develop-generalizationTraining-TrainerController
GitHub 7 年前
当前提交
d8c09831
共有 29 个文件被更改,包括 3547 次插入691 次删除
  1. 8
      docs/Learning-Environment-Examples.md
  2. 865
      docs/images/wall.png
  3. 22
      python/trainer_config.yaml
  4. 9
      unity-environment/Assets/ML-Agents/Examples/WallJump.meta
  5. 10
      unity-environment/Assets/ML-Agents/Examples/WallJump/Material.meta
  6. 77
      unity-environment/Assets/ML-Agents/Examples/WallJump/Material/spawnVolumeMaterial.mat
  7. 10
      unity-environment/Assets/ML-Agents/Examples/WallJump/Material/spawnVolumeMaterial.mat.meta
  8. 77
      unity-environment/Assets/ML-Agents/Examples/WallJump/Material/wallMaterial.mat
  9. 10
      unity-environment/Assets/ML-Agents/Examples/WallJump/Material/wallMaterial.mat.meta
  10. 10
      unity-environment/Assets/ML-Agents/Examples/WallJump/Prefabs.meta
  11. 700
      unity-environment/Assets/ML-Agents/Examples/WallJump/Prefabs/WallJumpArea.prefab
  12. 9
      unity-environment/Assets/ML-Agents/Examples/WallJump/Prefabs/WallJumpArea.prefab.meta
  13. 10
      unity-environment/Assets/ML-Agents/Examples/WallJump/Scenes.meta
  14. 1001
      unity-environment/Assets/ML-Agents/Examples/WallJump/Scenes/WallJump.unity
  15. 9
      unity-environment/Assets/ML-Agents/Examples/WallJump/Scenes/WallJump.unity.meta
  16. 10
      unity-environment/Assets/ML-Agents/Examples/WallJump/Scripts.meta
  17. 28
      unity-environment/Assets/ML-Agents/Examples/WallJump/Scripts/WallJumpAcademy.cs
  18. 13
      unity-environment/Assets/ML-Agents/Examples/WallJump/Scripts/WallJumpAcademy.cs.meta
  19. 327
      unity-environment/Assets/ML-Agents/Examples/WallJump/Scripts/WallJumpAgent.cs
  20. 13
      unity-environment/Assets/ML-Agents/Examples/WallJump/Scripts/WallJumpAgent.cs.meta
  21. 10
      unity-environment/Assets/ML-Agents/Examples/WallJump/TFModels.meta
  22. 1001
      unity-environment/Assets/ML-Agents/Examples/WallJump/TFModels/WallJump.bytes
  23. 9
      unity-environment/Assets/ML-Agents/Examples/WallJump/TFModels/WallJump.bytes.meta

8
docs/Learning-Environment-Examples.md


* Set-up: A platforming environment where the agent can jump over a wall.
* Goal: The agent must use the block to scale the wall and reach the goal.
* Agents: The environment contains one agent linked to a single brain.
* Agents: The environment contains one agent linked to two different brains. The brain the agent is linked to changes depending on the height of the wall.
* -0.01 for every step.
* -0.0005 for every step.
* Vector Action space: (Discrete) Size of 6, corresponding to movement in cardinal directions, jumping, and no movement.
* Vector Action space: (Discrete) Size of 74, corresponding to 14 raycasts each detecting 4 possible objects. plus the global position of the agent and whether or not the agent is grounded.
* Reset Parameters: One, corresponding to number of steps in training. Used to adjust size of the wall for Curriculum Learning.
* Reset Parameters: 4, corresponding to the height of the possible walls.
## Reacher

865
docs/images/wall.png

之前 之后
宽度: 942  |  高度: 780  |  大小: 42 KiB

22
python/trainer_config.yaml


time_horizon: 64
num_layers: 2
SmallWallBrain:
max_steps: 2.0e5
batch_size: 128
buffer_size: 2048
beta: 5.0e-3
hidden_units: 256
summary_freq: 2000
time_horizon: 128
num_layers: 2
normalize: false
BigWallBrain:
max_steps: 2.0e5
batch_size: 128
buffer_size: 2048
beta: 5.0e-3
hidden_units: 256
summary_freq: 2000
time_horizon: 128
num_layers: 2
normalize: false
StrikerBrain:
max_steps: 1.0e5
batch_size: 128

9
unity-environment/Assets/ML-Agents/Examples/WallJump.meta


fileFormatVersion: 2
guid: e61aed11f93544227801dfd529bf41c6
folderAsset: yes
timeCreated: 1520964896
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

10
unity-environment/Assets/ML-Agents/Examples/WallJump/Material.meta


fileFormatVersion: 2
guid: 3002d747534d24598b059f75c43b8d45
folderAsset: yes
timeCreated: 1517448702
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

77
unity-environment/Assets/ML-Agents/Examples/WallJump/Material/spawnVolumeMaterial.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: spawnVolumeMaterial
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords: _ALPHABLEND_ON
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: 3000
stringTagMap:
RenderType: Transparent
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: 10
- _GlossMapScale: 1
- _Glossiness: 0
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 2
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 5
- _UVSec: 0
- _ZWrite: 0
m_Colors:
- _Color: {r: 0, g: 0.83448315, b: 1, a: 0.303}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

10
unity-environment/Assets/ML-Agents/Examples/WallJump/Material/spawnVolumeMaterial.mat.meta


fileFormatVersion: 2
guid: ecd59def9213741058b969f699d10e8e
timeCreated: 1506376733
licenseType: Pro
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

77
unity-environment/Assets/ML-Agents/Examples/WallJump/Material/wallMaterial.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: wallMaterial
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords: _ALPHABLEND_ON
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: 3000
stringTagMap:
RenderType: Transparent
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: 10
- _GlossMapScale: 1
- _Glossiness: 0
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 2
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 5
- _UVSec: 0
- _ZWrite: 0
m_Colors:
- _Color: {r: 0.56228375, g: 0.76044035, b: 0.9558824, a: 0.603}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

10
unity-environment/Assets/ML-Agents/Examples/WallJump/Material/wallMaterial.mat.meta


fileFormatVersion: 2
guid: a0c2c8b2ac71342e1bd714d7178198e3
timeCreated: 1506376733
licenseType: Pro
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

10
unity-environment/Assets/ML-Agents/Examples/WallJump/Prefabs.meta


fileFormatVersion: 2
guid: 22e282f4b1d48436b91d6ad8a8903e1c
folderAsset: yes
timeCreated: 1517535133
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

700
unity-environment/Assets/ML-Agents/Examples/WallJump/Prefabs/WallJumpArea.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: 1280098394364104}
m_IsPrefabParent: 1
--- !u!1 &1195095783991828
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4651390251185036}
- component: {fileID: 33846302425286506}
- component: {fileID: 65193133000831296}
- component: {fileID: 23298506819960420}
- component: {fileID: 54678503543725326}
- component: {fileID: 114925928594762506}
- component: {fileID: 114092229367912210}
m_Layer: 0
m_Name: Agent
m_TagString: agent
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1243905751985214
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4245926775170606}
- component: {fileID: 33016986498506672}
- component: {fileID: 65082856895024712}
- component: {fileID: 23546212824591690}
m_Layer: 0
m_Name: Wall
m_TagString: wall
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1280098394364104
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4768003208014390}
m_Layer: 0
m_Name: WallJumpArea
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1395477826315484
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4294902888415044}
- component: {fileID: 33528566080995282}
- component: {fileID: 65551840025329434}
- component: {fileID: 23354960268522594}
- component: {fileID: 54027918861229180}
m_Layer: 0
m_Name: shortBlock
m_TagString: block
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1535176706844624
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4064361527677764}
- component: {fileID: 33890127227328306}
- component: {fileID: 65857793473814344}
- component: {fileID: 23318234009360618}
m_Layer: 0
m_Name: SpawnVolume
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1707364840842826
GameObject:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4930287780304116}
- component: {fileID: 33507625006194266}
- component: {fileID: 65060909118748988}
- component: {fileID: 23872068720866504}
m_Layer: 0
m_Name: Cube
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1964440537870194
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4192801639223200}
- component: {fileID: 33252015425015410}
- component: {fileID: 65412457053290128}
- component: {fileID: 23001074490764582}
m_Layer: 0
m_Name: Ground
m_TagString: walkableSurface
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1982078136115924
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4011541840118462}
- component: {fileID: 33618033993823702}
- component: {fileID: 65431820516000586}
- component: {fileID: 23621829541977726}
m_Layer: 0
m_Name: Goal
m_TagString: goal
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4011541840118462
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1982078136115924}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 6.7, y: 0.4, z: 3.3}
m_LocalScale: {x: 4, y: 0.32738775, z: 4}
m_Children: []
m_Father: {fileID: 4768003208014390}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4064361527677764
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1535176706844624}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 1.05, z: -6.5}
m_LocalScale: {x: 16.2, y: 1, z: 7}
m_Children: []
m_Father: {fileID: 4768003208014390}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4192801639223200
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1964440537870194}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -4}
m_LocalScale: {x: 20, y: 1, z: 20}
m_Children: []
m_Father: {fileID: 4768003208014390}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4245926775170606
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1243905751985214}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -1.53}
m_LocalScale: {x: 20, y: 0, z: 1.5}
m_Children: []
m_Father: {fileID: 4768003208014390}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4294902888415044
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1395477826315484}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 1.51, y: 2.05, z: -3.86}
m_LocalScale: {x: 3, y: 2, z: 3}
m_Children: []
m_Father: {fileID: 4768003208014390}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4651390251185036
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1195095783991828}
m_LocalRotation: {x: -0, y: 0.96758014, z: -0, w: 0.25256422}
m_LocalPosition: {x: -8.2, y: 1, z: -12.08}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 4930287780304116}
m_Father: {fileID: 4768003208014390}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4768003208014390
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1280098394364104}
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:
- {fileID: 4651390251185036}
- {fileID: 4192801639223200}
- {fileID: 4011541840118462}
- {fileID: 4294902888415044}
- {fileID: 4245926775170606}
- {fileID: 4064361527677764}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4930287780304116
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1707364840842826}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0, y: 0, z: 0.49}
m_LocalScale: {x: 0.1941064, y: 0.19410636, z: 0.19410636}
m_Children: []
m_Father: {fileID: 4651390251185036}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &23001074490764582
MeshRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1964440537870194}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 2100000, guid: 2c19bff363d1644b0818652340f120d5, 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_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!23 &23298506819960420
MeshRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1195095783991828}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 2100000, guid: 260483cdfc6b14e26823a02f23bd8baa, 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_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!23 &23318234009360618
MeshRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1535176706844624}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 2100000, guid: ecd59def9213741058b969f699d10e8e, 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_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!23 &23354960268522594
MeshRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1395477826315484}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 2100000, guid: f4abcb290251940948a31b349a6f9995, 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_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!23 &23546212824591690
MeshRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1243905751985214}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 2100000, guid: a0c2c8b2ac71342e1bd714d7178198e3, 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_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!23 &23621829541977726
MeshRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1982078136115924}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 2100000, guid: e810187ce86f44ba1a373ca07a86ea81, 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_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!23 &23872068720866504
MeshRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1707364840842826}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
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_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 &33016986498506672
MeshFilter:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1243905751985214}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!33 &33252015425015410
MeshFilter:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1964440537870194}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!33 &33507625006194266
MeshFilter:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1707364840842826}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!33 &33528566080995282
MeshFilter:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1395477826315484}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!33 &33618033993823702
MeshFilter:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1982078136115924}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!33 &33846302425286506
MeshFilter:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1195095783991828}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!33 &33890127227328306
MeshFilter:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1535176706844624}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!54 &54027918861229180
Rigidbody:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1395477826315484}
serializedVersion: 2
m_Mass: 10
m_Drag: 1
m_AngularDrag: 0.05
m_UseGravity: 1
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 116
m_CollisionDetection: 0
--- !u!54 &54678503543725326
Rigidbody:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1195095783991828}
serializedVersion: 2
m_Mass: 25
m_Drag: 2
m_AngularDrag: 0.05
m_UseGravity: 1
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 80
m_CollisionDetection: 0
--- !u!65 &65060909118748988
BoxCollider:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1707364840842826}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 0
serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!65 &65082856895024712
BoxCollider:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1243905751985214}
m_Material: {fileID: 13400000, guid: 2053f160e462a428ab794446c043b144, type: 2}
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!65 &65193133000831296
BoxCollider:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1195095783991828}
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!65 &65412457053290128
BoxCollider:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1964440537870194}
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!65 &65431820516000586
BoxCollider:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1982078136115924}
m_Material: {fileID: 0}
m_IsTrigger: 1
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1, y: 50, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!65 &65551840025329434
BoxCollider:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1395477826315484}
m_Material: {fileID: 13400000, guid: 2053f160e462a428ab794446c043b144, type: 2}
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!65 &65857793473814344
BoxCollider:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1535176706844624}
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!114 &114092229367912210
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1195095783991828}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bb172294dbbcc408286b156a2c4b553c, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &114925928594762506
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1195095783991828}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 676fca959b8ee45539773905ca71afa1, type: 3}
m_Name:
m_EditorClassIdentifier:
brain: {fileID: 0}
agentParameters:
agentCameras: []
maxStep: 2000
resetOnDone: 1
onDemandDecision: 0
numberOfActionsBetweenDecisions: 5
noWallBrain: {fileID: 0}
smallWallBrain: {fileID: 0}
bigWallBrain: {fileID: 0}
ground: {fileID: 1964440537870194}
spawnArea: {fileID: 1535176706844624}
goal: {fileID: 1982078136115924}
shortBlock: {fileID: 1395477826315484}
wall: {fileID: 1243905751985214}
jumpingTime: 0
jumpTime: 0.2
fallingForce: 111
hitGroundColliders:
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}

9
unity-environment/Assets/ML-Agents/Examples/WallJump/Prefabs/WallJumpArea.prefab.meta


fileFormatVersion: 2
guid: 54e3af627216447f790531de496099f0
timeCreated: 1520541093
licenseType: Free
NativeFormatImporter:
mainObjectFileID: 100100000
userData:
assetBundleName:
assetBundleVariant:

10
unity-environment/Assets/ML-Agents/Examples/WallJump/Scenes.meta


fileFormatVersion: 2
guid: 1d53e87fe54dd4178b88cc1a23b11731
folderAsset: yes
timeCreated: 1517446674
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

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

9
unity-environment/Assets/ML-Agents/Examples/WallJump/Scenes/WallJump.unity.meta


fileFormatVersion: 2
guid: 56024e8d040d344709949bc88128944d
timeCreated: 1506808980
licenseType: Pro
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

10
unity-environment/Assets/ML-Agents/Examples/WallJump/Scripts.meta


fileFormatVersion: 2
guid: 344123e9bd87b48fdbebb4202a771d96
folderAsset: yes
timeCreated: 1517445791
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

28
unity-environment/Assets/ML-Agents/Examples/WallJump/Scripts/WallJumpAcademy.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WallJumpAcademy : Academy {
[Header("Specific to WallJump")]
public float agentRunSpeed;
public float agentJumpHeight;
//when a goal is scored the ground will use this material for a few seconds.
public Material goalScoredMaterial;
//when fail, the ground will use this material for a few seconds.
public Material failMaterial;
[HideInInspector]
//use ~3 to make things less floaty
public float gravityMultiplier = 2.5f;
[HideInInspector]
public float agentJumpVelocity = 777;
[HideInInspector]
public float agentJumpVelocityMaxChange = 10;
// Use this for initialization
public override void InitializeAcademy()
{
Physics.gravity *= gravityMultiplier;
}
}

13
unity-environment/Assets/ML-Agents/Examples/WallJump/Scripts/WallJumpAcademy.cs.meta


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

327
unity-environment/Assets/ML-Agents/Examples/WallJump/Scripts/WallJumpAgent.cs


//Put this script on your blue cube.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;
public class WallJumpAgent : Agent
{
// Depending on this value, the wall will have different height
int configuration;
// Brain to use when no wall is present
public Brain noWallBrain;
// Brain to use when a jumpable wall is present
public Brain smallWallBrain;
// Brain to use when a wall requiring a block to jump over is present
public Brain bigWallBrain;
public GameObject ground;
public GameObject spawnArea;
Bounds spawnAreaBounds;
public GameObject goal;
public GameObject shortBlock;
public GameObject wall;
Rigidbody shortBlockRB;
Rigidbody agentRB;
Material groundMaterial;
Renderer groundRenderer;
WallJumpAcademy academy;
RayPerception rayPer;
public float jumpingTime;
public float jumpTime;
// This is a downward force applied when falling to make jumps look
// less floaty
public float fallingForce;
// Use to check the coliding objects
public Collider[] hitGroundColliders = new Collider[3];
Vector3 jumpTargetPos;
Vector3 jumpStartingPos;
string[] detectableObjects;
public override void InitializeAgent()
{
academy = FindObjectOfType<WallJumpAcademy>();
rayPer = GetComponent<RayPerception>();
configuration = Random.Range(0, 5);
detectableObjects = new string[] { "wall", "goal", "block" };
agentRB = GetComponent<Rigidbody>();
shortBlockRB = shortBlock.GetComponent<Rigidbody>();
spawnAreaBounds = spawnArea.GetComponent<Collider>().bounds;
groundRenderer = ground.GetComponent<Renderer>();
groundMaterial = groundRenderer.material;
spawnArea.SetActive(false);
}
// Begin the jump sequence
public void Jump()
{
jumpingTime = 0.2f;
jumpStartingPos = agentRB.position;
}
/// <summary>
/// Does the ground check.
/// </summary>
/// <returns><c>true</c>, if the agent is on the ground,
/// <c>false</c> otherwise.</returns>
/// <param name="boxWidth">The width of the box used to perform
/// the ground check. </param>
public bool DoGroundCheck(float boxWidth)
{
hitGroundColliders = new Collider[3];
Physics.OverlapBoxNonAlloc(
gameObject.transform.position + new Vector3(0, -0.05f, 0),
new Vector3(boxWidth / 2f, 0.5f, boxWidth / 2f),
hitGroundColliders,
gameObject.transform.rotation);
bool grounded = false;
foreach (Collider col in hitGroundColliders)
{
if (col != null && col.transform != this.transform &&
(col.CompareTag("walkableSurface") ||
col.CompareTag("block") ||
col.CompareTag("wall")))
{
grounded = true; //then we're grounded
break;
}
}
return grounded;
}
/// <summary>
/// Moves a rigidbody towards a position smoothly.
/// </summary>
/// <param name="targetPos">Target position.</param>
/// <param name="rb">The rigidbody to be moved.</param>
/// <param name="targetVel">The velocity to target during the
/// motion.</param>
/// <param name="maxVel">The maximum velocity posible.</param>
void MoveTowards(
Vector3 targetPos, Rigidbody rb, float targetVel, float maxVel)
{
Vector3 moveToPos = targetPos - rb.worldCenterOfMass;
Vector3 velocityTarget = moveToPos * targetVel * Time.fixedDeltaTime;
if (float.IsNaN(velocityTarget.x) == false)
{
rb.velocity = Vector3.MoveTowards(
rb.velocity, velocityTarget, maxVel);
}
}
public override void CollectObservations()
{
float rayDistance = 20f;
float[] rayAngles = { 0f, 45f, 90f, 135f, 180f, 110f, 70f };
AddVectorObs(rayPer.Perceive(
rayDistance, rayAngles, detectableObjects, 0f, 0f));
AddVectorObs(rayPer.Perceive(
rayDistance, rayAngles, detectableObjects, 2.5f, 2.5f));
Vector3 agentPos = agentRB.position - ground.transform.position;
AddVectorObs(agentPos / 20f);
AddVectorObs(DoGroundCheck(0.4f) ? 1 : 0);
}
/// <summary>
/// Gets a random spawn position in the spawningArea.
/// </summary>
/// <returns>The random spawn position.</returns>
public Vector3 GetRandomSpawnPos()
{
Vector3 randomSpawnPos = Vector3.zero;
float randomPosX = Random.Range(-spawnAreaBounds.extents.x,
spawnAreaBounds.extents.x);
float randomPosZ = Random.Range(-spawnAreaBounds.extents.z,
spawnAreaBounds.extents.z);
randomSpawnPos = spawnArea.transform.position +
new Vector3(randomPosX, 0.45f, randomPosZ);
return randomSpawnPos;
}
/// <summary>
/// Chenges the color of the ground for a moment
/// </summary>
/// <returns>The Enumerator to be used in a Coroutine</returns>
/// <param name="mat">The material to be swaped.</param>
/// <param name="time">The time the material will remain.</param>
IEnumerator GoalScoredSwapGroundMaterial(Material mat, float time)
{
groundRenderer.material = mat;
yield return new WaitForSeconds(time); //wait for 2 sec
groundRenderer.material = groundMaterial;
}
public void MoveAgent(float[] act)
{
AddReward(-0.0005f);
bool smallGrounded = DoGroundCheck(0.4f);
bool largeGrounded = DoGroundCheck(1.0f);
Vector3 dirToGo = Vector3.zero;
Vector3 rotateDir = Vector3.zero;
int action = Mathf.FloorToInt(act[0]);
switch (action)
{
case 0:
dirToGo = transform.forward * 1f * (largeGrounded ? 1f : 0.5f);
break;
case 1:
dirToGo = transform.forward * -1f * (largeGrounded ? 1f : 0.5f);
break;
case 2:
rotateDir = transform.up * -1f;
break;
case 3:
rotateDir = transform.up * 1f;
break;
case 4:
dirToGo = transform.right * -0.6f * (largeGrounded ? 1f : 0.5f);
break;
case 5:
dirToGo = transform.right * 0.6f * (largeGrounded ? 1f : 0.5f);
break;
case 6:
if ((jumpingTime <= 0f) && smallGrounded)
{
Jump();
}
break;
}
transform.Rotate(rotateDir, Time.fixedDeltaTime * 300f);
agentRB.AddForce(dirToGo * academy.agentRunSpeed,
ForceMode.VelocityChange);
if (jumpingTime > 0f)
{
jumpTargetPos =
new Vector3(agentRB.position.x,
jumpStartingPos.y + academy.agentJumpHeight,
agentRB.position.z) + dirToGo;
MoveTowards(jumpTargetPos, agentRB, academy.agentJumpVelocity,
academy.agentJumpVelocityMaxChange);
}
if (!(jumpingTime > 0f) && !largeGrounded)
{
agentRB.AddForce(
Vector3.down * fallingForce, ForceMode.Acceleration);
}
jumpingTime -= Time.fixedDeltaTime;
}
public override void AgentAction(float[] vectorAction, string textAction)
{
MoveAgent(vectorAction);
if ((!Physics.Raycast(agentRB.position, Vector3.down, 20))
|| (!Physics.Raycast(shortBlockRB.position, Vector3.down, 20)))
{
Done();
SetReward(-1f);
ResetBlock(shortBlockRB);
StartCoroutine(
GoalScoredSwapGroundMaterial(academy.failMaterial, .5f));
}
}
// Detect when the agent hits the goal
void OnTriggerEnter(Collider col)
{
if (col.gameObject.CompareTag("goal") && DoGroundCheck(0.4f))
{
SetReward(1f);
Done();
StartCoroutine(
GoalScoredSwapGroundMaterial(academy.goalScoredMaterial, 2));
}
}
//Reset the orange block position
void ResetBlock(Rigidbody blockRB)
{
blockRB.transform.position = GetRandomSpawnPos();
blockRB.velocity = Vector3.zero;
blockRB.angularVelocity = Vector3.zero;
}
public override void AgentReset()
{
ResetBlock(shortBlockRB);
transform.localPosition = new Vector3(
18 * (Random.value - 0.5f), 1, -12);
configuration = Random.Range(0, 5);
agentRB.velocity = default(Vector3);
}
private void FixedUpdate()
{
if (configuration != -1)
{
ConfigureAgent(configuration);
configuration = -1;
}
}
/// <summary>
/// Configures the agent. Given an integer config, the wall will have
/// different height and a different brain will be assigned to the agent.
/// </summary>
/// <param name="config">Config.
/// If 0 : No wall and noWallBrain.
/// If 1: Small wall and smallWallBrain.
/// Other : Tall wall and BigWallBrain. </param>
void ConfigureAgent(int config)
{
if (config == 0)
{
wall.transform.localScale = new Vector3(
wall.transform.localScale.x,
academy.resetParameters["no_wall_height"],
wall.transform.localScale.z);
GiveBrain(noWallBrain);
}
else if (config == 1)
{
wall.transform.localScale = new Vector3(
wall.transform.localScale.x,
academy.resetParameters["small_wall_height"],
wall.transform.localScale.z);
GiveBrain(smallWallBrain);
}
else
{
float height =
academy.resetParameters["big_wall_min_height"] +
Random.value * (academy.resetParameters["big_wall_max_height"] -
academy.resetParameters["big_wall_min_height"]);
wall.transform.localScale = new Vector3(
wall.transform.localScale.x,
height,
wall.transform.localScale.z);
GiveBrain(bigWallBrain);
}
}
}

13
unity-environment/Assets/ML-Agents/Examples/WallJump/Scripts/WallJumpAgent.cs.meta


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

10
unity-environment/Assets/ML-Agents/Examples/WallJump/TFModels.meta


fileFormatVersion: 2
guid: da68dfde501d241c788cadc9805b214a
folderAsset: yes
timeCreated: 1517539094
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

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

9
unity-environment/Assets/ML-Agents/Examples/WallJump/TFModels/WallJump.bytes.meta


fileFormatVersion: 2
guid: fae11f80dd25b4bc4918ce5223fd8e5b
timeCreated: 1520732146
licenseType: Free
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存