浏览代码

add drawspheres gizmo to perception

/hh-develop-walljump_rnd
Hunter 5 年前
当前提交
7c1a38e0
共有 9 个文件被更改,包括 149 次插入31 次删除
  1. 2
      UnitySDK/Assets/ML-Agents/Examples/SharedAssets/Materials/GridMatMoveable.mat
  2. 33
      UnitySDK/Assets/ML-Agents/Examples/SharedAssets/Scripts/RayPerception3D.cs
  3. 16
      UnitySDK/Assets/ML-Agents/Examples/WallJump/Scripts/WallJumpAgent.cs
  4. 18
      UnitySDK/ProjectSettings/QualitySettings.asset
  5. 2
      UnitySDK/csharp_timers.json
  6. 4
      config/trainer_config.yaml
  7. 2
      csharp_timers.json
  8. 94
      UnitySDK/Assets/ML-Agents/Examples/SharedAssets/Materials/GridMatHazard.mat
  9. 9
      UnitySDK/Assets/ML-Agents/Examples/SharedAssets/Materials/GridMatHazard.mat.meta

2
UnitySDK/Assets/ML-Agents/Examples/SharedAssets/Materials/GridMatMoveable.mat


- _GlossyReflections: 1
- _GridSize: 1
- _LineOffset: 0.5
- _LineSize: 0.08
- _LineSize: 0.05
- _LineWidth: 0.1
- _Metallic: 0
- _Mode: 0

33
UnitySDK/Assets/ML-Agents/Examples/SharedAssets/Scripts/RayPerception3D.cs


using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace MLAgents

Vector3 m_EndPosition;
RaycastHit m_Hit;
private float[] m_SubList;
public bool drawSphereGizmos;
public float gizmoSphereRadius = .5f;
public float gizmoSphereDrawDist = 2f;
public float[] rayAnglesForDebug;
/// <summary>
/// Creates perception vector to be used as part of an observation of an agent.
/// Each ray in the rayAngles array adds a sublist of data to the observation.

{
if (m_SubList == null || m_SubList.Length != detectableObjects.Length + 2)
m_SubList = new float[detectableObjects.Length + 2];
if (drawSphereGizmos)
{
rayAnglesForDebug = rayAngles;
}
// if (rayAnglesForDebug == null)
// {
// rayAnglesForDebug = new float[rayAngles.Length];
// }
m_PerceptionBuffer.Clear();
m_PerceptionBuffer.Capacity = m_SubList.Length * rayAngles.Length;

}
return m_PerceptionBuffer;
}
private void OnDrawGizmos()
{
if (drawSphereGizmos)
{
foreach (var angle in rayAnglesForDebug)
{
var pos = transform.TransformPoint(
PolarToCartesian(gizmoSphereDrawDist, angle));
Gizmos.DrawWireSphere(pos, gizmoSphereRadius);
}
}
}
/// <summary>

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


m_AgentRb.velocity = Vector3.zero;
}
private void FixedUpdate()
{
if (m_Configuration != -1)
{
ConfigureAgent(m_Configuration);
m_Configuration = -1;
}
}
// private void FixedUpdate()
// {
// if (m_Configuration != -1)
// {
// ConfigureAgent(m_Configuration);
// m_Configuration = -1;
// }
// }
/// <summary>
/// Configures the agent. Given an integer config, the wall will have

18
UnitySDK/ProjectSettings/QualitySettings.asset


asyncUploadBufferSize: 4
resolutionScalingFixedDPIFactor: 1
excludedTargetPlatforms: []
m_PerPlatformDefaultQuality:
Android: 2
Nintendo 3DS: 5
Nintendo Switch: 5
PS4: 5
PSM: 5
PSP2: 2
Samsung TV: 2
Standalone: 5
Tizen: 2
Web: 5
WebGL: 3
WiiU: 5
Windows Store Apps: 5
XboxOne: 5
iPhone: 2
tvOS: 2
m_PerPlatformDefaultQuality: {}

2
UnitySDK/csharp_timers.json


{"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}}}
{"count":1,"self":336.08376319999996,"total":336.224354,"children":{"AgentResetIfDone":{"count":55,"self":0.0032559999999999998,"total":0.0032559999999999998,"children":null},"AgentSendState":{"count":55,"self":0.046099,"total":0.119173,"children":{"CollectObservations":{"count":456,"self":0.073074,"total":0.073074,"children":null}}},"BrainDecideAction":{"count":55,"self":0.003511,"total":0.003511,"children":null},"AcademyStep":{"count":55,"self":0.004344,"total":0.004344,"children":null},"AgentAct":{"count":55,"self":0.0085449999999999988,"total":0.0085449999999999988,"children":null}}}

4
config/trainer_config.yaml


num_layers: 2
SmallWallJumpLearning:
max_steps: 2.0e5
max_steps: 1.0e6
batch_size: 128
buffer_size: 2048
beta: 5.0e-3

time_horizon: 1000
batch_size: 512
buffer_size: 4096
max_steps: 2e6
max_steps: 1.0e6
summary_freq: 3000
num_layers: 2
hidden_units: 128

2
csharp_timers.json


{"count":1,"self":26.708940799999997,"total":239.834716,"children":{"AgentResetIfDone":{"count":13809,"self":0.14462899999999998,"total":0.14462899999999998,"children":null},"AgentSendState":{"count":13809,"self":1.018158,"total":4.721239,"children":{"CollectObservations":{"count":110472,"self":3.7030808,"total":3.7030809999999996,"children":null}}},"BrainDecideAction":{"count":13809,"self":207.38073599999998,"total":207.380741,"children":null},"AcademyStep":{"count":13809,"self":0.07435,"total":0.07435,"children":null},"AgentAct":{"count":13809,"self":0.802439,"total":0.802439,"children":null}}}9899999999993,"children":null}}}
{"count":1,"self":375.14826239999996,"total":8686.488904,"children":{"AgentResetIfDone":{"count":414663,"self":4.5990952,"total":4.599095,"children":null},"AgentSendState":{"count":414663,"self":37.254604799999996,"total":161.11343,"children":{"CollectObservations":{"count":3317304,"self":123.8588288,"total":123.858824,"children":null}}},"BrainDecideAction":{"count":414663,"self":8115.9315455999995,"total":8115.931369,"children":null},"AcademyStep":{"count":414663,"self":2.635214,"total":2.635214,"children":null},"AgentAct":{"count":414663,"self":27.058908799999998,"total":27.058909999999997,"children":null}}}

94
UnitySDK/Assets/ML-Agents/Examples/SharedAssets/Materials/GridMatHazard.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: GridMatMoveable
m_Shader: {fileID: 4800000, guid: bbecf177c38d84ff08d7c683c116affd, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DrawU: 1
- _DrawV: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0
- _GlossyReflections: 1
- _GridSize: 1
- _LineOffset: 0.5
- _LineSize: 0.05
- _LineWidth: 0.1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Offset: 0
- _Parallax: 0.02
- _ParcelSize: 1
- _RepeatCount: 5
- _SelectCell: 0
- _SelectedCellX: 0
- _SelectedCellY: 0
- _SmoothnessTextureChannel: 0
- _Spacing: 0.5
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
- _transparency: 1
m_Colors:
- _CellColor: {r: 0.9254902, g: 0.9372549, b: 0.9411765, a: 1}
- _Color: {r: 0.935151, g: 0.9705882, b: 0.3282872, a: 0}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _LineColor: {r: 0.7058824, g: 0.7058824, b: 0.7058824, a: 1}
- _MainColor: {r: 1, g: 1, b: 1, a: 1}
- _SelectedColor: {r: 0.1586206, g: 1, b: 0, a: 1}

9
UnitySDK/Assets/ML-Agents/Examples/SharedAssets/Materials/GridMatHazard.mat.meta


fileFormatVersion: 2
guid: ecd293b3a0715436799b13ed2154c443
timeCreated: 1527928195
licenseType: Store
NativeFormatImporter:
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存