From ab9c963d877fa449942a2119f0d41a059228f984 Mon Sep 17 00:00:00 2001 From: S3JER <72788875+S3JER@users.noreply.github.com> Date: Fri, 8 Nov 2024 10:36:54 +0100 Subject: [PATCH] Handle if vertices have not been visited Co-Authored-By: Puvikaran Santhirasegaram <74664443+Puvikaran2001@users.noreply.github.com> --- Assets/Scripts/GlobalSettings.cs | 2 +- Assets/Scripts/Map/Vertex.cs | 2 ++ Assets/Scripts/Statistics/PatrollingVisualizer.cs | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Assets/Scripts/GlobalSettings.cs b/Assets/Scripts/GlobalSettings.cs index 77e59991..fea9b619 100644 --- a/Assets/Scripts/GlobalSettings.cs +++ b/Assets/Scripts/GlobalSettings.cs @@ -60,7 +60,7 @@ public static class GlobalSettings { public static readonly int TicksBeforeExplorationHeatMapCold = 10 * 60 * 4; public static readonly int TicksBeforeCoverageHeatMapCold = 10 * 60 * 4; - public static readonly int TicksBeforeWaypointCoverageHeatMapCold = 10 * 60 * 4; + public static readonly int TicksBeforeWaypointCoverageHeatMapCold = 10 * 60 * 6; public static bool IsRosMode = false; diff --git a/Assets/Scripts/Map/Vertex.cs b/Assets/Scripts/Map/Vertex.cs index 1e4a6c40..a36c53ed 100644 --- a/Assets/Scripts/Map/Vertex.cs +++ b/Assets/Scripts/Map/Vertex.cs @@ -13,6 +13,7 @@ public class Vertex : ICloneable public int LastTimeVisitedTick { get; private set; } = 0; public Vector2Int Position { get; } public Color Color { get; set;} + public int NumberOfVisits { get; private set; } = 0; public Vertex(float weight, Vector2Int position, Color? color = null) { @@ -26,6 +27,7 @@ public Vertex(float weight, Vector2Int position, Color? color = null) public void VisitedAtTick(int tick) { LastTimeVisitedTick = tick; + NumberOfVisits++; } public void AddNeighbor(Vertex neighbor){ diff --git a/Assets/Scripts/Statistics/PatrollingVisualizer.cs b/Assets/Scripts/Statistics/PatrollingVisualizer.cs index e6165c22..ec7d5817 100644 --- a/Assets/Scripts/Statistics/PatrollingVisualizer.cs +++ b/Assets/Scripts/Statistics/PatrollingVisualizer.cs @@ -60,6 +60,7 @@ public void ShowWaypointHeatMap(int currentTick){ foreach (var vertex in _patrollingMap.Verticies) { + if(vertex.NumberOfVisits == 0) continue; var ticksSinceLastExplored = currentTick - vertex.LastTimeVisitedTick; float coldness = Mathf.Min((float) ticksSinceLastExplored / (float) GlobalSettings.TicksBeforeWaypointCoverageHeatMapCold, 1.0f); var color = Color32.Lerp(ExplorationVisualizer.WarmColor, ExplorationVisualizer.ColdColor, coldness);