From df1958c48e75ee59d23e1d4317044f61725e21d4 Mon Sep 17 00:00:00 2001 From: Koha9 Date: Sat, 29 Jul 2023 04:04:18 +0900 Subject: [PATCH] =?UTF-8?q?V3.1.6=20=E4=BF=AE=E6=AD=A3TrainMode=E4=B8=ADTa?= =?UTF-8?q?rget=E4=B8=8D=E6=9B=B4=E6=96=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修正TrainMode中Target不更新问题 --- Assets/ML-Agents/Timers/Train_timers.json | 2 +- Assets/Script/InGame/EnemyContainer.cs | 2 + .../Script/InGame/MLAgentsCustomController.cs | 2 + Assets/Script/InGame/ParameterContainer.cs | 4 + Assets/Script/InGame/SceneBlock.cs | 4 +- Assets/Script/InGame/TargetController.cs | 9 ++- UserSettings/EditorUserSettings.asset | 4 +- UserSettings/Layouts/default-2021.dwlt | 78 +++++++++---------- 8 files changed, 60 insertions(+), 45 deletions(-) diff --git a/Assets/ML-Agents/Timers/Train_timers.json b/Assets/ML-Agents/Timers/Train_timers.json index ff1a2af..93ca976 100644 --- a/Assets/ML-Agents/Timers/Train_timers.json +++ b/Assets/ML-Agents/Timers/Train_timers.json @@ -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"}} \ No newline at end of file +{"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"}} \ No newline at end of file diff --git a/Assets/Script/InGame/EnemyContainer.cs b/Assets/Script/InGame/EnemyContainer.cs index 7e0ba66..e5842f5 100644 --- a/Assets/Script/InGame/EnemyContainer.cs +++ b/Assets/Script/InGame/EnemyContainer.cs @@ -16,6 +16,7 @@ private void Start() // initialize enemy by random public void RandomInitEnemys(int EnemyNum) { + Debug.Log("RandomInitEnemys"); for (int i = 0; i < EnemyNum; i++) { 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 public void RandomInitEnemysExcept(int enemyNum, Vector3 blockPosition, float sceneSize) { + Debug.Log("RandomInitEnemysExcept"); float randX = 0f; float randZ = 0f; for (int i = 0; i < enemyNum; i++) diff --git a/Assets/Script/InGame/MLAgentsCustomController.cs b/Assets/Script/InGame/MLAgentsCustomController.cs index b92b319..e9b503b 100644 --- a/Assets/Script/InGame/MLAgentsCustomController.cs +++ b/Assets/Script/InGame/MLAgentsCustomController.cs @@ -60,10 +60,12 @@ public override void OnEpisodeBegin() if (paramContainer.gameMode == 0) { // train mode + Debug.Log("MLAgentCustomController.OnEpisodeBegin: train mode start"); targetController.RollNewScene(); } else { + Debug.Log("MLAgentCustomController.OnEpisodeBegin: play mode start"); // play mode targetController.PlayInitialize(); // reset target UI diff --git a/Assets/Script/InGame/ParameterContainer.cs b/Assets/Script/InGame/ParameterContainer.cs index fb13bff..d836cc4 100644 --- a/Assets/Script/InGame/ParameterContainer.cs +++ b/Assets/Script/InGame/ParameterContainer.cs @@ -147,6 +147,7 @@ private void Start() targetTimeBonus = targetTimeBonusPerSec * timeLimit; try { + // try get start scene data startSceneData = GameObject.Find("StartSceneDataTransfer").GetComponent(); gameMode = startSceneData.gameMode; attackProb = startSceneData.attackProb; @@ -157,6 +158,9 @@ private void Start() { Debug.LogError("PrameterContainer:Run WithOut StartScreen!"); gameMode = 0; + attackProb = 0.3333f; + gotoProb = 0.3333f; + defenceProb = 0.0f; } } diff --git a/Assets/Script/InGame/SceneBlock.cs b/Assets/Script/InGame/SceneBlock.cs index b34d523..f6d46ce 100644 --- a/Assets/Script/InGame/SceneBlock.cs +++ b/Assets/Script/InGame/SceneBlock.cs @@ -100,13 +100,13 @@ public void InitBlock(GameObject envObj) // if firebasesAreaObj is null, find sub object by name 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; } // if enemyContainerObj is null, find them by name 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; } firebasesAreaPosition = transform.position + fireBasesAreaObj.transform.position; diff --git a/Assets/Script/InGame/TargetController.cs b/Assets/Script/InGame/TargetController.cs index 6ce22c5..8d81177 100644 --- a/Assets/Script/InGame/TargetController.cs +++ b/Assets/Script/InGame/TargetController.cs @@ -142,6 +142,7 @@ public void RollNewScene() { // goto target spawn Debug.Log("GOTO THIS TARGET!"); + targetTypeInt = (int)SceneBlockContainer.Targets.Go; RandomSpawnSceneBlock(SceneBlockContainer.Targets.Go); // set startDistance firstRewardFlag = true; @@ -150,6 +151,7 @@ public void RollNewScene() { // attack target spawn Debug.Log("ATTACK!"); + targetTypeInt = (int)SceneBlockContainer.Targets.Attack; RandomSpawnSceneBlock(SceneBlockContainer.Targets.Attack); // set startDistance firstRewardFlag = true; @@ -159,13 +161,14 @@ public void RollNewScene() { // defence target spawn Debug.Log("DEFENCE!"); + targetTypeInt = (int)SceneBlockContainer.Targets.Defence; RandomSpawnSceneBlock(SceneBlockContainer.Targets.Defence); // set startDistance firstRewardFlag = true; } else { - //Debug.Log("Free"); + Debug.Log("Free"); targetTypeInt = (int)SceneBlockContainer.Targets.Free; enemyCon.DestroyAllEnemys(); enemyCon.RandomInitEnemys(hudCon.enemyNum); @@ -184,14 +187,18 @@ private void UpdateTargetStates(Vector3? thisTargetPosition = null) if (thisTargetPosition != null) { targetPosition = (Vector3)thisTargetPosition; + Debug.Log("Target Position != null" + targetPosition); } 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++) + // set target position state to 0 targetState[i] = 0f; } else { + Debug.Log("Target Position == null" + targetPosition); targetState[1] = targetPosition.x; targetState[2] = targetPosition.y; targetState[3] = targetPosition.z; diff --git a/UserSettings/EditorUserSettings.asset b/UserSettings/EditorUserSettings.asset index 314dff3..76a94ac 100644 --- a/UserSettings/EditorUserSettings.asset +++ b/UserSettings/EditorUserSettings.asset @@ -12,10 +12,10 @@ EditorUserSettings: value: 5453565f53020f085f5d0e72157a0844454f4c2b757d7265757a4f64b7b4313c flags: 0 RecentlyUsedSceneGuid-2: - value: 06570c0704040b0e5a575520137b5e44154f192e292d22367c2c4866b7b3376f + value: 5703025650035e5d090f087148715d4443161e2c7e2c20357b281b31b0e43060 flags: 0 RecentlyUsedSceneGuid-3: - value: 5703025650035e5d090f087148715d4443161e2c7e2c20357b281b31b0e43060 + value: 06570c0704040b0e5a575520137b5e44154f192e292d22367c2c4866b7b3376f flags: 0 RecentlyUsedScenePath-0: value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d diff --git a/UserSettings/Layouts/default-2021.dwlt b/UserSettings/Layouts/default-2021.dwlt index 32b9e86..74f427d 100644 --- a/UserSettings/Layouts/default-2021.dwlt +++ b/UserSettings/Layouts/default-2021.dwlt @@ -15,9 +15,9 @@ MonoBehaviour: m_PixelRect: serializedVersion: 2 x: -1073 - y: 58 + y: 64 width: 1080 - height: 693 + height: 687 m_ShowMode: 0 m_Title: Scene m_RootView: {fileID: 4} @@ -43,7 +43,7 @@ MonoBehaviour: width: 1858 height: 1037 m_ShowMode: 4 - m_Title: Console + m_Title: Hierarchy m_RootView: {fileID: 12} m_MinSize: {x: 875, y: 300} m_MaxSize: {x: 10000, y: 10000} @@ -66,9 +66,9 @@ MonoBehaviour: x: 0 y: 0 width: 1080 - height: 693 - m_MinSize: {x: 200, y: 221} - m_MaxSize: {x: 4000, y: 4021} + height: 687 + m_MinSize: {x: 200, y: 200} + m_MaxSize: {x: 4000, y: 4000} m_ActualView: {fileID: 21} m_Panes: - {fileID: 21} @@ -93,11 +93,11 @@ MonoBehaviour: x: 0 y: 0 width: 1080 - height: 693 + height: 687 m_MinSize: {x: 200, y: 221} m_MaxSize: {x: 4000, y: 4021} vertical: 0 - controlID: 105 + controlID: 20 --- !u!114 &5 MonoBehaviour: m_ObjectHideFlags: 52 @@ -149,7 +149,7 @@ MonoBehaviour: m_MinSize: {x: 100, y: 200} m_MaxSize: {x: 8096, y: 16192} vertical: 1 - controlID: 119 + controlID: 149 --- !u!114 &7 MonoBehaviour: m_ObjectHideFlags: 52 @@ -169,8 +169,8 @@ MonoBehaviour: y: 470 width: 316 height: 517 - m_MinSize: {x: 102, y: 121} - m_MaxSize: {x: 4002, y: 4021} + m_MinSize: {x: 100, y: 100} + m_MaxSize: {x: 4000, y: 4000} m_ActualView: {fileID: 22} m_Panes: - {fileID: 22} @@ -200,7 +200,7 @@ MonoBehaviour: m_MinSize: {x: 100, y: 200} m_MaxSize: {x: 8096, y: 16192} vertical: 1 - controlID: 52 + controlID: 119 --- !u!114 &9 MonoBehaviour: m_ObjectHideFlags: 52 @@ -220,8 +220,8 @@ MonoBehaviour: y: 0 width: 316 height: 470 - m_MinSize: {x: 202, y: 221} - m_MaxSize: {x: 4002, y: 4021} + m_MinSize: {x: 200, y: 200} + m_MaxSize: {x: 4000, y: 4000} m_ActualView: {fileID: 20} m_Panes: - {fileID: 20} @@ -252,7 +252,7 @@ MonoBehaviour: m_MinSize: {x: 300, y: 200} m_MaxSize: {x: 24288, y: 16192} vertical: 0 - controlID: 118 + controlID: 113 --- !u!114 &11 MonoBehaviour: m_ObjectHideFlags: 52 @@ -272,8 +272,8 @@ MonoBehaviour: y: 0 width: 460 height: 987 - m_MinSize: {x: 276, y: 71} - m_MaxSize: {x: 4001, y: 4021} + m_MinSize: {x: 275, y: 50} + m_MaxSize: {x: 4000, y: 4000} m_ActualView: {fileID: 19} m_Panes: - {fileID: 19} @@ -369,8 +369,8 @@ MonoBehaviour: y: 0 width: 1082 height: 717 - m_MinSize: {x: 101, y: 121} - m_MaxSize: {x: 4001, y: 4021} + m_MinSize: {x: 100, y: 100} + m_MaxSize: {x: 4000, y: 4000} m_ActualView: {fileID: 16} m_Panes: - {fileID: 16} @@ -550,9 +550,9 @@ MonoBehaviour: m_IsLocked: 0 m_FolderTreeState: scrollPos: {x: 0, y: 155} - m_SelectedIDs: 46670000 - m_LastClickedID: 26438 - m_ExpandedIDs: 0000000000670000026700000467000006670000086700004067000000ca9a3b + m_SelectedIDs: b6760000 + m_LastClickedID: 30390 + m_ExpandedIDs: 000000007476000076760000787600007a7600007c760000b076000000ca9a3b m_RenameOverlay: m_UserAcceptedRename: 0 m_Name: @@ -580,7 +580,7 @@ MonoBehaviour: scrollPos: {x: 0, y: 0} m_SelectedIDs: m_LastClickedID: 0 - m_ExpandedIDs: 000000000067000002670000046700000667000008670000 + m_ExpandedIDs: 000000007476000076760000787600007a7600007c760000 m_RenameOverlay: m_UserAcceptedRename: 0 m_Name: @@ -605,9 +605,9 @@ MonoBehaviour: m_Icon: {fileID: 0} m_ResourceFile: m_ListAreaState: - m_SelectedInstanceIDs: c25a0000 - m_LastClickedInstanceID: 23234 - m_HadKeyboardFocusLastEvent: 1 + m_SelectedInstanceIDs: + m_LastClickedInstanceID: 0 + m_HadKeyboardFocusLastEvent: 0 m_ExpandedInstanceIDs: c62300008a5c000000000000 m_RenameOverlay: m_UserAcceptedRename: 0 @@ -670,8 +670,8 @@ MonoBehaviour: m_CachedPref: 160 m_ControlHash: -371814159 m_PrefName: Preview_InspectorPreview - m_LastInspectedObjectInstanceID: 23234 - m_LastVerticalScrollValue: 667 + m_LastInspectedObjectInstanceID: -1 + m_LastVerticalScrollValue: 0 m_GlobalObjectId: m_InspectorMode: 0 m_LockTracker: @@ -708,9 +708,9 @@ MonoBehaviour: m_SceneHierarchy: m_TreeViewState: scrollPos: {x: 0, y: 0} - m_SelectedIDs: c25a0000 - m_LastClickedID: 23234 - m_ExpandedIDs: 32fbffff2a5b0000 + m_SelectedIDs: + m_LastClickedID: 0 + m_ExpandedIDs: d8baffff30bbffff94bcffffe6bcffff04bdffff30fbffff m_RenameOverlay: m_UserAcceptedRename: 0 m_Name: @@ -755,9 +755,9 @@ MonoBehaviour: m_Pos: serializedVersion: 2 x: -1073 - y: 58 + y: 64 width: 1080 - height: 672 + height: 666 m_ViewDataDictionary: {fileID: 0} m_OverlayCanvas: m_LastAppliedPresetName: Default @@ -992,9 +992,9 @@ MonoBehaviour: m_PlayAudio: 0 m_AudioPlay: 0 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 - 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_CameraMode: drawMode: 0 @@ -1041,13 +1041,13 @@ MonoBehaviour: m_GridAxis: 1 m_gridOpacity: 0.5 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 - 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_Target: 1.4054321 + m_Target: 79.56483 speed: 2 - m_Value: 1.4054321 + m_Value: 79.56483 m_Ortho: m_Target: 0 speed: 2