private void GetNewPath(Point ghostPosition, Point playerPosition) { List <Point> path = null; switch (_AIState) { case GhostAIState.Random: path = GridSearch.BestFirstSearch(_grid, ghostPosition, _grid.GetRandomOpenPoint()).Path; break; case GhostAIState.TargetingWithLag: path = GridSearch.AStarSearch(_grid, ghostPosition, playerPosition).Path; break; case GhostAIState.Fleeing: var result = GridSearch.DijkstraGeneral(_grid, playerPosition); Point best = null; float largestDist = 0; foreach (Point k in result.DistanceMap.Keys) { if (result.DistanceMap[k] > largestDist) { best = k; largestDist = result.DistanceMap[k]; } } Dictionary <Point, float> costMap = InvertCostMap(result.DistanceMap, largestDist); path = GridSearch.AStarSearchWithCost(_grid, ghostPosition, best, costMap).Path; break; } _pathList = new Stack <Point>(path); }