直角移動 (上下左右) 代價 = 10,斜向移動代價 = 14 (≈ √2 × 10)。放大 10 倍改用整數運算,避免浮點數效能損耗。
public class RoutePlanData
{
public Rectangle CellMap { get; } // 地圖矩形範圍
public IList ClosedList { get; } = new List(); // 已處理節點
public IList OpenedList { get; } = new List(); // 待處理節點
public Point Destination { get; } // 目標位置
public RoutePlanData(Rectangle map, Point destination)
{
CellMap = map;
Destination = destination;
}
}
此類別為單次 Plan 呼叫的暫存狀態容器,不持有演算法邏輯。