V2.6 change Ray Tag result as Onehot
change Ray Tag result as Onehot, Observation State: -targetStates 6 -inTargetArea 1 -remainTime 1 -gunReady 1 -my Obs 4 -tag onehot 19*2 -tag dis 19
This commit is contained in:
@@ -1 +1 @@
|
||||
{"count":1,"self":7.6010208,"total":7.7934259,"children":{"InitializeActuators":{"count":16,"self":0.001499,"total":0.001499,"children":null},"InitializeSensors":{"count":16,"self":0.001,"total":0.001,"children":null},"AgentSendState":{"count":138,"self":0.002006,"total":0.0155275,"children":{"CollectObservations":{"count":1104,"self":0.010023899999999999,"total":0.010023899999999999,"children":null},"WriteActionMask":{"count":1104,"self":0.0015048,"total":0.0015048,"children":null},"RequestDecision":{"count":1104,"self":0.0019928,"total":0.0019928,"children":null}}},"DecideAction":{"count":138,"self":0.0055068,"total":0.0055068,"children":null},"AgentAct":{"count":138,"self":0.1678665,"total":0.1678665,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1670578612","unity_version":"2021.3.14f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2021.3.14f1\\Editor\\Unity.exe -projectpath C:\\Users\\UCUNI\\OneDrive\\Unity\\ML-Agents\\Aimbot-ParallelEnv -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-_qjpya-1B8A6Gvs6pbjAv -hubSessionId 13566e90-76f5-11ed-81d5-5bc0486f82d5 -accessToken qw1R29ZQd77wYz840DIgO8Mcql8NgyzciHRCP0pk3Ls00ef","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"InGame","end_time_seconds":"1670578620"}}
|
||||
{"count":1,"self":15.2624832,"total":16.0374865,"children":{"InitializeActuators":{"count":16,"self":0.0020017999999999998,"total":0.0020017999999999998,"children":null},"InitializeSensors":{"count":16,"self":0.0020989999999999997,"total":0.0020989999999999997,"children":null},"AgentSendState":{"count":547,"self":0.0070130999999999995,"total":0.034057899999999995,"children":{"CollectObservations":{"count":4376,"self":0.0200301,"total":0.0200301,"children":null},"WriteActionMask":{"count":4376,"self":0.0015003,"total":0.0015003,"children":null},"RequestDecision":{"count":4376,"self":0.0055144,"total":0.0055144,"children":null}}},"DecideAction":{"count":547,"self":0.0085414999999999987,"total":0.0085414999999999987,"children":null},"AgentAct":{"count":547,"self":0.72779699999999992,"total":0.72779699999999992,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1670633960","unity_version":"2021.3.14f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2021.3.14f1\\Editor\\Unity.exe -projectpath C:\\Users\\UCUNI\\OneDrive\\Unity\\ML-Agents\\Aimbot-ParallelEnv -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-BIduOqLJT8GiF8SNWhGj_ -hubSessionId e2ebfc30-77ac-11ed-bf56-45d250d830d4 -accessToken aCi_2ERt33bo42jVTu8X3P-PvUkABd5hiU-fyHtjEnA00ef","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"InGame","end_time_seconds":"1670633976"}}
|
||||
+44
-28
@@ -2406,7 +2406,7 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_BrainParameters:
|
||||
VectorObservationSize: 39
|
||||
VectorObservationSize: 70
|
||||
NumStackedVectorObservations: 1
|
||||
m_ActionSpec:
|
||||
m_NumContinuousActions: 1
|
||||
@@ -2454,6 +2454,7 @@ MonoBehaviour:
|
||||
mouseXSensitivity: 100
|
||||
mouseYSensitivity: 200
|
||||
yRotation: 0.1
|
||||
oneHotRayTag: 1
|
||||
defaultTPCamera: 1
|
||||
--- !u!114 &86413631
|
||||
MonoBehaviour:
|
||||
@@ -2474,13 +2475,14 @@ MonoBehaviour:
|
||||
agentCanvas: {fileID: 1159571854}
|
||||
viewDistance: 100
|
||||
focusRange: 0.15
|
||||
halfOuterRayNum: 5
|
||||
focusRayNum: 3
|
||||
halfOuterRayNum: 7
|
||||
focusRayNum: 5
|
||||
showInGameRay: 1
|
||||
showDebugRay: 0
|
||||
showInGameRayInfo: 1
|
||||
lineWidth: 0.05
|
||||
rayTagResult: []
|
||||
rayTagResultOneHot: []
|
||||
rayDisResult: []
|
||||
inViewEnemies: []
|
||||
--- !u!143 &86413632
|
||||
@@ -13044,7 +13046,7 @@ Mesh:
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: pb_Mesh189752
|
||||
m_Name: pb_Mesh130832
|
||||
serializedVersion: 10
|
||||
m_SubMeshes:
|
||||
- serializedVersion: 2
|
||||
@@ -16806,7 +16808,7 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_BrainParameters:
|
||||
VectorObservationSize: 39
|
||||
VectorObservationSize: 70
|
||||
NumStackedVectorObservations: 1
|
||||
m_ActionSpec:
|
||||
m_NumContinuousActions: 1
|
||||
@@ -16854,6 +16856,7 @@ MonoBehaviour:
|
||||
mouseXSensitivity: 100
|
||||
mouseYSensitivity: 200
|
||||
yRotation: 0.1
|
||||
oneHotRayTag: 1
|
||||
defaultTPCamera: 1
|
||||
--- !u!114 &629870341
|
||||
MonoBehaviour:
|
||||
@@ -16874,13 +16877,14 @@ MonoBehaviour:
|
||||
agentCanvas: {fileID: 1054491405}
|
||||
viewDistance: 100
|
||||
focusRange: 0.15
|
||||
halfOuterRayNum: 5
|
||||
focusRayNum: 3
|
||||
halfOuterRayNum: 7
|
||||
focusRayNum: 5
|
||||
showInGameRay: 1
|
||||
showDebugRay: 0
|
||||
showInGameRayInfo: 1
|
||||
lineWidth: 0.05
|
||||
rayTagResult: []
|
||||
rayTagResultOneHot: []
|
||||
rayDisResult: []
|
||||
inViewEnemies: []
|
||||
--- !u!143 &629870342
|
||||
@@ -23915,7 +23919,7 @@ Mesh:
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: pb_Mesh189648
|
||||
m_Name: pb_Mesh130728
|
||||
serializedVersion: 10
|
||||
m_SubMeshes:
|
||||
- serializedVersion: 2
|
||||
@@ -24969,7 +24973,7 @@ Mesh:
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: pb_Mesh193258
|
||||
m_Name: pb_Mesh134378
|
||||
serializedVersion: 10
|
||||
m_SubMeshes:
|
||||
- serializedVersion: 2
|
||||
@@ -28794,7 +28798,7 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_BrainParameters:
|
||||
VectorObservationSize: 39
|
||||
VectorObservationSize: 70
|
||||
NumStackedVectorObservations: 1
|
||||
m_ActionSpec:
|
||||
m_NumContinuousActions: 1
|
||||
@@ -28842,6 +28846,7 @@ MonoBehaviour:
|
||||
mouseXSensitivity: 100
|
||||
mouseYSensitivity: 200
|
||||
yRotation: 0.1
|
||||
oneHotRayTag: 1
|
||||
defaultTPCamera: 1
|
||||
--- !u!114 &1040515778
|
||||
MonoBehaviour:
|
||||
@@ -28862,13 +28867,14 @@ MonoBehaviour:
|
||||
agentCanvas: {fileID: 1360499123}
|
||||
viewDistance: 100
|
||||
focusRange: 0.15
|
||||
halfOuterRayNum: 5
|
||||
focusRayNum: 3
|
||||
halfOuterRayNum: 7
|
||||
focusRayNum: 5
|
||||
showInGameRay: 1
|
||||
showDebugRay: 0
|
||||
showInGameRayInfo: 1
|
||||
lineWidth: 0.05
|
||||
rayTagResult: []
|
||||
rayTagResultOneHot: []
|
||||
rayDisResult: []
|
||||
inViewEnemies: []
|
||||
--- !u!143 &1040515779
|
||||
@@ -36835,7 +36841,7 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_BrainParameters:
|
||||
VectorObservationSize: 39
|
||||
VectorObservationSize: 70
|
||||
NumStackedVectorObservations: 1
|
||||
m_ActionSpec:
|
||||
m_NumContinuousActions: 1
|
||||
@@ -36883,6 +36889,7 @@ MonoBehaviour:
|
||||
mouseXSensitivity: 100
|
||||
mouseYSensitivity: 200
|
||||
yRotation: 0.1
|
||||
oneHotRayTag: 1
|
||||
defaultTPCamera: 1
|
||||
--- !u!114 &1379895155
|
||||
MonoBehaviour:
|
||||
@@ -36903,13 +36910,14 @@ MonoBehaviour:
|
||||
agentCanvas: {fileID: 292511581}
|
||||
viewDistance: 100
|
||||
focusRange: 0.15
|
||||
halfOuterRayNum: 5
|
||||
focusRayNum: 3
|
||||
halfOuterRayNum: 7
|
||||
focusRayNum: 5
|
||||
showInGameRay: 1
|
||||
showDebugRay: 0
|
||||
showInGameRayInfo: 1
|
||||
lineWidth: 0.05
|
||||
rayTagResult: []
|
||||
rayTagResultOneHot: []
|
||||
rayDisResult: []
|
||||
inViewEnemies: []
|
||||
--- !u!143 &1379895156
|
||||
@@ -38757,7 +38765,7 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_BrainParameters:
|
||||
VectorObservationSize: 39
|
||||
VectorObservationSize: 70
|
||||
NumStackedVectorObservations: 1
|
||||
m_ActionSpec:
|
||||
m_NumContinuousActions: 1
|
||||
@@ -38805,6 +38813,7 @@ MonoBehaviour:
|
||||
mouseXSensitivity: 100
|
||||
mouseYSensitivity: 200
|
||||
yRotation: 0.1
|
||||
oneHotRayTag: 1
|
||||
defaultTPCamera: 1
|
||||
--- !u!114 &1463948060
|
||||
MonoBehaviour:
|
||||
@@ -38825,13 +38834,14 @@ MonoBehaviour:
|
||||
agentCanvas: {fileID: 1560580715}
|
||||
viewDistance: 100
|
||||
focusRange: 0.15
|
||||
halfOuterRayNum: 5
|
||||
focusRayNum: 3
|
||||
halfOuterRayNum: 7
|
||||
focusRayNum: 5
|
||||
showInGameRay: 1
|
||||
showDebugRay: 0
|
||||
showInGameRayInfo: 1
|
||||
lineWidth: 0.05
|
||||
rayTagResult: []
|
||||
rayTagResultOneHot: []
|
||||
rayDisResult: []
|
||||
inViewEnemies: []
|
||||
--- !u!143 &1463948061
|
||||
@@ -39523,7 +39533,7 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_BrainParameters:
|
||||
VectorObservationSize: 39
|
||||
VectorObservationSize: 70
|
||||
NumStackedVectorObservations: 1
|
||||
m_ActionSpec:
|
||||
m_NumContinuousActions: 1
|
||||
@@ -39571,6 +39581,7 @@ MonoBehaviour:
|
||||
mouseXSensitivity: 100
|
||||
mouseYSensitivity: 200
|
||||
yRotation: 0.1
|
||||
oneHotRayTag: 1
|
||||
defaultTPCamera: 1
|
||||
--- !u!114 &1490348734
|
||||
MonoBehaviour:
|
||||
@@ -39591,13 +39602,14 @@ MonoBehaviour:
|
||||
agentCanvas: {fileID: 618792061}
|
||||
viewDistance: 100
|
||||
focusRange: 0.15
|
||||
halfOuterRayNum: 5
|
||||
focusRayNum: 3
|
||||
halfOuterRayNum: 7
|
||||
focusRayNum: 5
|
||||
showInGameRay: 1
|
||||
showDebugRay: 0
|
||||
showInGameRayInfo: 1
|
||||
lineWidth: 0.05
|
||||
rayTagResult: []
|
||||
rayTagResultOneHot: []
|
||||
rayDisResult: []
|
||||
inViewEnemies: []
|
||||
--- !u!143 &1490348735
|
||||
@@ -40693,7 +40705,7 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_BrainParameters:
|
||||
VectorObservationSize: 39
|
||||
VectorObservationSize: 70
|
||||
NumStackedVectorObservations: 1
|
||||
m_ActionSpec:
|
||||
m_NumContinuousActions: 1
|
||||
@@ -40741,6 +40753,7 @@ MonoBehaviour:
|
||||
mouseXSensitivity: 100
|
||||
mouseYSensitivity: 200
|
||||
yRotation: 0.1
|
||||
oneHotRayTag: 1
|
||||
defaultTPCamera: 1
|
||||
--- !u!114 &1527717524
|
||||
MonoBehaviour:
|
||||
@@ -40761,13 +40774,14 @@ MonoBehaviour:
|
||||
agentCanvas: {fileID: 1724835459}
|
||||
viewDistance: 100
|
||||
focusRange: 0.15
|
||||
halfOuterRayNum: 5
|
||||
focusRayNum: 3
|
||||
halfOuterRayNum: 7
|
||||
focusRayNum: 5
|
||||
showInGameRay: 1
|
||||
showDebugRay: 0
|
||||
showInGameRayInfo: 1
|
||||
lineWidth: 0.05
|
||||
rayTagResult: []
|
||||
rayTagResultOneHot: []
|
||||
rayDisResult: []
|
||||
inViewEnemies: []
|
||||
--- !u!143 &1527717525
|
||||
@@ -45521,7 +45535,7 @@ Mesh:
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: pb_Mesh189800
|
||||
m_Name: pb_Mesh130880
|
||||
serializedVersion: 10
|
||||
m_SubMeshes:
|
||||
- serializedVersion: 2
|
||||
@@ -51108,7 +51122,7 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_BrainParameters:
|
||||
VectorObservationSize: 39
|
||||
VectorObservationSize: 70
|
||||
NumStackedVectorObservations: 1
|
||||
m_ActionSpec:
|
||||
m_NumContinuousActions: 1
|
||||
@@ -51156,6 +51170,7 @@ MonoBehaviour:
|
||||
mouseXSensitivity: 100
|
||||
mouseYSensitivity: 200
|
||||
yRotation: 0.1
|
||||
oneHotRayTag: 1
|
||||
defaultTPCamera: 1
|
||||
--- !u!114 &1834289471
|
||||
MonoBehaviour:
|
||||
@@ -51176,13 +51191,14 @@ MonoBehaviour:
|
||||
agentCanvas: {fileID: 450578166}
|
||||
viewDistance: 100
|
||||
focusRange: 0.15
|
||||
halfOuterRayNum: 5
|
||||
focusRayNum: 3
|
||||
halfOuterRayNum: 7
|
||||
focusRayNum: 5
|
||||
showInGameRay: 1
|
||||
showDebugRay: 0
|
||||
showInGameRayInfo: 1
|
||||
lineWidth: 0.05
|
||||
rayTagResult: []
|
||||
rayTagResultOneHot: []
|
||||
rayDisResult: []
|
||||
inViewEnemies: []
|
||||
--- !u!143 &1834289472
|
||||
|
||||
@@ -42,6 +42,7 @@ public class AgentWithGun : Agent
|
||||
public float yRotation = 0.1f;//定义一个浮点类型的量,记录‘围绕’X轴旋转的角度
|
||||
|
||||
[Header("Env")]
|
||||
public bool oneHotRayTag = true;
|
||||
private List<float> spinRecord = new List<float>();
|
||||
private bool lockMouse;
|
||||
private float Damage;
|
||||
@@ -418,6 +419,7 @@ public class AgentWithGun : Agent
|
||||
{
|
||||
EnvUICon.initChart();
|
||||
}
|
||||
rayScript.updateRayInfo(); // update raycast
|
||||
}
|
||||
// ML-AGENTS处理-------------------------------------------------------------------------------------------ML-AGENTS
|
||||
// 观察情报
|
||||
@@ -426,11 +428,13 @@ public class AgentWithGun : Agent
|
||||
//List<float> enemyLDisList = RaySensors.enemyLDisList;// All Enemy Lside Distances
|
||||
//List<float> enemyRDisList = RaySensors.enemyRDisList;// All Enemy Rside Distances
|
||||
|
||||
float[] myObserve = { transform.localPosition.x, transform.localPosition.y, transform.localPosition.z, transform.eulerAngles.y };
|
||||
float[] myObserve = { transform.localPosition.x, transform.localPosition.y, transform.localPosition.z, transform.eulerAngles.y/360f };
|
||||
float[] rayTagResult = rayScript.rayTagResult;// 探测用RayTag结果 float[](raySensorNum,1)
|
||||
float[] rayTagResultOnehot = rayScript.rayTagResultOneHot.ToArray(); // 探测用RayTagonehot结果 List<int>[](raySensorNum*Tags,1)
|
||||
float[] rayDisResult = rayScript.rayDisResult; // 探测用RayDis结果 float[](raySensorNum,1)
|
||||
float[] targetStates = targetCon.targetState; // (6) targettype, target x,y,z, firebasesAreaDiameter
|
||||
float remainTime = targetCon.leftTime;
|
||||
gunReadyToggle = gunReady();
|
||||
//float[] focusEnemyObserve = RaySensors.focusEnemyInfo;// 最近的Enemy情报 float[](3,1) MinEnemyIndex,x,z
|
||||
|
||||
//sensor.AddObservation(allEnemyNum); // 敌人数量 int
|
||||
@@ -439,11 +443,17 @@ public class AgentWithGun : Agent
|
||||
sensor.AddObservation(remainTime); // (1)
|
||||
sensor.AddObservation(gunReadyToggle); //(1) save gun is ready?
|
||||
sensor.AddObservation(myObserve); // (4)自机位置xyz+朝向 float[](4,1)
|
||||
sensor.AddObservation(rayTagResult); // 探测用RayTag结果 float[](raySensorNum,1)
|
||||
if (oneHotRayTag)
|
||||
{
|
||||
sensor.AddObservation(rayTagResultOnehot); // 探测用RayTag结果 float[](raySensorNum,1)
|
||||
}
|
||||
else
|
||||
{
|
||||
sensor.AddObservation(rayTagResult);
|
||||
}
|
||||
sensor.AddObservation(rayDisResult); // 探测用RayDis结果 float[](raySensorNum,1)
|
||||
//sensor.AddObservation(focusEnemyObserve); // 最近的Enemy情报 float[](3,1) MinEnemyIndex,x,z
|
||||
//sensor.AddObservation(raySensorNum); // raySensor数量 int
|
||||
gunReadyToggle = gunReady();
|
||||
//sensor.AddObservation(remainTime); // RemainTime int
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
public class Onehot
|
||||
{
|
||||
private List<string> tags = new List<string>();
|
||||
public List<List<float>> onehot = new List<List<float>>();
|
||||
private float totalNum;
|
||||
public void initialize(List<string> inputTags)
|
||||
{
|
||||
tags = inputTags;
|
||||
totalNum = tags.Count;
|
||||
for (int i = 0; i < totalNum; i++)
|
||||
{
|
||||
List<float> thisOnehot = new List<float>();
|
||||
for (int j = 0; j < totalNum; j++) thisOnehot.Add(0f);
|
||||
thisOnehot[i] = 1f;
|
||||
onehot.Add(thisOnehot);
|
||||
}
|
||||
}
|
||||
public List<float> encoder(string name = null)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
List<float> allZeroOnehot = new List<float>();
|
||||
for (int j = 0; j < totalNum; j++) allZeroOnehot.Add(0);
|
||||
return allZeroOnehot;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
return onehot[tags.IndexOf(name)];
|
||||
}catch(ArgumentOutOfRangeException)
|
||||
{
|
||||
List<float> allZeroOnehot = new List<float>();
|
||||
for (int j = 0; j < totalNum; j++) allZeroOnehot.Add(0);
|
||||
return allZeroOnehot;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string decoder(List<float> thisOnehot)
|
||||
{
|
||||
return tags[onehot.IndexOf(thisOnehot)];
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cc32b1477a6cda045910784943fbcfd5
|
||||
guid: cdb75d03525930d4caaefab4eaaf6e8a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
/*该scrip用于创建复数条ray于视角内,并探测被ray射到的物体*/
|
||||
@@ -28,6 +29,7 @@ public class RaySensors : MonoBehaviour
|
||||
|
||||
[Header("RayCastResult")]
|
||||
public float[] rayTagResult;
|
||||
public List<float> rayTagResultOneHot;
|
||||
public float[] rayDisResult;
|
||||
|
||||
[System.NonSerialized] public int totalRayNum;
|
||||
@@ -37,6 +39,8 @@ public class RaySensors : MonoBehaviour
|
||||
LineRenderer[] lineRenderers;
|
||||
rayInfoUI[] rayInfoUIs;
|
||||
public List<GameObject> inViewEnemies = new List<GameObject>();
|
||||
private List<string> tags = new List<string> {"Wall","Enemy"};
|
||||
private Onehot oneHotTags = new Onehot();
|
||||
|
||||
|
||||
private void Start()
|
||||
@@ -49,7 +53,8 @@ public class RaySensors : MonoBehaviour
|
||||
lineRenderers = new LineRenderer[totalRayNum];
|
||||
rayInfoOBJ = new GameObject[totalRayNum];
|
||||
rayInfoUIs = new rayInfoUI[totalRayNum];
|
||||
for(int i = 0; i < totalRayNum; i++)
|
||||
oneHotTags.initialize(tags);
|
||||
for (int i = 0; i < totalRayNum; i++)
|
||||
{
|
||||
linesOBJ[i] = new GameObject();
|
||||
linesOBJ[i].name = "rayCastLine-" + Convert.ToString(i);
|
||||
@@ -91,10 +96,12 @@ public class RaySensors : MonoBehaviour
|
||||
if (Physics.Raycast(ray, out thisHit, viewDistance)) // 若在viewDistance范围内有碰撞
|
||||
{
|
||||
rayInfoText = thisHit.collider.tag;
|
||||
rayTagResult = tagToInt(thisHit.collider.tag);
|
||||
rayTagResult = tagToInt(rayInfoText);
|
||||
rayTagResultOneHot.AddRange(oneHotTags.encoder(rayInfoText));
|
||||
rayDisResult = thisHit.distance;
|
||||
lineLength = rayDisResult;
|
||||
rayInfoText += "\n" + Convert.ToString(rayDisResult);
|
||||
rayDisResult = rayDisResult / viewDistance; // Normalization!
|
||||
//输出log
|
||||
switch (rayTagResult)
|
||||
{
|
||||
@@ -115,6 +122,7 @@ public class RaySensors : MonoBehaviour
|
||||
}
|
||||
else // 若在viewDistance范围无碰撞
|
||||
{
|
||||
rayTagResultOneHot.AddRange(oneHotTags.encoder());
|
||||
rayTagResult = -1f;
|
||||
rayDisResult = -1f;
|
||||
//输出log
|
||||
@@ -165,6 +173,7 @@ public class RaySensors : MonoBehaviour
|
||||
float focusREdge = agentCam.pixelWidth * (1 + focusRange) / 2;
|
||||
float thisCamPixelHeight = agentCam.pixelHeight;
|
||||
inViewEnemies.Clear();
|
||||
rayTagResultOneHot.Clear();
|
||||
for (int i = 0; i < halfOuterRayNum; i++) // create left outside rays; 0 ~ focusLeftEdge
|
||||
{
|
||||
Vector3 point = new Vector3(i * focusLEdge / (halfOuterRayNum - 1), thisCamPixelHeight / 2, 0);
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class sideChennelManager : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user