浏览代码

added hazard and updated the brain and scripts

/hh-develop-walljump_rnd
Hunter 5 年前
当前提交
3e620bc9
共有 8 个文件被更改,包括 147 次插入19 次删除
  1. 2
      UnitySDK/Assets/ML-Agents/Examples/WallJump/Brains/BigWallJumpLearning.asset
  2. 2
      UnitySDK/Assets/ML-Agents/Examples/WallJump/Brains/SmallWallJumpLearning.asset
  3. 2
      UnitySDK/Assets/ML-Agents/Examples/WallJump/Brains/WallJumpPlayer.asset
  4. 118
      UnitySDK/Assets/ML-Agents/Examples/WallJump/Prefabs/WallJumpArea.prefab
  5. 6
      UnitySDK/Assets/ML-Agents/Examples/WallJump/Scenes/WallJump.unity
  6. 33
      UnitySDK/Assets/ML-Agents/Examples/WallJump/Scripts/WallJumpAgent.cs
  7. 1
      UnitySDK/ProjectSettings/TagManager.asset
  8. 2
      UnitySDK/csharp_timers.json

2
UnitySDK/Assets/ML-Agents/Examples/WallJump/Brains/BigWallJumpLearning.asset


m_Name: BigWallJumpLearning
m_EditorClassIdentifier:
brainParameters:
vectorObservationSize: 83
vectorObservationSize: 97
numStackedVectorObservations: 1
vectorActionSize: 030000000300000002000000
cameraResolutions: []

2
UnitySDK/Assets/ML-Agents/Examples/WallJump/Brains/SmallWallJumpLearning.asset


m_Name: SmallWallJumpLearning
m_EditorClassIdentifier:
brainParameters:
vectorObservationSize: 83
vectorObservationSize: 97
numStackedVectorObservations: 1
vectorActionSize: 030000000300000002000000
cameraResolutions: []

2
UnitySDK/Assets/ML-Agents/Examples/WallJump/Brains/WallJumpPlayer.asset


m_Name: WallJumpPlayer
m_EditorClassIdentifier:
brainParameters:
vectorObservationSize: 83
vectorObservationSize: 97
numStackedVectorObservations: 1
vectorActionSize: 030000000300000002000000
cameraResolutions: []

118
UnitySDK/Assets/ML-Agents/Examples/WallJump/Prefabs/WallJumpArea.prefab


- component: {fileID: 23862399076711284}
- component: {fileID: 54757390068510808}
m_Layer: 0
m_Name: ShortBlock
m_TagString: block
m_Name: Hazard
m_TagString: hazard
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0

m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1884323561655012
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4545734715367722}
- component: {fileID: 33858426545422694}
- component: {fileID: 65516451821498548}
- component: {fileID: 23418352498320674}
- component: {fileID: 54423448529336914}
m_Layer: 0
m_Name: ShortBlock
m_TagString: block
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1886170194660384
GameObject:
m_ObjectHideFlags: 0

m_Father: {fileID: 4651390251185036}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4545734715367722
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1884323561655012}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -2.67, y: 1.33, z: -7.86}
m_LocalScale: {x: 2, y: 1.5, z: 2}
m_Children: []
m_Father: {fileID: 4768003208014390}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4651390251185036
Transform:
m_ObjectHideFlags: 1

- {fileID: 4011541840118462}
- {fileID: 4764219638476960}
- {fileID: 4886712515982252}
- {fileID: 4545734715367722}
- {fileID: 4972445296092312}
m_Father: {fileID: 0}
m_RootOrder: 0

m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1478101936519122}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -2.67, y: 1.33, z: -7.86}
m_LocalScale: {x: 3, y: 1.5, z: 3}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 3.04, y: 1.33, z: -7.86}
m_LocalScale: {x: 2, y: 1.5, z: 2}
m_RootOrder: 5
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!20 &20236434339313884
Camera:

m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!23 &23418352498320674
MeshRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1884323561655012}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 2100000, guid: eaad04b0e0dec42229c9cb00a981d7ac, 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!23 &23557798664619476
MeshRenderer:
m_ObjectHideFlags: 1

m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 2100000, guid: eaad04b0e0dec42229c9cb00a981d7ac, type: 2}
- {fileID: 2100000, guid: 88b9ae7af2c1748a0a1f63407587a601, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0

m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1886170194660384}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!33 &33858426545422694
MeshFilter:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1884323561655012}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!33 &33874593518009454
MeshFilter:
m_ObjectHideFlags: 1

m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1823012949159486}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!54 &54423448529336914
Rigidbody:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1884323561655012}
serializedVersion: 2
m_Mass: 25
m_Drag: 0.5
m_AngularDrag: 0.5
m_UseGravity: 1
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!54 &54678503543725326
Rigidbody:
m_ObjectHideFlags: 1

serializedVersion: 2
m_Size: {x: 400, y: 500, z: 400}
m_Center: {x: 0, y: 250, z: 0}
--- !u!65 &65516451821498548
BoxCollider:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1884323561655012}
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 &65611839918206582
BoxCollider:
m_ObjectHideFlags: 1

bigWallBrain: {fileID: 11400000, guid: b5f530c5bf8d64bf8a18df92e283bb9c, type: 2}
ground: {fileID: 1324926338613664}
spawnArea: {fileID: 1886170194660384}
shortBlock: {fileID: 1478101936519122}
shortBlock: {fileID: 1884323561655012}
hazardRb: {fileID: 54757390068510808}
wall: {fileID: 1528738716925344}

6
UnitySDK/Assets/ML-Agents/Examples/WallJump/Scenes/WallJump.unity


m_Name:
m_EditorClassIdentifier:
m_TrainingConfiguration:
width: 80
height: 80
width: 1280
height: 720
timeScale: 10
timeScale: 5
targetFrameRate: -1
m_InferenceConfiguration:
width: 1280

33
UnitySDK/Assets/ML-Agents/Examples/WallJump/Scripts/WallJumpAgent.cs


//Put this script on your blue cube.
using System;
using Random = UnityEngine.Random;
[RequireComponent(typeof(AgentCubeGroundCheck))] // Required for groundcheck
public class WallJumpAgent : Agent

public GameObject ground;
public GameObject spawnArea;
public GameObject shortBlock;
public Rigidbody hazardRb;
public GameObject wall;
Bounds m_SpawnAreaBounds;
Rigidbody m_ShortBlockRb;

m_agentMovement = FindObjectOfType<AgentCubeMovement>();
m_RayPer = GetComponent<RayPerception>();
m_Configuration = Random.Range(0, 5);
m_DetectableObjects = new[] { "wall", "goal", "block" };
m_DetectableObjects = new[] { "wall", "goal", "block", "hazard" };
m_AgentRb = GetComponent<Rigidbody>();
m_ShortBlockRb = shortBlock.GetComponent<Rigidbody>();
m_SpawnAreaBounds = spawnArea.GetComponent<Collider>().bounds;

public override void AgentAction(float[] vectorAction, string textAction)
{
if (IsDone())
{
return;
}
if(m_AgentRb.position.y < -1 || m_ShortBlockRb.position.y < -1)
if(m_AgentRb.position.y < -1 || m_ShortBlockRb.position.y < -1 || hazardRb.position.y < -1)
ResetBlock(m_ShortBlockRb);
// ResetBlock(m_ShortBlockRb);
// ResetBlock(hazardRb);
StartCoroutine(
GoalScoredSwapGroundMaterial(m_Academy.failMaterial, .5f));
Done();
}
}
void OnCollisionEnter(Collision col)
{
if (col.gameObject.CompareTag("hazard"))
{
SetReward(-1f);
StartCoroutine(
GoalScoredSwapGroundMaterial(m_Academy.failMaterial, .5f));
Done();

// Detect when the agent hits the goal
void OnTriggerStay(Collider col)
{
if (IsDone())
{
return;
}
ResetBlock(m_ShortBlockRb);
// ResetBlock(m_ShortBlockRb);
// ResetBlock(hazardRb);
StartCoroutine(
GoalScoredSwapGroundMaterial(m_Academy.goalScoredMaterial, .5f));
Done();

public override void AgentReset()
{
ResetBlock(m_ShortBlockRb);
ResetBlock(hazardRb);
transform.localPosition = new Vector3(
18 * (Random.value - 0.5f), 1, -12);
m_Configuration = Random.Range(0, 5);

1
UnitySDK/ProjectSettings/TagManager.asset


- symbol_O_Goal
- purpleAgent
- purpleGoal
- hazard
layers:
- Default
- TransparentFX

2
UnitySDK/csharp_timers.json


{"count":1,"self":54.300678399999995,"total":60.891335999999995,"children":{"AgentResetIfDone":{"count":3001,"self":0.149694,"total":0.149694,"children":null},"AgentSendState":{"count":3001,"self":0.952689,"total":2.677314,"children":{"CollectObservations":{"count":24024,"self":1.7246249999999999,"total":1.7246249999999999,"children":null}}},"BrainDecideAction":{"count":3001,"self":3.302732,"total":3.302732,"children":null},"AcademyStep":{"count":3001,"self":0.081987999999999991,"total":0.081987999999999991,"children":null},"AgentAct":{"count":3001,"self":0.37719199999999997,"total":0.37719199999999997,"children":null}}}
{"count":1,"self":7.355968,"total":47.330034999999995,"children":{"AgentResetIfDone":{"count":5242,"self":0.167117,"total":0.167117,"children":null},"AgentSendState":{"count":5242,"self":1.303016,"total":3.430564,"children":{"CollectObservations":{"count":41952,"self":2.127548,"total":2.127548,"children":null}}},"BrainDecideAction":{"count":5242,"self":35.7313632,"total":35.731362,"children":null},"AcademyStep":{"count":5242,"self":0.120016,"total":0.120016,"children":null},"AgentAct":{"count":5242,"self":0.523507,"total":0.523507,"children":null}}}
正在加载...
取消
保存