From 97e099b5a96bd8ee4e19e56b76f6c7a43d2de77f Mon Sep 17 00:00:00 2001 From: zwarenelle Date: Mon, 24 Jun 2024 21:34:19 +0200 Subject: [PATCH] Remove obstacle class, keep on cell --- .../CoveragePathPlanner.cs | 21 +++---------------- 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/CoveragePathPlanner/CoveragePathPlanner.cs b/src/CoveragePathPlanner/CoveragePathPlanner.cs index 8b79b6a..5a7908d 100644 --- a/src/CoveragePathPlanner/CoveragePathPlanner.cs +++ b/src/CoveragePathPlanner/CoveragePathPlanner.cs @@ -23,18 +23,12 @@ public class CoveragePathPlanner } } - public List PlanPath(List obstacles) + public List PlanPath(List obstacles) { // Add obstacles to the grid - foreach (Obstacle obstacle in obstacles) + foreach (Point obstacle in obstacles) { - for (int x = obstacle.X; x < obstacle.X + obstacle.Width; x++) - { - for (int y = obstacle.Y; y < obstacle.Y + obstacle.Height; y++) - { - _cells[x + y * _width].IsObstacle = true; - } - } + _cells[obstacle.X + obstacle.Y * _width].IsObstacle = true; } // Initialize the start cell @@ -114,15 +108,6 @@ public class CoveragePathPlanner // Manhattan distance heuristic return Math.Abs(cell.X - (_width - 1)) + Math.Abs(cell.Y - (_height - 1)); } - -} - -public class Obstacle -{ - public int X { get; set; } - public int Y { get; set; } - public int Width { get; set; } - public int Height { get; set; } } public class Cell