diff --git a/Assets/ML-Agents/Timers/Greatest_map_ever_timers.json b/Assets/ML-Agents/Timers/Greatest_map_ever_timers.json index 9a97eb3..ad80b5f 100644 --- a/Assets/ML-Agents/Timers/Greatest_map_ever_timers.json +++ b/Assets/ML-Agents/Timers/Greatest_map_ever_timers.json @@ -1 +1 @@ -{"count":1,"self":16.593504,"total":17.166309,"children":{"InitializeActuators":{"count":2,"self":0.0019996,"total":0.0019996,"children":null},"InitializeSensors":{"count":2,"self":0.0030004,"total":0.0030004,"children":null},"AgentSendState":{"count":612,"self":0.016998,"total":0.549809,"children":{"CollectObservations":{"count":1224,"self":0.0230042,"total":0.0230042,"children":null},"WriteActionMask":{"count":1224,"self":0.0060088,"total":0.0060088,"children":null},"RequestDecision":{"count":1224,"self":0.503798,"total":0.503798,"children":null}}},"DecideAction":{"count":612,"self":0.0089991,"total":0.0089991,"children":null},"AgentAct":{"count":612,"self":0.006997,"total":0.006997,"children":null}},"gauges":{"My Behavior.CumulativeReward":{"count":14,"max":0,"min":0,"runningAverage":0,"value":0,"weightedAverage":0}},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1650253950","unity_version":"2019.4.35f1","command_line_arguments":"C:\\Program Files\\unityeditorfolder\\2019.4.35f1\\Editor\\Unity.exe -projectpath F:\\SigmaRiskManagment\\real shooter Git Version -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-1IWpvtxiu_rvPpHhMWpzt -hubSessionId b1d8b690-be9f-11ec-92bc-6fd1276b6775 -accessToken D1AF5mitRE4Vh3s6p7rpmGuqcqvTsZJKmoGtSNfyNNs009f","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"Greatest_map_ever","end_time_seconds":"1650253967"}} \ No newline at end of file +{"count":1,"self":16.7881248,"total":28.869280999999997,"children":{"InitializeActuators":{"count":1,"self":0.0062039999999999994,"total":0.0062039999999999994,"children":null},"InitializeSensors":{"count":1,"self":0.009415,"total":0.009415,"children":null},"AgentInfo.ToProto":{"count":1,"self":0.0037809999999999996,"total":0.023178,"children":{"GenerateSensorData":{"count":1,"self":0.019396999999999998,"total":0.019396999999999998,"children":null}}},"AgentSendState":{"count":1094,"self":0.070126,"total":2.03434,"children":{"CollectObservations":{"count":1094,"self":1.694399,"total":1.694399,"children":null},"WriteActionMask":{"count":1094,"self":0.01526,"total":0.01526,"children":null},"RequestDecision":{"count":1094,"self":0.046751999999999995,"total":0.254555,"children":{"AgentInfo.ToProto":{"count":1094,"self":0.027583999999999997,"total":0.207803,"children":{"GenerateSensorData":{"count":1094,"self":0.180219,"total":0.180219,"children":null}}}}}}},"DecideAction":{"count":1094,"self":9.9110736,"total":9.911074,"children":null},"AgentAct":{"count":1094,"self":0.088208,"total":0.090377,"children":{"AgentInfo.ToProto":{"count":10,"self":0.00033,"total":0.002169,"children":{"GenerateSensorData":{"count":10,"self":0.001839,"total":0.001839,"children":null}}}}}},"gauges":{"npc.CumulativeReward":{"count":11,"max":0,"min":0,"runningAverage":0,"value":0,"weightedAverage":0}},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1650283028","unity_version":"2019.4.36f1","command_line_arguments":"\/Applications\/Unity\/Hub\/Editor\/2019.4.36f1\/Unity.app\/Contents\/MacOS\/Unity -projectpath \/Users\/gav\/tmp\/projects\/real-shooter -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-gav -hubSessionId 3b1d3b50-bef1-11ec-a2f1-7fead03718a2 -accessToken r8bZAeodsmy_r-5SjXH5Fv1-VHYleg9acf27P9OS5KU009f","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"Greatest_map_ever","end_time_seconds":"1650283056"}} \ No newline at end of file diff --git a/Assets/Prefabs/Bot.prefab b/Assets/Prefabs/Bot.prefab old mode 100755 new mode 100644 index eedbf35..286833e --- a/Assets/Prefabs/Bot.prefab +++ b/Assets/Prefabs/Bot.prefab @@ -143,19 +143,19 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_BrainParameters: - VectorObservationSize: 1 + VectorObservationSize: 4 NumStackedVectorObservations: 1 m_ActionSpec: m_NumContinuousActions: 0 - BranchSizes: 01000000 - VectorActionSize: 01000000 + BranchSizes: 0200000002000000 + VectorActionSize: 0200000002000000 VectorActionDescriptions: [] VectorActionSpaceType: 0 hasUpgradedBrainParametersWithActionSpec: 1 m_Model: {fileID: 0} m_InferenceDevice: 0 m_BehaviorType: 0 - m_BehaviorName: My Behavior + m_BehaviorName: npc TeamId: 0 m_UseChildSensors: 1 m_UseChildActuators: 1 @@ -209,4 +209,4 @@ MonoBehaviour: m_EditorClassIdentifier: m_SensorName: BufferSensor m_ObservableSize: 5 - m_MaxNumObservables: 512 + m_MaxNumObservables: 5 diff --git a/Assets/Scenes/Greatest_map_ever/Greatest_map_ever.unity b/Assets/Scenes/Greatest_map_ever/Greatest_map_ever.unity old mode 100755 new mode 100644 index 41d83a6..f858886 --- a/Assets/Scenes/Greatest_map_ever/Greatest_map_ever.unity +++ b/Assets/Scenes/Greatest_map_ever/Greatest_map_ever.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 705507994} - m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1} + m_IndirectSpecularColor: {r: 0.44657815, g: 0.49641192, b: 0.57481617, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -259,6 +259,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 6a2d29bfc31a8cf4e831e3bb80720414, type: 3} m_Name: m_EditorClassIdentifier: + PointId: 0 DeathAttr: 0 EnemiesSeen: [] --- !u!23 &140697607 @@ -353,6 +354,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 6a2d29bfc31a8cf4e831e3bb80720414, type: 3} m_Name: m_EditorClassIdentifier: + PointId: 0 DeathAttr: 0 EnemiesSeen: [] --- !u!23 &293522541 @@ -1315,6 +1317,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 6a2d29bfc31a8cf4e831e3bb80720414, type: 3} m_Name: m_EditorClassIdentifier: + PointId: 0 DeathAttr: 0 EnemiesSeen: [] --- !u!23 &1116745545 @@ -1745,7 +1748,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1345085340} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 47.446796, y: -5.782543, z: -25.400002} + m_LocalPosition: {x: 21.51, y: -5.782543, z: -10.46} m_LocalScale: {x: 1.4367, y: 1.4367, z: 1.4367} m_Children: [] m_Father: {fileID: 2060099472} @@ -1763,6 +1766,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 6a2d29bfc31a8cf4e831e3bb80720414, type: 3} m_Name: m_EditorClassIdentifier: + PointId: 0 DeathAttr: 0 EnemiesSeen: [] --- !u!23 &1345085343 @@ -1857,6 +1861,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 6a2d29bfc31a8cf4e831e3bb80720414, type: 3} m_Name: m_EditorClassIdentifier: + PointId: 0 DeathAttr: 0 EnemiesSeen: [] --- !u!23 &1488699524 @@ -2077,6 +2082,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 6a2d29bfc31a8cf4e831e3bb80720414, type: 3} m_Name: m_EditorClassIdentifier: + PointId: 0 DeathAttr: 0 EnemiesSeen: [] --- !u!23 &1663305224 @@ -2251,7 +2257,7 @@ MonoBehaviour: - {fileID: 2004854094} AIPrefab: {fileID: 2988578997639256874, guid: b016874eb34cc084aa4359f0bbec50e1, type: 3} - PlayerPrefab: {fileID: 5245491127989480125, guid: 80f6c1c85e5daed4c96c70205ed5503d, + PlayerPrefab: {fileID: 5245491127989480125, guid: 99bb17a23a489624baeaf337f91a4f84, type: 3} --- !u!1 &1871257865 GameObject: @@ -2506,6 +2512,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 6a2d29bfc31a8cf4e831e3bb80720414, type: 3} m_Name: m_EditorClassIdentifier: + PointId: 0 DeathAttr: 0 EnemiesSeen: [] --- !u!23 &2004854095 diff --git a/Assets/Scripts/Character/CharacterCondition.cs b/Assets/Scripts/Character/CharacterCondition.cs index d1ec569..33b15d5 100755 --- a/Assets/Scripts/Character/CharacterCondition.cs +++ b/Assets/Scripts/Character/CharacterCondition.cs @@ -9,6 +9,7 @@ public class CharacterCondition public event Action OnChangeAmmunitionEvent; private int health; + public int HealthPoints { get diff --git a/Assets/Scripts/Character/MovementController.cs b/Assets/Scripts/Character/MovementController.cs index 20e1026..71997d6 100644 --- a/Assets/Scripts/Character/MovementController.cs +++ b/Assets/Scripts/Character/MovementController.cs @@ -7,13 +7,28 @@ using UnityEngine.AI; public class MovementController : MonoBehaviour { public NavPoint currentPosition { get; set; } + private Dictionary navPoints = new Dictionary(); + [SerializeField] private NavMeshAgent navMeshAgent; private void Start() { - navMeshAgent.speed = SettingsReader.Instance.GetSettings.movementSpeed; + navMeshAgent.speed = SettingsReader.Instance.GetSettings.movementSpeed; + foreach (var np in MapManager.navPoints) { + navPoints[np.PointId] = np; + } } + public void MoveToPointById(int id) + { + if (!navPoints.ContainsKey(id)) + { + Debug.LogWarning("PIDOR"); + return; + } + goToNextNavPoint(navPoints[id]); + } + public void MoveToRandomPoint() { Debug.Log(MapManager.navPoints == null); @@ -23,7 +38,7 @@ public class MovementController : MonoBehaviour public List getPointsCandidate() { return MapManager.navPoints - .Where(point => (currentPosition.position - point.position).magnitude < SettingsReader.Instance.GetSettings.movementSpeed) + .Where(point => (currentPosition.position - point.position).magnitude < SettingsReader.Instance.GetSettings.movementDistance) .ToList(); } diff --git a/Assets/Scripts/Character/NPC.cs b/Assets/Scripts/Character/NPC.cs index 1069d42..7eb27c2 100644 --- a/Assets/Scripts/Character/NPC.cs +++ b/Assets/Scripts/Character/NPC.cs @@ -54,24 +54,29 @@ public class NPC : Agent, ICharacter sensor.AddObservation(Condition.HealthPoints); sensor.AddObservation(Condition.ArmourPoints); sensor.AddObservation(Condition.Ammunition); - sensor.AddObservation((int)NPC_State.State); + sensor.AddObservation((int) NPC_State.State); var candidates = moveController.getPointsCandidate(); foreach (var point in candidates) { - bufferSensor.AppendObservation(new float[] { + var parray = new float[] + { //1 position in navpointId - (float)moveController.currentPosition.PointId, + (float) moveController.currentPosition.PointId, //2 distance to flag moveController.currentPosition.FlagDistance, //3 death count in point moveController.currentPosition.DeathAttr, //4 flagEnemyDistance - GameManager.IsCloserToFlagFromNextNavPoint(point, transform.position)==true?1:0, + GameManager.IsCloserToFlagFromNextNavPoint(point, transform.position) == true ? 1 : 0, //5 EnemyVsNavPointDistance - GameManager.IsCloserToEnemyThanToNextNavPoint(point,transform.position, AgentCharacter.Team)==true?1:0 - }); - + GameManager.IsCloserToEnemyThanToNextNavPoint(point, transform.position, AgentCharacter.Team) == true + ? 1 + : 0 + }; + var _parray = string.Join(" ", parray); + Debug.Log("OBS: " + _parray); + bufferSensor.AppendObservation(parray); } } @@ -90,6 +95,9 @@ public class NPC : Agent, ICharacter { moveController.MoveToRandomPoint(); NPC_State = RunningState; + } else if (actions.DiscreteActions[0] == 2) + { + moveController.MoveToPointById(actions.DiscreteActions[1]); } } diff --git a/Assets/Scripts/Misc/NavPoint.cs b/Assets/Scripts/Misc/NavPoint.cs index 2b43e84..b36d9e8 100755 --- a/Assets/Scripts/Misc/NavPoint.cs +++ b/Assets/Scripts/Misc/NavPoint.cs @@ -8,13 +8,14 @@ public class NavPoint : MonoBehaviour public float FlagDistance { get; private set; } [HideInInspector] - public int? PointId; + public int PointId; public float DeathAttr = 0; public List EnemiesSeen = new List(); //Here other attributes; private void Start() { + PointId = GetInstanceID(); FlagDistance = (GameObject.FindGameObjectWithTag("Flag").transform.position - position).magnitude; } } diff --git a/Assets/Settings/Game Settings.asset b/Assets/Settings/Game Settings.asset old mode 100755 new mode 100644 index f1a62c0..98a5b56 --- a/Assets/Settings/Game Settings.asset +++ b/Assets/Settings/Game Settings.asset @@ -27,9 +27,9 @@ MonoBehaviour: armourPickupAmount: 50 ammunitionPickupAmount: 120 pickupsAmount: 2 - maxHealth: 0 - maxArmour: 0 - maxAmmo: 0 + maxHealth: 100 + maxArmour: 100 + maxAmmo: 31337 GetHitChanceInDirectPoint: 0 GetHitChanceInRunning: 0 GetHitChanceInCover: 0