diff --git a/Assets/ML-Agents/Timers/Play_timers.json b/Assets/ML-Agents/Timers/Play_timers.json
index 6fa5c34..4f82d65 100644
--- a/Assets/ML-Agents/Timers/Play_timers.json
+++ b/Assets/ML-Agents/Timers/Play_timers.json
@@ -1 +1 @@
-{"count":1,"self":14.61136,"total":14.758261,"children":{"InitializeActuators":{"count":2,"self":0.0009999,"total":0.0009999,"children":null},"InitializeSensors":{"count":2,"self":0.00099969999999999985,"total":0.00099969999999999985,"children":null},"AgentSendState":{"count":484,"self":0.0034990999999999998,"total":0.0180021,"children":{"CollectObservations":{"count":484,"self":0.0119995,"total":0.0119995,"children":null},"WriteActionMask":{"count":484,"self":0,"total":0,"children":null},"RequestDecision":{"count":484,"self":0.0025035,"total":0.0025035,"children":null}}},"DecideAction":{"count":484,"self":0.0029993,"total":0.0029993,"children":null},"AgentAct":{"count":484,"self":0.1239006,"total":0.1239006,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1698085512","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-3RTM9hQ6yJRZGQKZx8Slg -hubSessionId a9694f1b-42f4-414c-9f3a-decdfec467f4 -accessToken 0RXRt4Gr5-wz9bb63SDgNZNzv9nApR3GYqka0HInnGM00ef","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"Play","end_time_seconds":"1698085527"}}
\ No newline at end of file
+{"count":1,"self":8.5270087999999991,"total":8.5798268,"children":{"InitializeActuators":{"count":2,"self":0.0009999,"total":0.0009999,"children":null},"InitializeSensors":{"count":2,"self":0.0015000999999999999,"total":0.0015000999999999999,"children":null},"AgentSendState":{"count":183,"self":0.0020001,"total":0.0074968,"children":{"CollectObservations":{"count":183,"self":0.0034971,"total":0.0034971,"children":null},"WriteActionMask":{"count":183,"self":0.001,"total":0.001,"children":null},"RequestDecision":{"count":183,"self":0.0009996,"total":0.0009996,"children":null}}},"DecideAction":{"count":183,"self":0.0030022,"total":0.0030022,"children":null},"AgentAct":{"count":183,"self":0.0393183,"total":0.0393183,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1698173938","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-3RTM9hQ6yJRZGQKZx8Slg -hubSessionId a9694f1b-42f4-414c-9f3a-decdfec467f4 -accessToken ILZ68Yi-AKrQdQecLlrJbt9jO5T6wytkNtTUsAQRokI00ef","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"Play","end_time_seconds":"1698173947"}}
\ No newline at end of file
diff --git a/Assets/ML-Agents/Timers/Train_timers.json b/Assets/ML-Agents/Timers/Train_timers.json
index 20cf9a1..ce0d0bb 100644
--- a/Assets/ML-Agents/Timers/Train_timers.json
+++ b/Assets/ML-Agents/Timers/Train_timers.json
@@ -1 +1 @@
-{"count":1,"self":14.1656544,"total":14.3145136,"children":{"InitializeActuators":{"count":2,"self":0.0015011999999999998,"total":0.0015011999999999998,"children":null},"InitializeSensors":{"count":2,"self":0.0009999,"total":0.0009999,"children":null},"AgentSendState":{"count":454,"self":0.003999,"total":0.027000399999999997,"children":{"CollectObservations":{"count":454,"self":0.0205008,"total":0.0205008,"children":null},"WriteActionMask":{"count":454,"self":0,"total":0,"children":null},"RequestDecision":{"count":454,"self":0.0025006,"total":0.0025006,"children":null}}},"DecideAction":{"count":454,"self":0.0068705,"total":0.0068705,"children":null},"AgentAct":{"count":454,"self":0.11198749999999999,"total":0.11198749999999999,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1698085370","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-3RTM9hQ6yJRZGQKZx8Slg -hubSessionId a9694f1b-42f4-414c-9f3a-decdfec467f4 -accessToken 0RXRt4Gr5-wz9bb63SDgNZNzv9nApR3GYqka0HInnGM00ef","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"Train","end_time_seconds":"1698085385"}}
\ No newline at end of file
+{"count":1,"self":9.229641599999999,"total":9.3225,"children":{"InitializeActuators":{"count":2,"self":0.0020006,"total":0.0020006,"children":null},"InitializeSensors":{"count":2,"self":0.0015000999999999999,"total":0.0015000999999999999,"children":null},"AgentSendState":{"count":181,"self":0.0019981,"total":0.0168523,"children":{"CollectObservations":{"count":181,"self":0.011856199999999999,"total":0.011856199999999999,"children":null},"WriteActionMask":{"count":181,"self":0.0004999,"total":0.0004999,"children":null},"RequestDecision":{"count":181,"self":0.0024981,"total":0.0024981,"children":null}}},"DecideAction":{"count":181,"self":0.0040031,"total":0.0040031,"children":null},"AgentAct":{"count":181,"self":0.0680028,"total":0.0680028,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1698171221","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-3RTM9hQ6yJRZGQKZx8Slg -hubSessionId a9694f1b-42f4-414c-9f3a-decdfec467f4 -accessToken ILZ68Yi-AKrQdQecLlrJbt9jO5T6wytkNtTUsAQRokI00ef","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"Train","end_time_seconds":"1698171230"}}
\ No newline at end of file
diff --git a/Assets/RewardFunction.cs b/Assets/RewardFunction.cs
index 3ae9775..6d11bf6 100644
--- a/Assets/RewardFunction.cs
+++ b/Assets/RewardFunction.cs
@@ -53,8 +53,8 @@ private void Start()
/// State of the shooting action.
/// Returns the calculated total reward value.
///
- /// This method calculates the total reward based on the provided parameters,
- /// taking into account rewards for enemy kills, shooting actions, facing reward,
+ /// This method calculates the total reward based on the provided parameters,
+ /// taking into account rewards for enemy kills, shooting actions, facing reward,
/// and penalties such as spin and movement.
///
public float RewardCalculate(float sceneReward, float mouseX, float movement, int shootState)
@@ -108,7 +108,7 @@ public float RewardCalculate(float sceneReward, float mouseX, float movement, in
/// State value of the shooting action.
/// Returns the reward value associated with shooting.
///
- /// This method calculates the reward value based on the shooting state and other related conditions,
+ /// This method calculates the reward value based on the shooting state and other related conditions,
/// such as whether the enemy was hit, whether the shot was towards the target area, and whether the gun was ready to shoot.
///
private float Ballistic(int shootState)
@@ -132,7 +132,7 @@ private float Ballistic(int shootState)
return HitEnemyReward(gotHitObj.transform.position);
}
}
- if (targetCon.targetTypeInt == (int)Targets.Attack)
+ if (targetCon.targetType == Targets.Attack)
{
// while if attack mode
float targetDis = Vector3.Distance(sceneBlockCon.nowBlock.transform.position, transform.position);
@@ -175,16 +175,133 @@ private float Ballistic(int shootState)
///
private float FacingReward()
{
- float nowReward = 0;
- bool isFacingtoEnemy = false;
- float enemyFacingDistance = 0f;
-
Vector3 screenCenter = new Vector3(fpsCam.pixelWidth / 2, fpsCam.pixelHeight / 2, 0);
Vector3 screenLeft = new Vector3(0, fpsCam.pixelHeight / 2, 0);
Ray centerRay = fpsCam.ScreenPointToRay(screenCenter);
Ray leftRay = fpsCam.ScreenPointToRay(screenLeft);
+ switch (targetCon.targetType)
+ {
+ case Targets.Free:
+ return FacingRewardFree(centerRay);
+
+ case Targets.Attack:
+ return FacingRewardAttack(centerRay, leftRay);
+
+ case Targets.Go:
+ return FacingRewardGo(centerRay, leftRay);
+
+ case Targets.Stay:
+ // stay mode has no facing reward
+ return 0f;
+
+ default:
+ Debug.LogError("Wrong target type");
+ return 0f;
+ }
+ }
+
+ private float FacingRewardFree(Ray centerRay)
+ {
+ float nowReward = 0;
+ float enemyFacingDistance = 0f;
+ bool isFacingtoEnemy = false;
+ RaycastHit hit;
+ if (Physics.Raycast(centerRay, out hit, 100))
+ {
+ // facing to an enemy
+ if (hit.collider.tag != agentCon.myTag && hit.collider.tag != "Wall")
+ {
+ nowReward = commonParamCon.facingReward;
+ isFacingtoEnemy = true;
+ }
+ }
+ if (raySensors.inViewEnemies.Count > 0 && !isFacingtoEnemy)
+ {
+ // have enemy in view
+ List projectionDis = new List();
+ foreach (GameObject theEnemy in raySensors.inViewEnemies)
+ {
+ // for each enemy in view
+ Vector3 projection = Vector3.Project(theEnemy.transform.position - transform.position, (centerRay.direction * 10));
+ Vector3 verticalToRay = transform.position + projection - theEnemy.transform.position;
+ projectionDis.Add(verticalToRay.magnitude);
+ // Debug.Log("enemy!" + verticalToRay.magnitude);
+ // Debug.DrawRay(transform.position, (centerRay.direction * 100), Color.cyan);
+ // Debug.DrawRay(transform.position, theEnemy.transform.position - transform.position, Color.yellow);
+ // Debug.DrawRay(transform.position, projection, Color.blue);
+ // Debug.DrawRay(theEnemy.transform.position, verticalToRay, Color.magenta);
+ }
+ enemyFacingDistance = projectionDis.Min();
+ if (enemyFacingDistance <= lastEnemyFacingDistance)
+ {
+ // closing to enemy
+ nowReward = 1 / MathF.Sqrt(commonParamCon.facingInviewEnemyDisCOEF * enemyFacingDistance + 0.00001f);
+ }
+ else
+ {
+ nowReward = 0;
+ }
+ // enemy in view Reward
+ lastEnemyFacingDistance = enemyFacingDistance;
+ if (nowReward >= commonParamCon.facingReward) nowReward = commonParamCon.facingReward; // limit
+ if (nowReward <= -commonParamCon.facingReward) nowReward = -commonParamCon.facingReward; // limit
+ // Debug.Log("ninimum = " + nowReward);
+ }
+ return nowReward;
+ }
+
+ private float FacingRewardGo(Ray centerRay, Ray leftRay)
+ {
+ float nowReward = 0;
+ float camCenterToFireBase;
+ float camCenterToViewEdge;
+ (camCenterToFireBase, camCenterToViewEdge, _) = CameraCenterToFireBaseAndViewEdge(centerRay, leftRay);
+
+ // goto mode
+ if (camCenterToFireBase <= camCenterToViewEdge)
+ {
+ // fireArea is in view
+ nowReward = commonParamCon.facingReward;
+ }
+ else
+ {
+ nowReward = 0;
+ }
+ return nowReward;
+ }
+
+ private float FacingRewardAttack(Ray centerRay, Ray leftRay)
+ {
+ float nowReward = 0;
+ float camCenterToFireBase;
+ float targetDis;
+ (camCenterToFireBase, _, targetDis) = CameraCenterToFireBaseAndViewEdge(centerRay, leftRay);
+ // attack mode
+ if (targetDis <= raySensors.viewDistance)
+ {
+ // Debug.DrawRay(new Vector3(0,0,0), viewPoint, Color.red);
+ // while center of screen between target's distance is lower than firebasesAreaDiameter
+ // while facing to target
+ if (camCenterToFireBase <= sceneBlockCon.nowBlock.firebasesAreaDiameter / 2)
+ {
+ // Debug.DrawRay(centerRay.origin, viewPoint-centerRay.origin, Color.blue);
+ nowReward = commonParamCon.facingReward;
+ }
+ else
+ {
+ // while not facing to target
+ nowReward = (lastTargetFacingDistance - camCenterToFireBase) * commonParamCon.facingTargetReward;
+ }
+ }
+ // update lastTargetFacingDistance
+ lastTargetFacingDistance = camCenterToFireBase;
+ return nowReward;
+ }
+
+ private (float, float, float) CameraCenterToFireBaseAndViewEdge(Ray centerRay, Ray leftRay)
+ {
// target fireBaseArea Position, turen y to camera's y
Vector3 fireBaseArea = sceneBlockCon.nowBlock.fireBasesAreaObj.transform.position;
fireBaseArea.y = fpsCam.transform.position.y;
@@ -204,100 +321,12 @@ private float FacingReward()
// center of screen to target's distance
// Debug.DrawLine(pointInCenterRay, fireBaseArea,Color.green);
- float camCenterToTarget = Vector3.Distance(pointInCenterRay, fireBaseArea);
+ float camCenterToFireBase = Vector3.Distance(pointInCenterRay, fireBaseArea);
// left of screen to target's distance
// Debug.DrawLine(pointInLeftRay, pointInCenterRay, Color.yellow);
float camCenterToViewEdge = Vector3.Distance(pointInLeftRay, pointInCenterRay);
-
- switch (targetCon.targetTypeInt)
- {
- case (int)Targets.Free:
- //free mode
- RaycastHit hit;
- if (Physics.Raycast(centerRay, out hit, 100))
- {
- // facing to an enemy
- if (hit.collider.tag != agentCon.myTag && hit.collider.tag != "Wall")
- {
- nowReward = commonParamCon.facingReward;
- isFacingtoEnemy = true;
- }
- }
- if (raySensors.inViewEnemies.Count > 0 && !isFacingtoEnemy)
- {
- // have enemy in view
- List projectionDis = new List();
- foreach (GameObject theEnemy in raySensors.inViewEnemies)
- {
- // for each enemy in view
- Vector3 projection = Vector3.Project(theEnemy.transform.position - transform.position, (centerRay.direction * 10));
- Vector3 verticalToRay = transform.position + projection - theEnemy.transform.position;
- projectionDis.Add(verticalToRay.magnitude);
- // Debug.Log("enemy!" + verticalToRay.magnitude);
- // Debug.DrawRay(transform.position, (centerRay.direction * 100), Color.cyan);
- // Debug.DrawRay(transform.position, theEnemy.transform.position - transform.position, Color.yellow);
- // Debug.DrawRay(transform.position, projection, Color.blue);
- // Debug.DrawRay(theEnemy.transform.position, verticalToRay, Color.magenta);
- }
- enemyFacingDistance = projectionDis.Min();
- if (enemyFacingDistance <= lastEnemyFacingDistance)
- {
- // closing to enemy
- nowReward = 1 / MathF.Sqrt(commonParamCon.facingInviewEnemyDisCOEF * enemyFacingDistance + 0.00001f);
- }
- else
- {
- nowReward = 0;
- }
- // enemy in view Reward
- lastEnemyFacingDistance = enemyFacingDistance;
- if (nowReward >= commonParamCon.facingReward) nowReward = commonParamCon.facingReward; // limit
- if (nowReward <= -commonParamCon.facingReward) nowReward = -commonParamCon.facingReward; // limit
- // Debug.Log("ninimum = " + nowReward);
- }
- break;
-
- case (int)Targets.Attack:
- // attack mode
- if (targetDis <= raySensors.viewDistance)
- {
- // Debug.DrawRay(new Vector3(0,0,0), viewPoint, Color.red);
- // while center of screen between target's distance is lower than firebasesAreaDiameter
- // while facing to target
- if (camCenterToTarget <= sceneBlockCon.nowBlock.firebasesAreaDiameter / 2)
- {
- // Debug.DrawRay(centerRay.origin, viewPoint-centerRay.origin, Color.blue);
- nowReward = commonParamCon.facingReward;
- }
- else
- {
- // while not facing to target
- nowReward = (lastTargetFacingDistance - camCenterToTarget) * commonParamCon.facingTargetReward;
- }
- }
- // update lastTargetFacingDistance
- lastTargetFacingDistance = camCenterToTarget;
- break;
-
- case (int)Targets.Go:
- // goto mode
- if (camCenterToTarget <= camCenterToViewEdge)
- {
- // fireArea is in view
- nowReward = commonParamCon.facingReward;
- }
- else
- {
- nowReward = 0;
- }
- break;
-
- default:
- Debug.LogError("Wrong target type");
- break;
- }
- return nowReward;
+ return (camCenterToFireBase, camCenterToViewEdge, targetDis);
}
///
@@ -310,24 +339,24 @@ private float FacingReward()
int endTypeInt = 0;
float nowReward = 0;
float endReward = 0;
- switch (targetCon.targetTypeInt)
+ switch (targetCon.targetType)
{
- case (int)Targets.Go:
+ case Targets.Go:
// goto
(endTypeInt, nowReward, endReward) = CheckOverAndRewardsGo();
break;
- case (int)Targets.Attack:
+ case Targets.Attack:
// attack
(endTypeInt, nowReward, endReward) = CheckOverAndRewardsAttack();
break;
- case (int)Targets.Defence:
+ case Targets.Defence:
//defence
(endTypeInt, nowReward, endReward) = CheckOverAndRewardsDefence();
break;
- case (int)Targets.Stay:
+ case Targets.Stay:
// Stay
// endless
nowReward = 0;
@@ -522,7 +551,7 @@ private float GetDistanceReward(float nowDistance, int inarea)
public float KillReward(Vector3 enemyPosition)
{
float nowKillReward = 0f;
- if (targetCon.targetTypeInt == (int)Targets.Attack)
+ if (targetCon.targetType == Targets.Attack)
{
// attack mode
(_, int isInArea) = sceneBlockCon.nowBlock.GetDistInArea(enemyPosition);
@@ -536,7 +565,7 @@ public float KillReward(Vector3 enemyPosition)
nowKillReward = commonParamCon.killNonTargetReward;
}
}
- else if (targetCon.targetTypeInt == (int)Targets.Free)
+ else if (targetCon.targetType == Targets.Free)
{
// free mode hit
nowKillReward = paramCon.killTargetEnemyReward;
@@ -557,7 +586,7 @@ public float KillReward(Vector3 enemyPosition)
public float HitEnemyReward(Vector3 enemyPosition)
{
float nowHitReward = 0f;
- if (targetCon.targetTypeInt == (int)Targets.Attack)
+ if (targetCon.targetType == Targets.Attack)
{
// attack mode
(_, int isInArea) = sceneBlockCon.nowBlock.GetDistInArea(enemyPosition);
@@ -572,7 +601,7 @@ public float HitEnemyReward(Vector3 enemyPosition)
nowHitReward = commonParamCon.hitNonTargetReward;
}
}
- else if (targetCon.targetTypeInt == (int)Targets.Free)
+ else if (targetCon.targetType == Targets.Free)
{
// free mode hit
nowHitReward = paramCon.hitTargetReward;
diff --git a/Assets/Scenes/Play.unity b/Assets/Scenes/Play.unity
index 24705b6..b60018a 100644
--- a/Assets/Scenes/Play.unity
+++ b/Assets/Scenes/Play.unity
@@ -3302,7 +3302,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1}
- m_AnchoredPosition: {x: 0.000030517578, y: -246.20215}
+ m_AnchoredPosition: {x: 0.000030517578, y: -246.20192}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!114 &324069808
@@ -7165,7 +7165,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
agentCam: {fileID: 1633276149}
TPSCam: {fileID: 1586670226}
- lineMeterial: {fileID: 10306, guid: 0000000000000000f000000000000000, type: 3}
+ lineMeterial: {fileID: 10306, guid: 0000000000000000f000000000000000, type: 0}
rayInfoPrefab: {fileID: 2963094767576631243, guid: e13f99706bb4ffe459a06857048ece22, type: 3}
agentCanvas: {fileID: 1054491405}
viewDistance: 100
@@ -12793,7 +12793,7 @@ MonoBehaviour:
m_HandleRect: {fileID: 538300382}
m_Direction: 2
m_Value: 0
- m_Size: 0.9999897
+ m_Size: 0.9998836
m_NumberOfSteps: 0
m_OnValueChanged:
m_PersistentCalls:
@@ -19532,7 +19532,7 @@ MonoBehaviour:
m_GameObject: {fileID: 1866094461}
m_Enabled: 1
m_EditorHideFlags: 0
- m_Script: {fileID: 11500000, guid: ea781484763623c438c1806e3a965667, type: 3}
+ m_Script: {fileID: 11500000, guid: 9585e6d628809d14ba93cb74005c3514, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &1866094463
@@ -20068,7 +20068,7 @@ MonoBehaviour:
enemyContainerObj: {fileID: 891195334}
sceneBlockContainerObj: {fileID: 1811162388}
targetControllerObj: {fileID: 1692325237}
- parameterContainerObj: {fileID: 707336050}
+ commonParameterContainerObj: {fileID: 220347584}
HUDObj: {fileID: 2082200184}
mouseMode: 0
blockLevel: 0
diff --git a/Assets/Script/GameScript/MLAgentsCustomController.cs b/Assets/Script/GameScript/MLAgentsCustomController.cs
index 9378bfd..6e93471 100644
--- a/Assets/Script/GameScript/MLAgentsCustomController.cs
+++ b/Assets/Script/GameScript/MLAgentsCustomController.cs
@@ -55,7 +55,7 @@ private void Start()
envUIController = environmentUIObj.GetComponent();
hudController = hudObj.GetComponent();
targetUIController = hudObj.GetComponent();
- messageBoxController = worldUIControllerObj.GetComponent();
+ messageBoxController = hudObj.GetComponent();
sideChannelController = sideChannelObj.GetComponent();
rewardFunction = gameObject.GetComponent();
worldUICon = worldUIControllerObj.GetComponent();
@@ -163,13 +163,13 @@ public override void OnActionReceived(ActionBuffers actionBuffers)
{
envUIController.RemoveChart();
}
- worldUICon.UpdateChart(targetController.targetTypeInt, endTypeInt);
+ worldUICon.UpdateChart(targetController.targetType, endTypeInt);
//Debug.Log("reward = " + nowReward);
if (endTypeInt != (int)TargetController.EndType.Running)
{
// Win or lose Finished
Debug.Log("Finish reward = " + nowReward);
- string targetString = Enum.GetName(typeof(Targets), targetController.targetTypeInt);
+ string targetString = Enum.GetName(typeof(Targets), targetController.targetType);
switch (endTypeInt)
{
case (int)TargetController.EndType.Win:
diff --git a/Assets/Script/GameScript/ParameterContainer.cs b/Assets/Script/GameScript/ParameterContainer.cs
index 0037b9b..ea5a3c2 100644
--- a/Assets/Script/GameScript/ParameterContainer.cs
+++ b/Assets/Script/GameScript/ParameterContainer.cs
@@ -93,7 +93,7 @@ private void Start()
private void Update()
{
// get target distance and in area
- if (targetCon.targetTypeInt is (int)Targets.Go or (int)Targets.Attack)
+ if (targetCon.targetType is Targets.Go or Targets.Attack)
{
(agentDistance, agentInArea) = blockCont.GetAgentTargetDistanceAndInside(agentObj.transform.position);
// attack goto or defence target
diff --git a/Assets/Script/GameScript/TargetController.cs b/Assets/Script/GameScript/TargetController.cs
index b4e9c3b..1f7ef0e 100644
--- a/Assets/Script/GameScript/TargetController.cs
+++ b/Assets/Script/GameScript/TargetController.cs
@@ -36,7 +36,7 @@ public class TargetController : MonoBehaviour
[SerializeField, Range(0f, 1f)] public float gotoProb = 0.2f;
[SerializeField, Range(0f, 1f)] public float defenceProb = 0.2f;
- [System.NonSerialized] public int targetTypeInt;
+ [System.NonSerialized] public Targets targetType;
[System.NonSerialized] public int gotoLevelNum;
[System.NonSerialized] public int attackLevelNum;
public float[] targetState = new float[6];
@@ -150,7 +150,7 @@ public void RollNewScene()
{
// goto target spawn
Debug.Log("GOTO THIS TARGET!");
- targetTypeInt = (int)Targets.Go;
+ targetType = Targets.Go;
RandomSpawnSceneBlock(Targets.Go);
// set startDistance
firstRewardFlag = true;
@@ -159,7 +159,7 @@ public void RollNewScene()
{
// attack target spawn
Debug.Log("ATTACK Mode Start");
- targetTypeInt = (int)Targets.Attack;
+ targetType = Targets.Attack;
RandomSpawnSceneBlock(Targets.Attack);
// set startDistance
firstRewardFlag = true;
@@ -169,7 +169,7 @@ public void RollNewScene()
{
// defence target spawn
Debug.Log("DEFENCE Mode Start");
- targetTypeInt = (int)Targets.Defence;
+ targetType = Targets.Defence;
RandomSpawnSceneBlock(Targets.Defence);
// set startDistance
firstRewardFlag = true;
@@ -177,14 +177,14 @@ public void RollNewScene()
else
{
Debug.Log("Free Mode Start");
- targetTypeInt = (int)Targets.Free;
+ targetType = Targets.Free;
enemyCon.DestroyAllEnemys();
enemyCon.RandomInitEnemys(hudCon.enemyNum);
MoveAgentToSpwanArea();
sceneBlockCon.DestroyBlock();
}
UpdateTargetStates();
- envUICon.UpdateTargetType(targetTypeInt);
+ envUICon.UpdateTargetType(targetType);
}
#region Agent Move Method
@@ -282,9 +282,9 @@ private void RandomSpawnSceneBlock(Targets targetType)
///
public void PlayInitialize()
{
- targetTypeInt = (int)Targets.Stay;
+ targetType = Targets.Stay;
UpdateTargetStates();
- envUICon.UpdateTargetType(targetTypeInt);
+ envUICon.UpdateTargetType(targetType);
MoveAgentToSpwanArea();
enemyCon.DestroyAllEnemys();
sceneBlockCon.DestroyBlock();
@@ -293,33 +293,33 @@ public void PlayInitialize()
// change to attack mode
public void AttackModeChange(Vector3 targetPosition)
{
- targetTypeInt = (int)Targets.Attack;
+ targetType = Targets.Attack;
UpdateTargetStates(targetPosition);
- envUICon.UpdateTargetType(targetTypeInt);
+ envUICon.UpdateTargetType(targetType);
}
// change to free mode
public void FreeModeChange()
{
- targetTypeInt = (int)Targets.Free;
+ targetType = (int)Targets.Free;
UpdateTargetStates();
- envUICon.UpdateTargetType(targetTypeInt);
+ envUICon.UpdateTargetType(targetType);
}
// change to goto mode
public void GotoModeChange(Vector3 targetPosition)
{
- targetTypeInt = (int)Targets.Go;
+ targetType = Targets.Go;
UpdateTargetStates(targetPosition);
- envUICon.UpdateTargetType(targetTypeInt);
+ envUICon.UpdateTargetType(targetType);
}
// change to stay mode
public void StayModeChange()
{
- targetTypeInt = (int)Targets.Stay;
+ targetType = Targets.Stay;
UpdateTargetStates();
- envUICon.UpdateTargetType(targetTypeInt);
+ envUICon.UpdateTargetType(targetType);
}
#endregion Play Mode Method
@@ -332,12 +332,12 @@ public void StayModeChange()
private void UpdateTargetStates(Vector3? targetPosition = null)
{
// targettype, x,y,z, firebasesAreaDiameter
- targetState[0] = targetTypeInt;
+ targetState[0] = (int)targetType;
if (targetPosition != null)
{
this.targetPosition = (Vector3)targetPosition;
}
- if (targetTypeInt == (int)Targets.Free || targetTypeInt == (int)Targets.Stay)
+ if (targetType == (int)Targets.Free || targetType == Targets.Stay)
{
for (int i = 1; i < targetState.Length; i++)
// set target position state to 0
@@ -360,7 +360,7 @@ private void UpdateTargetStates(Vector3? targetPosition = null)
/// The in-area state.
public int GetInAreaState()
{
- if (targetTypeInt == (int)Targets.Go)
+ if (targetType == Targets.Go)
{
return inArea;
}
diff --git a/Assets/Script/PlayMode/MouseInMap.cs b/Assets/Script/PlayMode/MouseInMap.cs
index ca0ffe5..a475073 100644
--- a/Assets/Script/PlayMode/MouseInMap.cs
+++ b/Assets/Script/PlayMode/MouseInMap.cs
@@ -21,7 +21,7 @@ public class MouseInMap : MonoBehaviour
[SerializeField]
private GameObject targetControllerObj;
[SerializeField]
- private GameObject parameterContainerObj;
+ private GameObject commonParameterContainerObj;
[SerializeField]
private GameObject HUDObj;
@@ -56,7 +56,7 @@ public enum MouseMode
private void Start()
{
- commonParamCon = parameterContainerObj.GetComponent();
+ commonParamCon = commonParameterContainerObj.GetComponent();
groundMask = LayerMask.GetMask("Ground");
targetCon = targetControllerObj.GetComponent();
mousePreviewCon = mousePreviewObj.GetComponent();
diff --git a/Assets/Script/UI/EnvironmentUIControl.cs b/Assets/Script/UI/EnvironmentUIControl.cs
index bb1e9df..a61ab27 100644
--- a/Assets/Script/UI/EnvironmentUIControl.cs
+++ b/Assets/Script/UI/EnvironmentUIControl.cs
@@ -131,31 +131,31 @@ public void UpdateTargetGauge(float firebasesBelong, float belongMaxPoint)
}
// update targetType text
- public void UpdateTargetType(int targetInt)
+ public void UpdateTargetType(Targets targetInt)
{
switch (targetInt)
{
- case (int)Targets.Go:
+ case Targets.Go:
targetTypeText.text = "GOTO";
targetTypeText.color = Color.blue;
break;
- case (int)Targets.Attack:
+ case Targets.Attack:
targetTypeText.text = "Attack!";
targetTypeText.color = Color.red;
break;
- case (int)Targets.Defence:
+ case Targets.Defence:
targetTypeText.text = "Defence";
targetTypeText.color = Color.green;
break;
- case (int)Targets.Free:
+ case Targets.Free:
targetTypeText.text = "Free";
targetTypeText.color = Color.yellow;
break;
- case (int)Targets.Stay:
+ case Targets.Stay:
targetTypeText.text = "Stay";
targetTypeText.color = Color.white;
break;
@@ -169,7 +169,7 @@ public void UpdateTargetType(int targetInt)
// update state text
// public TextMeshProUGUI stateText;
- // targetState[0] = targetTypeInt;
+ // targetState[0] = targetType;
// targetState[1] = targetEndPosition.x / raySensors.viewDistance; // normalization
// targetState[2] = targetEndPosition.y / raySensors.viewDistance;
// targetState[3] = targetEndPosition.z / raySensors.viewDistance;
diff --git a/Assets/Script/UI/WorldUIController.cs b/Assets/Script/UI/WorldUIController.cs
index 55d8d0f..7c75f50 100644
--- a/Assets/Script/UI/WorldUIController.cs
+++ b/Assets/Script/UI/WorldUIController.cs
@@ -26,32 +26,33 @@ private void Start()
}
}
- public void UpdateChart(int targetType, int endType)
+ public void UpdateChart(Targets targetType, int endType)
{
float winRatio = 0f;
+ int targetTypeInt = (int)targetType;
switch (endType)
{
case (int)TargetController.EndType.Win:
//Win
- totalGames[targetType] += 1;
- winGames[targetType] += 1;
- winRatio = (float)winGames[targetType] / totalGames[targetType];
- winChart.AddData(targetType, winRatio);
- if (totalGames[targetType] > maxXAxis)
+ totalGames[targetTypeInt] += 1;
+ winGames[targetTypeInt] += 1;
+ winRatio = (float)winGames[targetTypeInt] / totalGames[targetTypeInt];
+ winChart.AddData(targetTypeInt, winRatio);
+ if (totalGames[targetTypeInt] > maxXAxis)
{
- maxXAxis = totalGames[targetType];
+ maxXAxis = totalGames[targetTypeInt];
winChart.AddXAxisData(Convert.ToString(maxXAxis));
}
break;
case (int)TargetController.EndType.Lose:
//lose
- totalGames[targetType] += 1;
- winRatio = (float)winGames[targetType] / totalGames[targetType];
- winChart.AddData(targetType, winRatio);
- if (totalGames[targetType] > maxXAxis)
+ totalGames[targetTypeInt] += 1;
+ winRatio = (float)winGames[targetTypeInt] / totalGames[targetTypeInt];
+ winChart.AddData(targetTypeInt, winRatio);
+ if (totalGames[targetTypeInt] > maxXAxis)
{
- maxXAxis = totalGames[targetType];
+ maxXAxis = totalGames[targetTypeInt];
winChart.AddXAxisData(Convert.ToString(maxXAxis));
}
break;
diff --git a/UserSettings/EditorUserSettings.asset b/UserSettings/EditorUserSettings.asset
index 3d09235..bbd5554 100644
--- a/UserSettings/EditorUserSettings.asset
+++ b/UserSettings/EditorUserSettings.asset
@@ -12,10 +12,10 @@ EditorUserSettings:
value: 5703025650035e5d090f087148715d4443161e2c7e2c20357b281b31b0e43060
flags: 0
RecentlyUsedSceneGuid-2:
- value: 5453565f53020f085f5d0e72157a0844454f4c2b757d7265757a4f64b7b4313c
+ value: 06570c0704040b0e5a575520137b5e44154f192e292d22367c2c4866b7b3376f
flags: 0
RecentlyUsedSceneGuid-3:
- value: 06570c0704040b0e5a575520137b5e44154f192e292d22367c2c4866b7b3376f
+ value: 5453565f53020f085f5d0e72157a0844454f4c2b757d7265757a4f64b7b4313c
flags: 0
RecentlyUsedScenePath-0:
value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d
diff --git a/UserSettings/Layouts/default-2021.dwlt b/UserSettings/Layouts/default-2021.dwlt
index bd96fc6..d66d9f5 100644
--- a/UserSettings/Layouts/default-2021.dwlt
+++ b/UserSettings/Layouts/default-2021.dwlt
@@ -14,12 +14,12 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_PixelRect:
serializedVersion: 2
- x: -141
- y: 132
+ x: 39
+ y: 281
width: 1792
height: 1021
m_ShowMode: 4
- m_Title: Inspector
+ m_Title: Game
m_RootView: {fileID: 2}
m_MinSize: {x: 875, y: 300}
m_MaxSize: {x: 10000, y: 10000}
@@ -120,7 +120,7 @@ MonoBehaviour:
m_MinSize: {x: 300, y: 200}
m_MaxSize: {x: 24288, y: 16192}
vertical: 0
- controlID: 52
+ controlID: 49
--- !u!114 &6
MonoBehaviour:
m_ObjectHideFlags: 52
@@ -140,12 +140,12 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 0
- width: 957
+ width: 956
height: 971
m_MinSize: {x: 100, y: 200}
m_MaxSize: {x: 8096, y: 16192}
vertical: 1
- controlID: 128
+ controlID: 50
--- !u!114 &7
MonoBehaviour:
m_ObjectHideFlags: 52
@@ -163,7 +163,7 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 0
- width: 957
+ width: 956
height: 696
m_MinSize: {x: 201, y: 221}
m_MaxSize: {x: 4001, y: 4021}
@@ -190,7 +190,7 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 696
- width: 957
+ width: 956
height: 275
m_MinSize: {x: 231, y: 271}
m_MaxSize: {x: 10001, y: 10021}
@@ -217,14 +217,14 @@ MonoBehaviour:
- {fileID: 11}
m_Position:
serializedVersion: 2
- x: 957
+ x: 956
y: 0
width: 496
height: 971
m_MinSize: {x: 100, y: 200}
m_MaxSize: {x: 8096, y: 16192}
vertical: 1
- controlID: 103
+ controlID: 17
--- !u!114 &10
MonoBehaviour:
m_ObjectHideFlags: 52
@@ -293,9 +293,9 @@ MonoBehaviour:
m_Children: []
m_Position:
serializedVersion: 2
- x: 1453
+ x: 1452
y: 0
- width: 339
+ width: 340
height: 971
m_MinSize: {x: 276, y: 71}
m_MaxSize: {x: 4001, y: 4021}
@@ -324,9 +324,9 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
- x: -141
- y: 162
- width: 956
+ x: 39
+ y: 311
+ width: 955
height: 675
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
@@ -662,9 +662,9 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
- x: 65
+ x: 1920
y: 73
- width: 990
+ width: 1024
height: 686
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
@@ -676,7 +676,7 @@ MonoBehaviour:
m_ShowGizmos: 0
m_TargetDisplay: 0
m_ClearColor: {r: 0, g: 0, b: 0, a: 0}
- m_TargetSize: {x: 990, y: 665}
+ m_TargetSize: {x: 1024, y: 665}
m_TextureFilterMode: 0
m_TextureHideFlags: 61
m_RenderIMGUI: 1
@@ -691,8 +691,8 @@ MonoBehaviour:
m_VRangeLocked: 0
hZoomLockedByDefault: 0
vZoomLockedByDefault: 0
- m_HBaseRangeMin: -495
- m_HBaseRangeMax: 495
+ m_HBaseRangeMin: -512
+ m_HBaseRangeMax: 512
m_VBaseRangeMin: -332.5
m_VBaseRangeMax: 332.5
m_HAllowExceedBaseRangeMin: 1
@@ -712,23 +712,23 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 21
- width: 990
+ width: 1024
height: 665
m_Scale: {x: 1, y: 1}
- m_Translation: {x: 495, y: 332.5}
+ m_Translation: {x: 512, y: 332.5}
m_MarginLeft: 0
m_MarginRight: 0
m_MarginTop: 0
m_MarginBottom: 0
m_LastShownAreaInsideMargins:
serializedVersion: 2
- x: -495
+ x: -512
y: -332.5
- width: 990
+ width: 1024
height: 665
m_MinimalGUI: 1
m_defaultScale: 1
- m_LastWindowPixelSize: {x: 990, y: 686}
+ m_LastWindowPixelSize: {x: 1024, y: 686}
m_ClearInEditMode: 1
m_NoCameraWarning: 1
m_LowResolutionForAspectRatios: 01000000000000000000
@@ -754,9 +754,9 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
- x: -141
- y: 858
- width: 956
+ x: 39
+ y: 1007
+ width: 955
height: 254
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
@@ -775,36 +775,36 @@ MonoBehaviour:
m_SkipHidden: 0
m_SearchArea: 1
m_Folders:
- - Assets/Script/GameScript
+ - Assets/Shader
m_Globs: []
m_OriginalText:
m_ViewMode: 1
m_StartGridSize: 16
m_LastFolders:
- - Assets/Script/GameScript
+ - Assets/Shader
m_LastFoldersGridSize: 16
m_LastProjectPath: C:\Users\UCUNI\OneDrive\Unity\ML-Agents\Aimbot-ParallelEnv
m_LockTracker:
m_IsLocked: 0
m_FolderTreeState:
- scrollPos: {x: 0, y: 502}
- m_SelectedIDs: ce880000
- m_LastClickedID: 35022
- m_ExpandedIDs: 00000000b0880000b2880000b4880000b6880000b8880000ba880000bc880000be880000c0880000c2880000c4880000c6880000c8880000ca880000cc880000ce880000d0880000d2880000d4880000f888000000ca9a3bffffff7f
+ scrollPos: {x: 0, y: 337}
+ m_SelectedIDs: 08890000
+ m_LastClickedID: 35080
+ m_ExpandedIDs: 000000001488000016880000188800001a8800001c8800001e88000020880000228800002488000026880000288800002a8800002c880000328800003488000036880000388800008c88000000ca9a3bffffff7f
m_RenameOverlay:
m_UserAcceptedRename: 0
- m_Name: Prefeb
- m_OriginalName: Prefeb
+ m_Name:
+ m_OriginalName:
m_EditFieldRect:
serializedVersion: 2
x: 0
y: 0
width: 0
height: 0
- m_UserData: 1000000003
+ m_UserData: 0
m_IsWaitingForDelay: 0
m_IsRenaming: 0
- m_OriginalEventType: 0
+ m_OriginalEventType: 11
m_IsRenamingFilename: 1
m_ClientGUIView: {fileID: 8}
m_SearchString:
@@ -818,7 +818,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0}
m_SelectedIDs:
m_LastClickedID: 0
- m_ExpandedIDs: 00000000b0880000b2880000b4880000b6880000b8880000ba880000bc880000be880000c0880000c2880000c4880000c6880000c8880000ca880000cc880000ce880000d0880000d2880000d4880000
+ m_ExpandedIDs: 000000001488000016880000188800001a8800001c8800001e88000020880000228800002488000026880000288800002a8800002c8800002e8800003088000032880000348800003688000038880000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@@ -922,8 +922,8 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
- x: 816
- y: 162
+ x: 995
+ y: 311
width: 494
height: 526
m_ViewDataDictionary: {fileID: 0}
@@ -933,9 +933,9 @@ MonoBehaviour:
m_SceneHierarchy:
m_TreeViewState:
scrollPos: {x: 0, y: 0}
- m_SelectedIDs: dc920000
- m_LastClickedID: 37596
- m_ExpandedIDs: 82f7ffff88f8ffff30fbffff38930000
+ m_SelectedIDs: 2ec40000
+ m_LastClickedID: 50222
+ m_ExpandedIDs: 68d6ffff52d7fffff6dbffff36e5ffff40e6ffff48e7ffff52e8ffff6ae9ffff32fbffffb8b3000064c00000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@@ -979,8 +979,8 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
- x: 816
- y: 709
+ x: 995
+ y: 858
width: 494
height: 403
m_ViewDataDictionary: {fileID: 0}
@@ -1035,9 +1035,9 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
- x: 1312
- y: 162
- width: 338
+ x: 1491
+ y: 311
+ width: 339
height: 950
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
@@ -1050,7 +1050,7 @@ MonoBehaviour:
m_ControlHash: -371814159
m_PrefName: Preview_InspectorPreview
m_LastInspectedObjectInstanceID: -1
- m_LastVerticalScrollValue: 918
+ m_LastVerticalScrollValue: 0
m_GlobalObjectId:
m_InspectorMode: 0
m_LockTracker: