copy method

  1. @override
GridAstarState copy()
override

Implementation

@override
GridAstarState copy() {
  var newState = GridAstarState(
    start: start,
    target: target,
    grid: List.generate(grid.length, (i) => List.from(grid[i])),
    parents: HashMap.from(parents),
    dirs: List.from(dirs),
    gCost: HashMap.from(gCost),
    fCost: HashMap.from(fCost),
    open: PriorityQueue<GridPoint>((a, b) => fCost[a]!.compareTo(fCost[b]!)),
    status: status,
    heuristic: heuristic,
  );

  newState.open = PriorityQueue<GridPoint>(
      (a, b) => newState.fCost[a]!.compareTo(newState.fCost[b]!));
  newState.open.addAll(open.toList());

  return newState;
}