V3.3.5 LevelProbabilityPanel逻辑完成

This commit is contained in:
Koha9 2023-10-05 23:49:34 +09:00
parent 19761315f2
commit 0b23c91832
3 changed files with 26 additions and 8 deletions

View File

@ -1 +1 @@
{"count":1,"self":8.25924,"total":8.3077335,"children":{"InitializeActuators":{"count":2,"self":0.0010007,"total":0.0010007,"children":null},"InitializeSensors":{"count":2,"self":0.001501,"total":0.001501,"children":null},"AgentSendState":{"count":151,"self":0.0014988999999999998,"total":0.0125058,"children":{"CollectObservations":{"count":151,"self":0.0090066,"total":0.0090066,"children":null},"WriteActionMask":{"count":151,"self":0.0005009,"total":0.0005009,"children":null},"RequestDecision":{"count":151,"self":0.0014994,"total":0.0014994,"children":null}}},"DecideAction":{"count":151,"self":0.0010014,"total":0.0010014,"children":null},"AgentAct":{"count":151,"self":0.032485,"total":0.032485,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1696510666","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-q2quha7JFq52w-SUtj3vv -hubSessionId 61f6b54c-8d4c-45ec-a505-47188486c77c -accessToken MD8iouPZlC7chsDZh-2OfbaNG8DDnFy36WE1syqyLNg00ef","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"StartScene","end_time_seconds":"1696510675"}}
{"count":1,"self":7.6867775999999992,"total":7.7230661,"children":{"InitializeActuators":{"count":2,"self":0.0010014,"total":0.0010014,"children":null},"InitializeSensors":{"count":2,"self":0.0009991,"total":0.0009991,"children":null},"AgentSendState":{"count":133,"self":0.0034961999999999997,"total":0.0112705,"children":{"CollectObservations":{"count":133,"self":0.0063840999999999993,"total":0.0063840999999999993,"children":null},"WriteActionMask":{"count":133,"self":0,"total":0,"children":null},"RequestDecision":{"count":133,"self":0.0013901999999999999,"total":0.0013901999999999999,"children":null}}},"DecideAction":{"count":133,"self":0.0010008,"total":0.0010008,"children":null},"AgentAct":{"count":133,"self":0.022017099999999998,"total":0.022017099999999998,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1696516721","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-q2quha7JFq52w-SUtj3vv -hubSessionId 61f6b54c-8d4c-45ec-a505-47188486c77c -accessToken QYTEq0ishS-kLjhfwMeB2jbrH3uriRLQpQBsjnaTMm000ef","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"StartScene","end_time_seconds":"1696516728"}}

View File

@ -1 +1 @@
{"count":1,"self":7.384512,"total":7.4340082,"children":{"InitializeActuators":{"count":2,"self":0.0010007,"total":0.0010007,"children":null},"InitializeSensors":{"count":2,"self":0.001501,"total":0.001501,"children":null},"AgentSendState":{"count":151,"self":0.0014988999999999998,"total":0.0125058,"children":{"CollectObservations":{"count":151,"self":0.0090066,"total":0.0090066,"children":null},"WriteActionMask":{"count":151,"self":0.0005009,"total":0.0005009,"children":null},"RequestDecision":{"count":151,"self":0.0014994,"total":0.0014994,"children":null}}},"DecideAction":{"count":151,"self":0.0010014,"total":0.0010014,"children":null},"AgentAct":{"count":151,"self":0.032485,"total":0.032485,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1696510666","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-q2quha7JFq52w-SUtj3vv -hubSessionId 61f6b54c-8d4c-45ec-a505-47188486c77c -accessToken MD8iouPZlC7chsDZh-2OfbaNG8DDnFy36WE1syqyLNg00ef","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"Train","end_time_seconds":"1696510674"}}
{"count":1,"self":6.9184632,"total":6.9552502,"children":{"InitializeActuators":{"count":2,"self":0.0010014,"total":0.0010014,"children":null},"InitializeSensors":{"count":2,"self":0.0009991,"total":0.0009991,"children":null},"AgentSendState":{"count":133,"self":0.0034961999999999997,"total":0.0112705,"children":{"CollectObservations":{"count":133,"self":0.0063840999999999993,"total":0.0063840999999999993,"children":null},"WriteActionMask":{"count":133,"self":0,"total":0,"children":null},"RequestDecision":{"count":133,"self":0.0013901999999999999,"total":0.0013901999999999999,"children":null}}},"DecideAction":{"count":133,"self":0.0010008,"total":0.0010008,"children":null},"AgentAct":{"count":133,"self":0.022017099999999998,"total":0.022017099999999998,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1696516721","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-q2quha7JFq52w-SUtj3vv -hubSessionId 61f6b54c-8d4c-45ec-a505-47188486c77c -accessToken QYTEq0ishS-kLjhfwMeB2jbrH3uriRLQpQBsjnaTMm000ef","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"Train","end_time_seconds":"1696516727"}}

View File

@ -60,10 +60,14 @@ private void AddEventTrigger(GameObject gameObject, EventTriggerType triggerType
eventTrigger.triggers.Add(entry);
}
/// <summary>
/// On Probability Slider Value Change.Adjust other sliders' value to make sure the total value is 1.
/// </summary>
/// <param name="value">change to this value</param>
/// <param name="exceptedIndex">changed panel index</param>
private void OnSliderValueChange(float value, int exceptedIndex)
{
float newTotalValue = 0;
float averageCorrectionValue = 0;
int unlockedPanelNum = 0;
int remainCorrectionNum = panelNum;
float extraValue = 0;
@ -97,9 +101,8 @@ private void OnSliderValueChange(float value, int exceptedIndex)
}
// Calculate the average correction value
extraValue = newTotalValue - 1;
averageCorrectionValue = extraValue / (unlockedPanelNum - 1);
// initialize correction value to each panel
correctionValues = Enumerable.Repeat(averageCorrectionValue, panelNum).ToArray();
correctionValues = Enumerable.Repeat(extraValue / (unlockedPanelNum - 1), panelNum).ToArray();
// make sure all probability value is not less than 0 and equal to 1
int iterationCount = 0;
while (remainCorrectionNum > 0)
@ -119,6 +122,9 @@ private void OnSliderValueChange(float value, int exceptedIndex)
enableSliderListener();
}
/// <summary>
/// enable all sliders' onValueChanged action listener
/// </summary>
private void enableSliderListener()
{
for (int i = 0; i < panelNum; i++)
@ -128,6 +134,9 @@ private void enableSliderListener()
}
}
/// <summary>
/// calculate the correction value to each panel,while the total value is not equal to 1
/// </summary>
private (float[], int) reCalculateCorrectionValues(float[] correctionValues, int exceptedIndex, float value, float extraValue)
{
int remainCorrectionNum = 0;
@ -142,8 +151,14 @@ private void enableSliderListener()
correctionValues[i] = singleLevelPanels[i].ProbabilityValue - value;
continue;
}
// if the panel is locked or the probability value is 0 or the probability value is equal to the correction value
if (singleLevelPanels[i].IsLocked || singleLevelPanels[i].ProbabilityValue <= 0)
// if the panel is locked
if (singleLevelPanels[i].IsLocked)
{
correctionValues[i] = 0;
continue;
}
//if the probability value is 0 or the probability value is equal to the correction value
if (singleLevelPanels[i].ProbabilityValue < 0 || singleLevelPanels[i].ProbabilityValue > 1)
{
correctionValues[i] = 0;
}
@ -151,7 +166,7 @@ private void enableSliderListener()
{
underZeroExtraValueAfterCorrected += correctionValues[i];
}
else if (singleLevelPanels[i].ProbabilityValue - correctionValues[i] < 0)
else if (singleLevelPanels[i].ProbabilityValue - correctionValues[i] < 0 || singleLevelPanels[i].ProbabilityValue - correctionValues[i] > 1)
{
underZeroExtraValueAfterCorrected += correctionValues[i];
correctionValues[i] = singleLevelPanels[i].ProbabilityValue;
@ -188,6 +203,9 @@ private void enableSliderListener()
return (correctionValues, remainCorrectionNum);
}
/// <summary>
/// applicate correction value to each panel
/// </summary>
private void applyCorrectionValue(float[] correctionValues)
{
for (int i = 0; i < panelNum; i++)