浏览代码

add escape room

/develop/pushcollabonly
HH 4 年前
当前提交
8d5659cc
共有 17 个文件被更改,包括 4415 次插入18 次删除
  1. 36
      Project/Assets/ML-Agents/Examples/PushBlock/Prefabs/PushBlockCollabAreaStaticGrid.prefab
  2. 7
      Project/Assets/ML-Agents/Examples/PushBlock/Scripts/PushBlockEnvController.cs
  3. 6
      Project/ProjectSettings/TagManager.asset
  4. 1001
      Project/Assets/ML-Agents/Examples/PushBlock/Prefabs/EscapeRoom.prefab
  5. 7
      Project/Assets/ML-Agents/Examples/PushBlock/Prefabs/EscapeRoom.prefab.meta
  6. 949
      Project/Assets/ML-Agents/Examples/PushBlock/Scenes/EscapeRoom.unity
  7. 9
      Project/Assets/ML-Agents/Examples/PushBlock/Scenes/EscapeRoom.unity.meta
  8. 60
      Project/Assets/ML-Agents/Examples/PushBlock/Scripts/DoorSwitchTrigger.cs
  9. 11
      Project/Assets/ML-Agents/Examples/PushBlock/Scripts/DoorSwitchTrigger.cs.meta
  10. 137
      Project/Assets/ML-Agents/Examples/PushBlock/Scripts/EscapeRoomAgentCollab.cs
  11. 12
      Project/Assets/ML-Agents/Examples/PushBlock/Scripts/EscapeRoomAgentCollab.cs.meta
  12. 157
      Project/Assets/ML-Agents/Examples/PushBlock/Scripts/EscapeRoomGameController.cs
  13. 11
      Project/Assets/ML-Agents/Examples/PushBlock/Scripts/EscapeRoomGameController.cs.meta
  14. 1001
      Project/Assets/ML-Agents/Examples/PushBlock/TFModels/EscapeRoom.onnx
  15. 14
      Project/Assets/ML-Agents/Examples/PushBlock/TFModels/EscapeRoom.onnx.meta
  16. 1001
      Project/Assets/ML-Agents/Examples/PushBlock/TFModels/PushBlockCollabGridComa2.onnx
  17. 14
      Project/Assets/ML-Agents/Examples/PushBlock/TFModels/PushBlockCollabGridComa2.onnx.meta

36
Project/Assets/ML-Agents/Examples/PushBlock/Prefabs/PushBlockCollabAreaStaticGrid.prefab


VectorActionDescriptions: []
VectorActionSpaceType: 0
hasUpgradedBrainParametersWithActionSpec: 1
m_Model: {fileID: 11400000, guid: 71d6f70da79364f00b5823e7158d7f22, type: 3}
m_Model: {fileID: 11400000, guid: cc80e1b0c1e5d442ab2afde4187a0691, type: 3}
m_InferenceDevice: 0
m_BehaviorType: 0
m_BehaviorName: PushBlock

m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8190299122290044757}
m_LocalRotation: {x: 0, y: 1, z: 0, w: 0}
m_LocalPosition: {x: 0, y: 0.59, z: -4.39}
m_LocalPosition: {x: 0, y: 0.59, z: 9.21}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 8195608969721335995}

VectorActionDescriptions: []
VectorActionSpaceType: 0
hasUpgradedBrainParametersWithActionSpec: 1
m_Model: {fileID: 11400000, guid: 71d6f70da79364f00b5823e7158d7f22, type: 3}
m_Model: {fileID: 11400000, guid: cc80e1b0c1e5d442ab2afde4187a0691, type: 3}
m_InferenceDevice: 0
m_BehaviorType: 0
m_BehaviorName: PushBlock

m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8191066182651411141}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalPosition: {x: 0, y: 0, z: 10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 8191066183478082749}

m_Name:
m_EditorClassIdentifier:
Name: StaticPlatformGrid
CellScaleX: 1.3
CellScaleX: 1
CellScaleZ: 1.3
CellScaleZ: 1
GridNumSideX: 20
GridNumSideZ: 20
RotateGridWithRoot: 1

serializedVersion: 2
m_Bits: 1
gridDepthType: 1
rootReference: {fileID: 8191903532335653025}
rootReference: {fileID: 8191066182651411141}
MaxColliderBufferSize: 500
InitialColliderBufferSize: 16
ObservationPerCell: 7

m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8191066182862526894}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalPosition: {x: 0, y: 0, z: 10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 8188215278053101651}

m_Name:
m_EditorClassIdentifier:
Name: StaticPlatformGrid
CellScaleX: 1.3
CellScaleX: 1
CellScaleZ: 1.3
CellScaleZ: 1
GridNumSideX: 20
GridNumSideZ: 20
RotateGridWithRoot: 1

serializedVersion: 2
m_Bits: 1
gridDepthType: 1
rootReference: {fileID: 8191903532335653025}
rootReference: {fileID: 8191066182862526894}
MaxColliderBufferSize: 500
InitialColliderBufferSize: 16
ObservationPerCell: 7

m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8191066182918326564}
serializedVersion: 2
m_Mass: 35
m_Mass: 10
m_Drag: 0.5
m_AngularDrag: 0.05
m_UseGravity: 1

m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8191066183046235082}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalPosition: {x: 0, y: 0, z: 10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 3789616195185397257}

m_Name:
m_EditorClassIdentifier:
Name: StaticPlatformGrid
CellScaleX: 1.3
CellScaleX: 1
CellScaleZ: 1.3
CellScaleZ: 1
GridNumSideX: 20
GridNumSideZ: 20
RotateGridWithRoot: 1

serializedVersion: 2
m_Bits: 1
gridDepthType: 1
rootReference: {fileID: 8191903532335653025}
rootReference: {fileID: 8191066183046235082}
MaxColliderBufferSize: 500
InitialColliderBufferSize: 16
ObservationPerCell: 7

VectorActionDescriptions: []
VectorActionSpaceType: 0
hasUpgradedBrainParametersWithActionSpec: 1
m_Model: {fileID: 11400000, guid: 71d6f70da79364f00b5823e7158d7f22, type: 3}
m_Model: {fileID: 11400000, guid: cc80e1b0c1e5d442ab2afde4187a0691, type: 3}
m_InferenceDevice: 0
m_BehaviorType: 0
m_BehaviorName: PushBlock

m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8191066183517911096}
serializedVersion: 2
m_Mass: 35
m_Mass: 10
m_Drag: 0.5
m_AngularDrag: 0.05
m_UseGravity: 1

7
Project/Assets/ML-Agents/Examples/PushBlock/Scripts/PushBlockEnvController.cs


m_AgentGroup.GroupEpisodeInterrupted();
ResetScene();
}
// foreach (var item in BlocksList)
// {
// //Give Agent Rewards
// m_AgentGroup.AddGroupReward(.01f * item.Rb.velocity.sqrMagnitude);
// }
}
/// <summary>

// Swap ground material for a bit to indicate we scored.
StartCoroutine(GoalScoredSwapGroundMaterial(m_PushBlockSettings.goalScoredMaterial, 0.5f));
print($"Scored {score} on gameObject.name");
if (done)
{
//Reset assets

6
Project/ProjectSettings/TagManager.asset


- purpleAgent
- purpleGoal
- tile
- zombie
- blockLarge
- blockVeryLarge
- blockSmall
- door
- switch
layers:
- Default
- TransparentFX

1001
Project/Assets/ML-Agents/Examples/PushBlock/Prefabs/EscapeRoom.prefab
文件差异内容过多而无法显示
查看文件

7
Project/Assets/ML-Agents/Examples/PushBlock/Prefabs/EscapeRoom.prefab.meta


fileFormatVersion: 2
guid: 9cb88a3d0345c426395698d39ba8a38e
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

949
Project/Assets/ML-Agents/Examples/PushBlock/Scenes/EscapeRoom.unity


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.8, g: 0.8, b: 0.8, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 3
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 11
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 1
m_LightmapEditorSettings:
serializedVersion: 10
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 0
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 500
m_PVRBounces: 2
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVRFilteringMode: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ShowResolutionOverlay: 1
m_LightingDataAsset: {fileID: 112000002, guid: 03723c7f910c3423aa1974f1b9ce8392,
type: 2}
m_UseShadowmask: 1
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1001 &152639159
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalPosition.y
value: -35.5
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalRotation.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalRotation.w
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_RootOrder
value: 9
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 180
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5038458592615033283, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_Name
value: EscapeRoom (3)
objectReference: {fileID: 0}
- target: {fileID: 5038458592615033283, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 9cb88a3d0345c426395698d39ba8a38e, type: 3}
--- !u!1 &255077123
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 255077126}
- component: {fileID: 255077125}
- component: {fileID: 255077124}
m_Layer: 0
m_Name: EventSystem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &255077124
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 255077123}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1077351063, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalAxis: Horizontal
m_VerticalAxis: Vertical
m_SubmitButton: Submit
m_CancelButton: Cancel
m_InputActionsPerSecond: 10
m_RepeatDelay: 0.5
m_ForceModuleActive: 0
--- !u!114 &255077125
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 255077123}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -619905303, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FirstSelected: {fileID: 0}
m_sendNavigationEvents: 1
m_DragThreshold: 5
--- !u!4 &255077126
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 255077123}
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: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &299227616
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalPosition.y
value: -46
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalRotation.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalRotation.w
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_RootOrder
value: 10
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 180
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5038458592615033283, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_Name
value: EscapeRoom (4)
objectReference: {fileID: 0}
- target: {fileID: 5038458592615033283, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 9cb88a3d0345c426395698d39ba8a38e, type: 3}
--- !u!1 &318490716
GameObject:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 318490717}
m_Layer: 0
m_Name: UnityEngine-Recorder
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &318490717
Transform:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 318490716}
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: 365376271}
- {fileID: 1265651286}
m_Father: {fileID: 0}
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &365376270
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 365376271}
m_Layer: 0
m_Name: Settings
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &365376271
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 365376270}
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: 1257687049}
m_Father: {fileID: 318490717}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &502449554
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 4943719350691982, guid: 5889392e3f05b448a8a06c5def6c2dec, type: 3}
propertyPath: m_LocalPosition.x
value: 106.38621
objectReference: {fileID: 0}
- target: {fileID: 4943719350691982, guid: 5889392e3f05b448a8a06c5def6c2dec, type: 3}
propertyPath: m_LocalPosition.y
value: 38.840767
objectReference: {fileID: 0}
- target: {fileID: 4943719350691982, guid: 5889392e3f05b448a8a06c5def6c2dec, type: 3}
propertyPath: m_LocalPosition.z
value: 34.72934
objectReference: {fileID: 0}
- target: {fileID: 4943719350691982, guid: 5889392e3f05b448a8a06c5def6c2dec, type: 3}
propertyPath: m_LocalRotation.x
value: 0.31598538
objectReference: {fileID: 0}
- target: {fileID: 4943719350691982, guid: 5889392e3f05b448a8a06c5def6c2dec, type: 3}
propertyPath: m_LocalRotation.y
value: -0.3596048
objectReference: {fileID: 0}
- target: {fileID: 4943719350691982, guid: 5889392e3f05b448a8a06c5def6c2dec, type: 3}
propertyPath: m_LocalRotation.z
value: 0.13088542
objectReference: {fileID: 0}
- target: {fileID: 4943719350691982, guid: 5889392e3f05b448a8a06c5def6c2dec, type: 3}
propertyPath: m_LocalRotation.w
value: 0.8681629
objectReference: {fileID: 0}
- target: {fileID: 4943719350691982, guid: 5889392e3f05b448a8a06c5def6c2dec, type: 3}
propertyPath: m_RootOrder
value: 4
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 5889392e3f05b448a8a06c5def6c2dec, type: 3}
--- !u!1001 &650728834
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalPosition.y
value: -12.1
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalRotation.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalRotation.w
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_RootOrder
value: 7
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 180
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5038458592615033283, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_Name
value: EscapeRoom (1)
objectReference: {fileID: 0}
- target: {fileID: 5038458592615033283, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 9cb88a3d0345c426395698d39ba8a38e, type: 3}
--- !u!1001 &848465043
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalPosition.y
value: -23.6
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalRotation.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalRotation.w
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_RootOrder
value: 8
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 180
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5038458592615033283, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_Name
value: EscapeRoom (2)
objectReference: {fileID: 0}
- target: {fileID: 5038458592615033283, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 9cb88a3d0345c426395698d39ba8a38e, type: 3}
--- !u!1 &1009000883
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1009000884}
- component: {fileID: 1009000887}
m_Layer: 0
m_Name: SingleCam
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1009000884
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1009000883}
m_LocalRotation: {x: 0.5, y: 0, z: 0, w: 0.8660254}
m_LocalPosition: {x: 0, y: 20, z: -15}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 60, y: 0, z: 0}
--- !u!20 &1009000887
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1009000883}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 2
m_BackGroundColor: {r: 0.46666667, g: 0.5647059, b: 0.60784316, a: 1}
m_projectionMatrixMode: 1
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_GateFitMode: 2
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 56.2
orthographic: 0
orthographic size: 6.98
m_Depth: 2
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!1 &1257687048
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1257687049}
m_Layer: 0
m_Name: 50bfc0f4c3d6f46df98d3c66ceb89209
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1257687049
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1257687048}
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: 365376271}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1265651285
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1265651286}
m_Layer: 0
m_Name: RecordingSessions
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1265651286
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1265651285}
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: 318490717}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1574236047
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1574236049}
- component: {fileID: 1574236050}
- component: {fileID: 1574236048}
m_Layer: 0
m_Name: PushBlockSettings
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1574236048
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1574236047}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ec51f47c5ed0478080c449c74fd9c154, type: 3}
m_Name:
m_EditorClassIdentifier:
gravityMultiplier: 1.5
fixedDeltaTime: 0.02
maximumDeltaTime: 0.33333334
solverIterations: 6
solverVelocityIterations: 1
reuseCollisionCallbacks: 1
--- !u!4 &1574236049
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1574236047}
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: 0}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1574236050
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1574236047}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e5ed63dbfa25542ecb8bc013adfba183, type: 3}
m_Name:
m_EditorClassIdentifier:
agentRunSpeed: 3
agentRotationSpeed: 15
spawnAreaMarginMultiplier: 0.5
goalScoredMaterial: {fileID: 2100000, guid: df32cc593804f42df97464dc455057b8, type: 2}
failMaterial: {fileID: 2100000, guid: a1daf31cdf41e484ca9ac33a5c6f524a, type: 2}
--- !u!1001 &1900462655
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 224194346362733190, guid: 3ce107b4a79bc4eef83afde434932a68,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224194346362733190, guid: 3ce107b4a79bc4eef83afde434932a68,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224194346362733190, guid: 3ce107b4a79bc4eef83afde434932a68,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224194346362733190, guid: 3ce107b4a79bc4eef83afde434932a68,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224194346362733190, guid: 3ce107b4a79bc4eef83afde434932a68,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224194346362733190, guid: 3ce107b4a79bc4eef83afde434932a68,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224194346362733190, guid: 3ce107b4a79bc4eef83afde434932a68,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 224194346362733190, guid: 3ce107b4a79bc4eef83afde434932a68,
type: 3}
propertyPath: m_RootOrder
value: 3
objectReference: {fileID: 0}
- target: {fileID: 224194346362733190, guid: 3ce107b4a79bc4eef83afde434932a68,
type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224194346362733190, guid: 3ce107b4a79bc4eef83afde434932a68,
type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224194346362733190, guid: 3ce107b4a79bc4eef83afde434932a68,
type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224194346362733190, guid: 3ce107b4a79bc4eef83afde434932a68,
type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224194346362733190, guid: 3ce107b4a79bc4eef83afde434932a68,
type: 3}
propertyPath: m_AnchorMin.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224194346362733190, guid: 3ce107b4a79bc4eef83afde434932a68,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224194346362733190, guid: 3ce107b4a79bc4eef83afde434932a68,
type: 3}
propertyPath: m_AnchorMax.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224194346362733190, guid: 3ce107b4a79bc4eef83afde434932a68,
type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224194346362733190, guid: 3ce107b4a79bc4eef83afde434932a68,
type: 3}
propertyPath: m_Pivot.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224194346362733190, guid: 3ce107b4a79bc4eef83afde434932a68,
type: 3}
propertyPath: m_Pivot.y
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 3ce107b4a79bc4eef83afde434932a68, type: 3}
--- !u!1001 &5039471850774661581
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalRotation.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalRotation.w
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_RootOrder
value: 5
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 180
objectReference: {fileID: 0}
- target: {fileID: 5035570448929433331, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5038458592615033283, guid: 9cb88a3d0345c426395698d39ba8a38e,
type: 3}
propertyPath: m_Name
value: EscapeRoom
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 9cb88a3d0345c426395698d39ba8a38e, type: 3}

9
Project/Assets/ML-Agents/Examples/PushBlock/Scenes/EscapeRoom.unity.meta


fileFormatVersion: 2
guid: 614b51930981d4c23961f71f3ab1c2b9
timeCreated: 1506808980
licenseType: Pro
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

60
Project/Assets/ML-Agents/Examples/PushBlock/Scripts/DoorSwitchTrigger.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class DoorSwitchTrigger : MonoBehaviour
{
[Header("Trigger Collider Tag To Detect")]
public string tagToDetect = "agent"; //collider tag to detect
[Header("Goal Value")]
public float GoalValue = 1;
private Collider m_col;
[System.Serializable]
public class TriggerEvent : UnityEvent<Collider, float>
{
}
[Header("Trigger Callbacks")]
public TriggerEvent onTriggerEnterEvent = new TriggerEvent();
public TriggerEvent onTriggerStayEvent = new TriggerEvent();
public TriggerEvent onTriggerExitEvent = new TriggerEvent();
private void OnTriggerEnter(Collider col)
{
if (col.CompareTag(tagToDetect))
{
onTriggerEnterEvent.Invoke(m_col, GoalValue);
}
}
private void OnTriggerStay(Collider col)
{
if (col.CompareTag(tagToDetect))
{
onTriggerStayEvent.Invoke(m_col, GoalValue);
}
}
private void OnTriggerExit(Collider col)
{
if (col.CompareTag(tagToDetect))
{
onTriggerExitEvent.Invoke(m_col, GoalValue);
}
}
// Start is called before the first frame update
void Awake()
{
m_col = GetComponent<Collider>();
}
// Update is called once per frame
void Update()
{
}
}

11
Project/Assets/ML-Agents/Examples/PushBlock/Scripts/DoorSwitchTrigger.cs.meta


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

137
Project/Assets/ML-Agents/Examples/PushBlock/Scripts/EscapeRoomAgentCollab.cs


//Put this script on your blue cube.
using System.Collections;
using UnityEngine;
using Unity.MLAgents;
using Unity.MLAgents.Actuators;
using Unity.MLAgents.Sensors;
public class EscapeRoomAgentCollab : Agent
{
PushBlockSettings m_PushBlockSettings;
Rigidbody m_AgentRb; //cached on initialization
public bool useVectorObs = true;
private EscapeRoomGameController m_GameController;
// void Awake()
// {
// }
public override void Initialize()
{
// Cache the agent rigidbody
m_AgentRb = GetComponent<Rigidbody>();
m_PushBlockSettings = FindObjectOfType<PushBlockSettings>();
m_GameController = GetComponentInParent<EscapeRoomGameController>();
}
public override void CollectObservations(VectorSensor sensor)
{
if (useVectorObs)
{
sensor.AddObservation(m_GameController.DoorIsOpen);
sensor.AddObservation(m_GameController.PlayerDict[this].HoldingSwitch);
sensor.AddObservation(m_GameController.PlayerDict[this].Scored);
}
}
/// <summary>
/// Moves the agent according to the selected action.
/// </summary>
public void MoveAgent(ActionSegment<int> act)
{
var dirToGo = Vector3.zero;
var rotateDir = Vector3.zero;
var action = act[0];
switch (action)
{
case 1:
dirToGo = transform.forward * 1f;
break;
case 2:
dirToGo = transform.forward * -1f;
break;
case 3:
rotateDir = transform.up * 1f;
break;
case 4:
rotateDir = transform.up * -1f;
break;
case 5:
dirToGo = transform.right * -0.75f;
break;
case 6:
dirToGo = transform.right * 0.75f;
break;
}
transform.Rotate(rotateDir, Time.fixedDeltaTime * 200f);
m_AgentRb.AddForce(dirToGo * m_PushBlockSettings.agentRunSpeed,
ForceMode.VelocityChange);
}
/// <summary>
/// Called every step of the engine. Here the agent takes an action.
/// </summary>
public override void OnActionReceived(ActionBuffers actionBuffers)
{
// Move the agent using the action.
MoveAgent(actionBuffers.DiscreteActions);
// Penalty given each step to encourage agent to finish task quickly.
AddReward(-1f / 15000);
}
public override void Heuristic(in ActionBuffers actionsOut)
{
var discreteActionsOut = actionsOut.DiscreteActions;
discreteActionsOut[0] = 0;
if (Input.GetKey(KeyCode.D))
{
discreteActionsOut[0] = 3;
}
else if (Input.GetKey(KeyCode.W))
{
discreteActionsOut[0] = 1;
}
else if (Input.GetKey(KeyCode.A))
{
discreteActionsOut[0] = 4;
}
else if (Input.GetKey(KeyCode.S))
{
discreteActionsOut[0] = 2;
}
}
private void OnTriggerStay(Collider col)
{
if (col.CompareTag("switch"))
{
m_GameController.PlayerDict[this].HoldingSwitch = true;
}
}
void OnTriggerEnter(Collider col)
{
if (col.CompareTag("goal"))
{
m_GameController.AgentScored(this);
}
}
/// <summary>
/// In the editor, if "Reset On Done" is checked then AgentReset() will be
/// called automatically anytime we mark done = true in an agent script.
/// </summary>
public override void OnEpisodeBegin()
{
}
}

12
Project/Assets/ML-Agents/Examples/PushBlock/Scripts/EscapeRoomAgentCollab.cs.meta


fileFormatVersion: 2
guid: e965235cfe60e41808b67808e19704a4
timeCreated: 1506829537
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

157
Project/Assets/ML-Agents/Examples/PushBlock/Scripts/EscapeRoomGameController.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.MLAgents;
public class EscapeRoomGameController : MonoBehaviour
{
[System.Serializable]
public class PlayerInfo
{
public EscapeRoomAgentCollab Agent;
[HideInInspector]
public Vector3 StartingPos;
[HideInInspector]
public Quaternion StartingRot;
[HideInInspector]
public Rigidbody Rb;
public bool Scored;
public bool HoldingSwitch;
}
/// <summary>
/// Max Academy steps before this platform resets
/// </summary>
/// <returns></returns>
[Header("Max Environment Steps")] public int MaxEnvironmentSteps = 25000;
public int NumOfAgentsThatHaveScored = 0;
public List<PlayerInfo> AgentsList = new List<PlayerInfo>();
public Dictionary<EscapeRoomAgentCollab, PlayerInfo> PlayerDict =
new Dictionary<EscapeRoomAgentCollab, PlayerInfo>();
private SimpleMultiAgentGroup m_AgentGroup;
private int m_ResetTimer;
/// <summary>
/// We will be changing the ground material based on success/failue
/// </summary>
public MeshRenderer GroundRenderer;
public Material GroundMaterial; //cached on Awake()
public Material GoalScoredMaterial;
// Start is called before the first frame update
void Start()
{
// Initialize TeamManager
m_AgentGroup = new SimpleMultiAgentGroup();
foreach (var item in AgentsList)
{
item.StartingPos = item.Agent.transform.localPosition;
item.StartingRot = item.Agent.transform.localRotation;
item.Rb = item.Agent.GetComponent<Rigidbody>();
m_AgentGroup.RegisterAgent(item.Agent);
PlayerDict.Add(item.Agent, item);
}
ResetScene();
}
bool AgentIsHoldingSwitch()
{
foreach (var item in PlayerDict)
{
if (item.Value.HoldingSwitch)
{
return true;
}
}
return false;
}
public bool DoorIsOpen;
// Update is called once per frame
void FixedUpdate()
{
m_ResetTimer += 1;
if (m_ResetTimer >= MaxEnvironmentSteps && MaxEnvironmentSteps > 0)
{
m_AgentGroup.GroupEpisodeInterrupted();
ResetScene();
}
DoorIsOpen = AgentIsHoldingSwitch();
DoorOpen(DoorIsOpen);
foreach (var item in PlayerDict)
{
item.Value.HoldingSwitch = false;
}
}
public GameObject Door;
void DoorOpen(bool isOpen)
{
Door.SetActive(!isOpen);
}
void ResetScene()
{
NumOfAgentsThatHaveScored = 0;
m_ResetTimer = 0;
print($"Resetting {gameObject.name}");
foreach (var item in AgentsList)
{
item.Agent.transform.localPosition = item.StartingPos;
item.Agent.transform.localRotation = item.StartingRot;
item.Rb.velocity = Vector3.zero;
item.Rb.angularVelocity = Vector3.zero;
item.Scored = false;
item.HoldingSwitch = false;
}
DoorIsOpen = false;
DoorOpen(false);
//Random platform rot
var rotation = Random.Range(0, 4);
var rotationAngle = rotation * 90f;
transform.Rotate(new Vector3(0f, rotationAngle, 0f));
}
public void AgentScored(EscapeRoomAgentCollab agent)
{
if (PlayerDict[agent].Scored)
{
return;
}
print($"{agent.name} Scored");
PlayerDict[agent].Scored = true;
//Decrement the counter
NumOfAgentsThatHaveScored++;
// Swap ground material for a bit to indicate we scored.
StartCoroutine(GoalScoredSwapGroundMaterial(GoalScoredMaterial, 0.3f));
//Give Agent Rewards
m_AgentGroup.AddGroupReward(1);
if (NumOfAgentsThatHaveScored == 3)
{
//Reset assets
m_AgentGroup.EndGroupEpisode();
ResetScene();
}
}
/// <summary>
/// Swap ground material, wait time seconds, then swap back to the regular material.
/// </summary>
IEnumerator GoalScoredSwapGroundMaterial(Material mat, float time)
{
print("Start GoalScoredSwapGroundMaterial");
GroundRenderer.material = mat;
yield return new WaitForSeconds(time); // Wait for 2 sec
GroundRenderer.material = GroundMaterial;
}
}

11
Project/Assets/ML-Agents/Examples/PushBlock/Scripts/EscapeRoomGameController.cs.meta


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

1001
Project/Assets/ML-Agents/Examples/PushBlock/TFModels/EscapeRoom.onnx
文件差异内容过多而无法显示
查看文件

14
Project/Assets/ML-Agents/Examples/PushBlock/TFModels/EscapeRoom.onnx.meta


fileFormatVersion: 2
guid: 63263e9849fc04159b94e514e2c6711c
ScriptedImporter:
fileIDToRecycleName:
11400000: main obj
11400002: model data
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 683b6cb6d0a474744822c888b46772c9, type: 3}
optimizeModel: 1
forceArbitraryBatchSize: 1
treatErrorsAsWarnings: 0

1001
Project/Assets/ML-Agents/Examples/PushBlock/TFModels/PushBlockCollabGridComa2.onnx
文件差异内容过多而无法显示
查看文件

14
Project/Assets/ML-Agents/Examples/PushBlock/TFModels/PushBlockCollabGridComa2.onnx.meta


fileFormatVersion: 2
guid: cc80e1b0c1e5d442ab2afde4187a0691
ScriptedImporter:
fileIDToRecycleName:
11400000: main obj
11400002: model data
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 683b6cb6d0a474744822c888b46772c9, type: 3}
optimizeModel: 1
forceArbitraryBatchSize: 1
treatErrorsAsWarnings: 0
正在加载...
取消
保存