V3.1.6 修正TrainMode中Target不更新问题

修正TrainMode中Target不更新问题
This commit is contained in:
Koha9 2023-07-29 04:04:18 +09:00
parent 630cbc4f70
commit df1958c48e
8 changed files with 60 additions and 45 deletions

View File

@ -1 +1 @@
{"count":1,"self":104.97326079999999,"total":112.0977204,"children":{"InitializeActuators":{"count":16,"self":0.0010003,"total":0.0010003,"children":null},"InitializeSensors":{"count":16,"self":0.0005001,"total":0.0005001,"children":null},"AgentSendState":{"count":5390,"self":0.076617499999999991,"total":0.813488,"children":{"CollectObservations":{"count":43120,"self":0.6721809,"total":0.6721809,"children":null},"WriteActionMask":{"count":43120,"self":0.0220062,"total":0.0220062,"children":null},"RequestDecision":{"count":43120,"self":0.042683399999999996,"total":0.042683399999999996,"children":null}}},"DecideAction":{"count":5390,"self":0.0811302,"total":0.0811302,"children":null},"AgentAct":{"count":5390,"self":6.22784,"total":6.2278401,"children":null}},"gauges":{"AKMAgent.CumulativeReward":{"count":24,"max":-2072.377,"min":-3955.04,"runningAverage":-3431.14233,"value":-3949.06714,"weightedAverage":-3815.8313}},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1690540848","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-UCUNI -hubSessionId 4b63fb8e-9776-4262-b4cb-28aa0e369085 -accessToken Pb-uYo6-TCqI_VYWW4hD7qruW991NK-uVlSKxlTMxiM00ef","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"Train","end_time_seconds":"1690540960"}} {"count":1,"self":93.9066496,"total":100.4165704,"children":{"InitializeActuators":{"count":16,"self":0.0014999,"total":0.0014999,"children":null},"InitializeSensors":{"count":16,"self":0.0009984,"total":0.0009984,"children":null},"AgentSendState":{"count":4785,"self":0.068162199999999992,"total":0.6963434,"children":{"CollectObservations":{"count":38280,"self":0.5769577,"total":0.5769577,"children":null},"WriteActionMask":{"count":38280,"self":0.0135614,"total":0.0135614,"children":null},"RequestDecision":{"count":38280,"self":0.0376621,"total":0.0376621,"children":null}}},"DecideAction":{"count":4785,"self":0.076930699999999991,"total":0.076930699999999991,"children":null},"AgentAct":{"count":4785,"self":5.7336504,"total":5.7336504999999995,"children":null}},"gauges":{"AKMAgent.CumulativeReward":{"count":24,"max":2806.10864,"min":-4452.61768,"runningAverage":-2349.35767,"value":-3779.56152,"weightedAverage":-3245.75586}},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1690570399","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-UCUNI -hubSessionId 86b502dc-202f-4afa-ba52-5731b3c3e27e -accessToken bXZIpg17jDRkRVo5dVNqmYk0dCWyT28bRLu3CEAvUuU00ef","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"Train","end_time_seconds":"1690570500"}}

View File

@ -16,6 +16,7 @@ private void Start()
// initialize enemy by random // initialize enemy by random
public void RandomInitEnemys(int EnemyNum) public void RandomInitEnemys(int EnemyNum)
{ {
Debug.Log("RandomInitEnemys");
for (int i = 0; i < EnemyNum; i++) for (int i = 0; i < EnemyNum; i++)
{ {
float randX = UnityEngine.Random.Range(targetCon.minEnemyAreaX, targetCon.maxEnemyAreaX); float randX = UnityEngine.Random.Range(targetCon.minEnemyAreaX, targetCon.maxEnemyAreaX);
@ -28,6 +29,7 @@ public void RandomInitEnemys(int EnemyNum)
// initialize enemy by random but not in block area // initialize enemy by random but not in block area
public void RandomInitEnemysExcept(int enemyNum, Vector3 blockPosition, float sceneSize) public void RandomInitEnemysExcept(int enemyNum, Vector3 blockPosition, float sceneSize)
{ {
Debug.Log("RandomInitEnemysExcept");
float randX = 0f; float randX = 0f;
float randZ = 0f; float randZ = 0f;
for (int i = 0; i < enemyNum; i++) for (int i = 0; i < enemyNum; i++)

View File

@ -60,10 +60,12 @@ public override void OnEpisodeBegin()
if (paramContainer.gameMode == 0) if (paramContainer.gameMode == 0)
{ {
// train mode // train mode
Debug.Log("MLAgentCustomController.OnEpisodeBegin: train mode start");
targetController.RollNewScene(); targetController.RollNewScene();
} }
else else
{ {
Debug.Log("MLAgentCustomController.OnEpisodeBegin: play mode start");
// play mode // play mode
targetController.PlayInitialize(); targetController.PlayInitialize();
// reset target UI // reset target UI

View File

@ -147,6 +147,7 @@ private void Start()
targetTimeBonus = targetTimeBonusPerSec * timeLimit; targetTimeBonus = targetTimeBonusPerSec * timeLimit;
try try
{ {
// try get start scene data
startSceneData = GameObject.Find("StartSceneDataTransfer").GetComponent<StartSeneData>(); startSceneData = GameObject.Find("StartSceneDataTransfer").GetComponent<StartSeneData>();
gameMode = startSceneData.gameMode; gameMode = startSceneData.gameMode;
attackProb = startSceneData.attackProb; attackProb = startSceneData.attackProb;
@ -157,6 +158,9 @@ private void Start()
{ {
Debug.LogError("PrameterContainer:Run WithOut StartScreen!"); Debug.LogError("PrameterContainer:Run WithOut StartScreen!");
gameMode = 0; gameMode = 0;
attackProb = 0.3333f;
gotoProb = 0.3333f;
defenceProb = 0.0f;
} }
} }

View File

@ -100,13 +100,13 @@ public void InitBlock(GameObject envObj)
// if firebasesAreaObj is null, find sub object by name // if firebasesAreaObj is null, find sub object by name
if (fireBasesAreaObj == null) if (fireBasesAreaObj == null)
{ {
Debug.Log("SceneBlock.Start: fireBasesAreaObj not found, get it by name"); // Debug.Log("SceneBlock.Start: fireBasesAreaObj not found, get it by name");
fireBasesAreaObj = transform.Find("FirebasesArea").gameObject; fireBasesAreaObj = transform.Find("FirebasesArea").gameObject;
} }
// if enemyContainerObj is null, find them by name // if enemyContainerObj is null, find them by name
if (enemyContainerObj == null) if (enemyContainerObj == null)
{ {
Debug.Log("SceneBlock.Start: enemyContainerObj not found, get it by name"); // Debug.Log("SceneBlock.Start: enemyContainerObj not found, get it by name");
enemyContainerObj = transform.Find("EnemyContainer").gameObject; enemyContainerObj = transform.Find("EnemyContainer").gameObject;
} }
firebasesAreaPosition = transform.position + fireBasesAreaObj.transform.position; firebasesAreaPosition = transform.position + fireBasesAreaObj.transform.position;

View File

@ -142,6 +142,7 @@ public void RollNewScene()
{ {
// goto target spawn // goto target spawn
Debug.Log("GOTO THIS TARGET!"); Debug.Log("GOTO THIS TARGET!");
targetTypeInt = (int)SceneBlockContainer.Targets.Go;
RandomSpawnSceneBlock(SceneBlockContainer.Targets.Go); RandomSpawnSceneBlock(SceneBlockContainer.Targets.Go);
// set startDistance // set startDistance
firstRewardFlag = true; firstRewardFlag = true;
@ -150,6 +151,7 @@ public void RollNewScene()
{ {
// attack target spawn // attack target spawn
Debug.Log("ATTACK!"); Debug.Log("ATTACK!");
targetTypeInt = (int)SceneBlockContainer.Targets.Attack;
RandomSpawnSceneBlock(SceneBlockContainer.Targets.Attack); RandomSpawnSceneBlock(SceneBlockContainer.Targets.Attack);
// set startDistance // set startDistance
firstRewardFlag = true; firstRewardFlag = true;
@ -159,13 +161,14 @@ public void RollNewScene()
{ {
// defence target spawn // defence target spawn
Debug.Log("DEFENCE!"); Debug.Log("DEFENCE!");
targetTypeInt = (int)SceneBlockContainer.Targets.Defence;
RandomSpawnSceneBlock(SceneBlockContainer.Targets.Defence); RandomSpawnSceneBlock(SceneBlockContainer.Targets.Defence);
// set startDistance // set startDistance
firstRewardFlag = true; firstRewardFlag = true;
} }
else else
{ {
//Debug.Log("Free"); Debug.Log("Free");
targetTypeInt = (int)SceneBlockContainer.Targets.Free; targetTypeInt = (int)SceneBlockContainer.Targets.Free;
enemyCon.DestroyAllEnemys(); enemyCon.DestroyAllEnemys();
enemyCon.RandomInitEnemys(hudCon.enemyNum); enemyCon.RandomInitEnemys(hudCon.enemyNum);
@ -184,14 +187,18 @@ private void UpdateTargetStates(Vector3? thisTargetPosition = null)
if (thisTargetPosition != null) if (thisTargetPosition != null)
{ {
targetPosition = (Vector3)thisTargetPosition; targetPosition = (Vector3)thisTargetPosition;
Debug.Log("Target Position != null" + targetPosition);
} }
if (targetTypeInt == (int)SceneBlockContainer.Targets.Free || targetTypeInt == (int)SceneBlockContainer.Targets.Stay) if (targetTypeInt == (int)SceneBlockContainer.Targets.Free || targetTypeInt == (int)SceneBlockContainer.Targets.Stay)
{ {
Debug.Log("UpdateTargetStates Target Position: set all zeros ");
for (int i = 1; i < targetState.Length; i++) for (int i = 1; i < targetState.Length; i++)
// set target position state to 0
targetState[i] = 0f; targetState[i] = 0f;
} }
else else
{ {
Debug.Log("Target Position == null" + targetPosition);
targetState[1] = targetPosition.x; targetState[1] = targetPosition.x;
targetState[2] = targetPosition.y; targetState[2] = targetPosition.y;
targetState[3] = targetPosition.z; targetState[3] = targetPosition.z;

View File

@ -12,10 +12,10 @@ EditorUserSettings:
value: 5453565f53020f085f5d0e72157a0844454f4c2b757d7265757a4f64b7b4313c value: 5453565f53020f085f5d0e72157a0844454f4c2b757d7265757a4f64b7b4313c
flags: 0 flags: 0
RecentlyUsedSceneGuid-2: RecentlyUsedSceneGuid-2:
value: 06570c0704040b0e5a575520137b5e44154f192e292d22367c2c4866b7b3376f value: 5703025650035e5d090f087148715d4443161e2c7e2c20357b281b31b0e43060
flags: 0 flags: 0
RecentlyUsedSceneGuid-3: RecentlyUsedSceneGuid-3:
value: 5703025650035e5d090f087148715d4443161e2c7e2c20357b281b31b0e43060 value: 06570c0704040b0e5a575520137b5e44154f192e292d22367c2c4866b7b3376f
flags: 0 flags: 0
RecentlyUsedScenePath-0: RecentlyUsedScenePath-0:
value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d

View File

@ -15,9 +15,9 @@ MonoBehaviour:
m_PixelRect: m_PixelRect:
serializedVersion: 2 serializedVersion: 2
x: -1073 x: -1073
y: 58 y: 64
width: 1080 width: 1080
height: 693 height: 687
m_ShowMode: 0 m_ShowMode: 0
m_Title: Scene m_Title: Scene
m_RootView: {fileID: 4} m_RootView: {fileID: 4}
@ -43,7 +43,7 @@ MonoBehaviour:
width: 1858 width: 1858
height: 1037 height: 1037
m_ShowMode: 4 m_ShowMode: 4
m_Title: Console m_Title: Hierarchy
m_RootView: {fileID: 12} m_RootView: {fileID: 12}
m_MinSize: {x: 875, y: 300} m_MinSize: {x: 875, y: 300}
m_MaxSize: {x: 10000, y: 10000} m_MaxSize: {x: 10000, y: 10000}
@ -66,9 +66,9 @@ MonoBehaviour:
x: 0 x: 0
y: 0 y: 0
width: 1080 width: 1080
height: 693 height: 687
m_MinSize: {x: 200, y: 221} m_MinSize: {x: 200, y: 200}
m_MaxSize: {x: 4000, y: 4021} m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {fileID: 21} m_ActualView: {fileID: 21}
m_Panes: m_Panes:
- {fileID: 21} - {fileID: 21}
@ -93,11 +93,11 @@ MonoBehaviour:
x: 0 x: 0
y: 0 y: 0
width: 1080 width: 1080
height: 693 height: 687
m_MinSize: {x: 200, y: 221} m_MinSize: {x: 200, y: 221}
m_MaxSize: {x: 4000, y: 4021} m_MaxSize: {x: 4000, y: 4021}
vertical: 0 vertical: 0
controlID: 105 controlID: 20
--- !u!114 &5 --- !u!114 &5
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 52 m_ObjectHideFlags: 52
@ -149,7 +149,7 @@ MonoBehaviour:
m_MinSize: {x: 100, y: 200} m_MinSize: {x: 100, y: 200}
m_MaxSize: {x: 8096, y: 16192} m_MaxSize: {x: 8096, y: 16192}
vertical: 1 vertical: 1
controlID: 119 controlID: 149
--- !u!114 &7 --- !u!114 &7
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 52 m_ObjectHideFlags: 52
@ -169,8 +169,8 @@ MonoBehaviour:
y: 470 y: 470
width: 316 width: 316
height: 517 height: 517
m_MinSize: {x: 102, y: 121} m_MinSize: {x: 100, y: 100}
m_MaxSize: {x: 4002, y: 4021} m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {fileID: 22} m_ActualView: {fileID: 22}
m_Panes: m_Panes:
- {fileID: 22} - {fileID: 22}
@ -200,7 +200,7 @@ MonoBehaviour:
m_MinSize: {x: 100, y: 200} m_MinSize: {x: 100, y: 200}
m_MaxSize: {x: 8096, y: 16192} m_MaxSize: {x: 8096, y: 16192}
vertical: 1 vertical: 1
controlID: 52 controlID: 119
--- !u!114 &9 --- !u!114 &9
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 52 m_ObjectHideFlags: 52
@ -220,8 +220,8 @@ MonoBehaviour:
y: 0 y: 0
width: 316 width: 316
height: 470 height: 470
m_MinSize: {x: 202, y: 221} m_MinSize: {x: 200, y: 200}
m_MaxSize: {x: 4002, y: 4021} m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {fileID: 20} m_ActualView: {fileID: 20}
m_Panes: m_Panes:
- {fileID: 20} - {fileID: 20}
@ -252,7 +252,7 @@ MonoBehaviour:
m_MinSize: {x: 300, y: 200} m_MinSize: {x: 300, y: 200}
m_MaxSize: {x: 24288, y: 16192} m_MaxSize: {x: 24288, y: 16192}
vertical: 0 vertical: 0
controlID: 118 controlID: 113
--- !u!114 &11 --- !u!114 &11
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 52 m_ObjectHideFlags: 52
@ -272,8 +272,8 @@ MonoBehaviour:
y: 0 y: 0
width: 460 width: 460
height: 987 height: 987
m_MinSize: {x: 276, y: 71} m_MinSize: {x: 275, y: 50}
m_MaxSize: {x: 4001, y: 4021} m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {fileID: 19} m_ActualView: {fileID: 19}
m_Panes: m_Panes:
- {fileID: 19} - {fileID: 19}
@ -369,8 +369,8 @@ MonoBehaviour:
y: 0 y: 0
width: 1082 width: 1082
height: 717 height: 717
m_MinSize: {x: 101, y: 121} m_MinSize: {x: 100, y: 100}
m_MaxSize: {x: 4001, y: 4021} m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {fileID: 16} m_ActualView: {fileID: 16}
m_Panes: m_Panes:
- {fileID: 16} - {fileID: 16}
@ -550,9 +550,9 @@ MonoBehaviour:
m_IsLocked: 0 m_IsLocked: 0
m_FolderTreeState: m_FolderTreeState:
scrollPos: {x: 0, y: 155} scrollPos: {x: 0, y: 155}
m_SelectedIDs: 46670000 m_SelectedIDs: b6760000
m_LastClickedID: 26438 m_LastClickedID: 30390
m_ExpandedIDs: 0000000000670000026700000467000006670000086700004067000000ca9a3b m_ExpandedIDs: 000000007476000076760000787600007a7600007c760000b076000000ca9a3b
m_RenameOverlay: m_RenameOverlay:
m_UserAcceptedRename: 0 m_UserAcceptedRename: 0
m_Name: m_Name:
@ -580,7 +580,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0} scrollPos: {x: 0, y: 0}
m_SelectedIDs: m_SelectedIDs:
m_LastClickedID: 0 m_LastClickedID: 0
m_ExpandedIDs: 000000000067000002670000046700000667000008670000 m_ExpandedIDs: 000000007476000076760000787600007a7600007c760000
m_RenameOverlay: m_RenameOverlay:
m_UserAcceptedRename: 0 m_UserAcceptedRename: 0
m_Name: m_Name:
@ -605,9 +605,9 @@ MonoBehaviour:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_ResourceFile: m_ResourceFile:
m_ListAreaState: m_ListAreaState:
m_SelectedInstanceIDs: c25a0000 m_SelectedInstanceIDs:
m_LastClickedInstanceID: 23234 m_LastClickedInstanceID: 0
m_HadKeyboardFocusLastEvent: 1 m_HadKeyboardFocusLastEvent: 0
m_ExpandedInstanceIDs: c62300008a5c000000000000 m_ExpandedInstanceIDs: c62300008a5c000000000000
m_RenameOverlay: m_RenameOverlay:
m_UserAcceptedRename: 0 m_UserAcceptedRename: 0
@ -670,8 +670,8 @@ MonoBehaviour:
m_CachedPref: 160 m_CachedPref: 160
m_ControlHash: -371814159 m_ControlHash: -371814159
m_PrefName: Preview_InspectorPreview m_PrefName: Preview_InspectorPreview
m_LastInspectedObjectInstanceID: 23234 m_LastInspectedObjectInstanceID: -1
m_LastVerticalScrollValue: 667 m_LastVerticalScrollValue: 0
m_GlobalObjectId: m_GlobalObjectId:
m_InspectorMode: 0 m_InspectorMode: 0
m_LockTracker: m_LockTracker:
@ -708,9 +708,9 @@ MonoBehaviour:
m_SceneHierarchy: m_SceneHierarchy:
m_TreeViewState: m_TreeViewState:
scrollPos: {x: 0, y: 0} scrollPos: {x: 0, y: 0}
m_SelectedIDs: c25a0000 m_SelectedIDs:
m_LastClickedID: 23234 m_LastClickedID: 0
m_ExpandedIDs: 32fbffff2a5b0000 m_ExpandedIDs: d8baffff30bbffff94bcffffe6bcffff04bdffff30fbffff
m_RenameOverlay: m_RenameOverlay:
m_UserAcceptedRename: 0 m_UserAcceptedRename: 0
m_Name: m_Name:
@ -755,9 +755,9 @@ MonoBehaviour:
m_Pos: m_Pos:
serializedVersion: 2 serializedVersion: 2
x: -1073 x: -1073
y: 58 y: 64
width: 1080 width: 1080
height: 672 height: 666
m_ViewDataDictionary: {fileID: 0} m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas: m_OverlayCanvas:
m_LastAppliedPresetName: Default m_LastAppliedPresetName: Default
@ -992,9 +992,9 @@ MonoBehaviour:
m_PlayAudio: 0 m_PlayAudio: 0
m_AudioPlay: 0 m_AudioPlay: 0
m_Position: m_Position:
m_Target: {x: 32.245174, y: 39.198368, z: 44.195084} m_Target: {x: -3.954848, y: -124.757774, z: -32.582333}
speed: 2 speed: 2
m_Value: {x: 32.245174, y: 39.198368, z: 44.195084} m_Value: {x: -3.954848, y: -124.757774, z: -32.582333}
m_RenderMode: 0 m_RenderMode: 0
m_CameraMode: m_CameraMode:
drawMode: 0 drawMode: 0
@ -1041,13 +1041,13 @@ MonoBehaviour:
m_GridAxis: 1 m_GridAxis: 1
m_gridOpacity: 0.5 m_gridOpacity: 0.5
m_Rotation: m_Rotation:
m_Target: {x: 0.6133127, y: 0.005624831, z: -0.004448684, w: 0.78973943} m_Target: {x: 0.5022141, y: -0.11378048, z: 0.06679058, w: 0.85455513}
speed: 2 speed: 2
m_Value: {x: 0.61334574, y: 0.0056251343, z: -0.0044489237, w: 0.789782} m_Value: {x: 0.5022416, y: -0.11378672, z: 0.06679424, w: 0.8546019}
m_Size: m_Size:
m_Target: 1.4054321 m_Target: 79.56483
speed: 2 speed: 2
m_Value: 1.4054321 m_Value: 79.56483
m_Ortho: m_Ortho:
m_Target: 0 m_Target: 0
speed: 2 speed: 2