Enum SquareDistanceMetric
Identifies the distance formula used when computing distances between SquareCoord values.
Namespace: Scylla.Core.Structures
Assembly: ScyllaCore.dll
Syntax
public enum SquareDistanceMetric
Remarks
The correct metric depends on the movement model of the game:
- 4-connected grids (VonNeumann) should use Manhattan as the A* heuristic.
- 8-connected grids where diagonal moves cost 1 (Moore) should use Chebyshev as the A* heuristic.
- 8-connected grids where diagonal moves cost sqrt(2) should use Octile as the A* heuristic.
- Euclidean is the true geometric distance and underestimates on discrete grids; prefer it only when the application requires the straight-line length rather than a pathfinding heuristic.
This enum is accepted by DistanceTo(SquareCoord, SquareDistanceMetric). For performance-critical code that only needs Manhattan or Chebyshev distances, prefer the dedicated integer methods ManhattanDistanceTo(SquareCoord) and ChebyshevDistanceTo(SquareCoord) which avoid floating-point overhead.
Fields
| Name | Description |
|---|---|
| Chebyshev | Maximum of the absolute differences along each axis: |
| Euclidean | Straight-line geometric distance: |
| Manhattan | Sum of the absolute differences along each axis: |
| Octile | Exact shortest-path distance for 8-connected movement where diagonal steps cost
|