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

修正TrainMode中Target不更新问题
This commit is contained in:
2023-07-29 04:04:18 +09:00
parent 630cbc4f70
commit df1958c48e
8 changed files with 60 additions and 45 deletions
+1 -1
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"}}
+2
View File
@@ -16,6 +16,7 @@ public class EnemyContainer : MonoBehaviour
// 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 class EnemyContainer : MonoBehaviour
// 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++)
@@ -60,10 +60,12 @@ public class MLAgentsCustomController : Agent
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
@@ -147,6 +147,7 @@ public class ParameterContainer : MonoBehaviour
targetTimeBonus = targetTimeBonusPerSec * timeLimit;
try
{
// try get start scene data
startSceneData = GameObject.Find("StartSceneDataTransfer").GetComponent<StartSeneData>();
gameMode = startSceneData.gameMode;
attackProb = startSceneData.attackProb;
@@ -157,6 +158,9 @@ public class ParameterContainer : MonoBehaviour
{
Debug.LogError("PrameterContainer:Run WithOut StartScreen!");
gameMode = 0;
attackProb = 0.3333f;
gotoProb = 0.3333f;
defenceProb = 0.0f;
}
}
+2 -2
View File
@@ -100,13 +100,13 @@ public class SceneBlock : MonoBehaviour
// 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;
+8 -1
View File
@@ -142,6 +142,7 @@ public class TargetController : MonoBehaviour
{
// 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 class TargetController : MonoBehaviour
{
// attack target spawn
Debug.Log("ATTACK!");
targetTypeInt = (int)SceneBlockContainer.Targets.Attack;
RandomSpawnSceneBlock(SceneBlockContainer.Targets.Attack);
// set startDistance
firstRewardFlag = true;
@@ -159,13 +161,14 @@ public class TargetController : MonoBehaviour
{
// 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 @@ public class TargetController : MonoBehaviour
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;