expand method

  1. @override
Iterable<AutonomyAStarState> expand()
override

Gets all possible states reachable from this state.

It is okay to return cyclic paths from this function. In a scenario with reversible actions, it is possible to go from, for example, State A to State B, and from State B to State A. It is okay to return both states when needed, as the cycle will be detected by comparing each state's hash values.

Implementation

@override
Iterable<AutonomyAStarState> expand() => [
  copyWith(direction: DriveDirection.forward, orientation: orientation, position: position.goForward(orientation)),
  copyWith(direction: DriveDirection.left, orientation: orientation.turnLeft(), position: position),
  copyWith(direction: DriveDirection.right, orientation: orientation.turnRight(), position: position),
].where((state) => !collection.pathfinder.isObstacle(state.position));