Skip to content

Commit

Permalink
Handle if vertices have not been visited
Browse files Browse the repository at this point in the history
Co-Authored-By: Puvikaran Santhirasegaram <[email protected]>
  • Loading branch information
S3JER and Puvikaran2001 committed Nov 8, 2024
1 parent 4d792c0 commit ab9c963
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Assets/Scripts/GlobalSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 2 additions & 0 deletions Assets/Scripts/Map/Vertex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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){
Expand Down
1 change: 1 addition & 0 deletions Assets/Scripts/Statistics/PatrollingVisualizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ab9c963

Please sign in to comment.