3) A* 移動優化
預留介面,依參數啟動不同效率/路徑長度/精度的 A*。推薦兩方案:預設最精確但耗效能;另一最高效但路徑非最短:
PathFinderFast pathFinderFast = new PathFinderFast(varyObstruction)
{
HeavyDiagonals = false,
HeuristicEstimate = 100,
};
封裝的 A* DLL 基於第七節改編,可作調試器調試參數組合。模擬測試得 0.0071 秒,滿意則記錄配置:Diagonals=true, HeavyDiagonals=true, Heuristic=5, Formula=Max(DX,DY), TIEBreaker=false, SearchLimit=40000。Silverlight 引擎中啟動:
PathFinderFast pathFinderFast = new PathFinderFast(varyObstruction)
{
Diagonals = true, HeavyDiagonals = true, HeuristicEstimate = 5,
Formula = HeuristicFormula.MaxDXDY, TIEBreaker = false, SearchLimit = 40000,
};

1) 地圖切片最優載入法
無需額外判斷、無需 Clear 容器,按 0-8 順序重新賦值 9 片 Source,效能極優:
private void ChangeMapSection()
{
countSection = 0;
for (int x = startSectionX; x <= endSectionX; x++)
for (int y = startSectionY; y <= endSectionY; y++)
{
mapSection[countSection].Source = Super.GetImage(string.Format("/Image/Map/{0}/Surface/{1}_{2}.jpg", mapCode, x, y));
Canvas.SetLeft(mapSection[countSection], x * mapSectionWidth);
Canvas.SetTop(mapSection[countSection], y * mapSectionHeight);
countSection++;
}
}
A* 使用竟可如此簡單。