From 82219b9882776a79f55793c8bf5f5cd1638cd828 Mon Sep 17 00:00:00 2001 From: Ariel Kwiatkowski Date: Fri, 26 May 2023 14:44:28 +0100 Subject: [PATCH] Clamp the avg energy heuristic --- Assets/Scenes/NormalScene.unity | 4 +++- Assets/Scripts/MLUtils.cs | 3 +++ Assets/Scripts/Params.cs | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Assets/Scenes/NormalScene.unity b/Assets/Scenes/NormalScene.unity index 7b42c4f..9dfa465 100644 --- a/Assets/Scenes/NormalScene.unity +++ b/Assets/Scenes/NormalScene.unity @@ -600,7 +600,7 @@ MonoBehaviour: spawnScale: 7 gridSpawn: 1 groupSpawnScale: 1.5 - enableObstacles: 1 + enableObstacles: 0 blockScale: 3 randomMass: 1 randomEnergy: 0 @@ -621,6 +621,7 @@ MonoBehaviour: rewardVelocityMatching: 1 rewardGoal: 1 rewardFinal: 1 + rewardAvgFinal: 1 sightRadius: 10 sightAgents: 12 sightAngle: 180 @@ -6263,6 +6264,7 @@ MonoBehaviour: PreferredSpeed: 1.33 mass: 1 squasherType: 3 + startPosition: {x: 0, y: 0, z: 0} CollectedGoal: 0 rewardDisabled: 0 distanceTraversed: 0 diff --git a/Assets/Scripts/MLUtils.cs b/Assets/Scripts/MLUtils.cs index c212c0d..1984a92 100644 --- a/Assets/Scripts/MLUtils.cs +++ b/Assets/Scripts/MLUtils.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Diagnostics.Contracts; using System.Linq; +using System.Reflection; using Managers; using UnityEngine; using Random = UnityEngine.Random; @@ -259,6 +260,8 @@ public static float AverageEnergyHeuristic(Vector3 position, Vector3 target, Vec var avgSpeed = (totalDistance - finalDistance) / timeLimit; // v' + + avgSpeed = Mathf.Max(avgSpeed, Params.HeuristicEpsilon); var remainingTime = finalDistance / avgSpeed; // T' diff --git a/Assets/Scripts/Params.cs b/Assets/Scripts/Params.cs index 532becd..3e86aa0 100644 --- a/Assets/Scripts/Params.cs +++ b/Assets/Scripts/Params.cs @@ -135,6 +135,9 @@ private void Awake() public float rewardAvgFinal = 1f; public static float RewAvgFinal => Get("r_avg_final", Instance.rewardAvgFinal); + public float heuristicEpsilon = 0.1f; + public static float HeuristicEpsilon => Get("heuristic_epsilon", Instance.heuristicEpsilon); +