浏览代码

Convert pyramids to Raycast sensor (#3299)

/asymm-envs
GitHub 5 年前
当前提交
ceebacd6
共有 4 个文件被更改,包括 809 次插入327 次删除
  1. 117
      Project/Assets/ML-Agents/Examples/Pyramids/Prefabs/AreaPB.prefab
  2. 11
      Project/Assets/ML-Agents/Examples/Pyramids/Scripts/PyramidAgent.cs
  3. 1001
      Project/Assets/ML-Agents/Examples/Pyramids/TFModels/Pyramids.nn
  4. 7
      com.unity.ml-agents/csharp_timers.json.meta

117
Project/Assets/ML-Agents/Examples/Pyramids/Prefabs/AreaPB.prefab


- component: {fileID: 54596704247224538}
- component: {fileID: 114399412043818042}
- component: {fileID: 114937736047215868}
- component: {fileID: 114507422577425370}
- component: {fileID: 5712624269609438939}
- component: {fileID: 5767481171805996936}
- component: {fileID: 4725417187860315718}
m_Layer: 0
m_Name: Agent
m_TagString: agent

m_Name:
m_EditorClassIdentifier:
m_BrainParameters:
vectorObservationSize: 172
vectorObservationSize: 4
numStackedVectorObservations: 1
vectorActionSize: 05000000
vectorActionDescriptions: []

area: {fileID: 1464170487903594}
areaSwitch: {fileID: 1432086782037750}
useVectorObs: 1
--- !u!114 &114507422577425370
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1131043459059966}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bb172294dbbcc408286b156a2c4b553c, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!65 &65345930959735878
BoxCollider:
m_ObjectHideFlags: 0

DecisionPeriod: 5
RepeatAction: 1
offsetStep: 0
--- !u!114 &5712624269609438939
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1131043459059966}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6bb6b867a41448888c1cd4f99643ad71, type: 3}
m_Name:
m_EditorClassIdentifier:
sensorName: RayPerceptionSensor
detectableTags:
- block
- wall
- goal
- switchOff
- switchOn
- stone
raysPerDirection: 3
maxRayDegrees: 70
sphereCastRadius: 0.5
rayLength: 35
rayLayerMask:
serializedVersion: 2
m_Bits: 4294967291
observationStacks: 1
rayHitColor: {r: 1, g: 0, b: 0, a: 1}
rayMissColor: {r: 1, g: 1, b: 1, a: 1}
useWorldPositions: 1
startVerticalOffset: 0
endVerticalOffset: 0
--- !u!114 &5767481171805996936
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1131043459059966}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6bb6b867a41448888c1cd4f99643ad71, type: 3}
m_Name:
m_EditorClassIdentifier:
sensorName: RayPerceptionSensor1
detectableTags:
- block
- wall
- goal
- switchOff
- switchOn
- stone
raysPerDirection: 3
maxRayDegrees: 65
sphereCastRadius: 0.5
rayLength: 35
rayLayerMask:
serializedVersion: 2
m_Bits: 4294967291
observationStacks: 1
rayHitColor: {r: 1, g: 0, b: 0, a: 1}
rayMissColor: {r: 1, g: 1, b: 1, a: 1}
useWorldPositions: 1
startVerticalOffset: 0
endVerticalOffset: 5
--- !u!114 &4725417187860315718
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1131043459059966}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6bb6b867a41448888c1cd4f99643ad71, type: 3}
m_Name:
m_EditorClassIdentifier:
sensorName: RayPerceptionSensor2
detectableTags:
- block
- wall
- goal
- switchOff
- switchOn
- stone
raysPerDirection: 3
maxRayDegrees: 75
sphereCastRadius: 0.5
rayLength: 35
rayLayerMask:
serializedVersion: 2
m_Bits: 4294967291
observationStacks: 1
rayHitColor: {r: 1, g: 0, b: 0, a: 1}
rayMissColor: {r: 1, g: 1, b: 1, a: 1}
useWorldPositions: 1
startVerticalOffset: 0
endVerticalOffset: 10
--- !u!1 &1148882946833254
GameObject:
m_ObjectHideFlags: 0

11
Project/Assets/ML-Agents/Examples/Pyramids/Scripts/PyramidAgent.cs


public GameObject area;
PyramidArea m_MyArea;
Rigidbody m_AgentRb;
RayPerception m_RayPer;
PyramidSwitch m_SwitchLogic;
public GameObject areaSwitch;
public bool useVectorObs;

base.InitializeAgent();
m_AgentRb = GetComponent<Rigidbody>();
m_MyArea = area.GetComponent<PyramidArea>();
m_RayPer = GetComponent<RayPerception>();
m_SwitchLogic = areaSwitch.GetComponent<PyramidSwitch>();
}

{
const float rayDistance = 35f;
float[] rayAngles = { 20f, 90f, 160f, 45f, 135f, 70f, 110f };
float[] rayAngles1 = { 25f, 95f, 165f, 50f, 140f, 75f, 115f };
float[] rayAngles2 = { 15f, 85f, 155f, 40f, 130f, 65f, 105f };
string[] detectableObjects = { "block", "wall", "goal", "switchOff", "switchOn", "stone" };
AddVectorObs(m_RayPer.Perceive(rayDistance, rayAngles, detectableObjects));
AddVectorObs(m_RayPer.Perceive(rayDistance, rayAngles1, detectableObjects, 0f, 5f));
AddVectorObs(m_RayPer.Perceive(rayDistance, rayAngles2, detectableObjects, 0f, 10f));
AddVectorObs(m_SwitchLogic.GetState());
AddVectorObs(transform.InverseTransformDirection(m_AgentRb.velocity));
}

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

7
com.unity.ml-agents/csharp_timers.json.meta


fileFormatVersion: 2
guid: d0b30a07226cb466d814e9351b8c231e
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存