searchStep method
Implementation
@override
void searchStep(GridBFSState state) {
// If there is no open node, we are stuck.
if (state.open.isEmpty) {
state.status = Status.failure;
return;
}
GridPoint point = state.open.removeFirst();
point.set(state.grid, GridNode.closed);
// We can return because the target node is reached.
if (state.target.get(state.grid) == GridNode.closed) {
state.status = Status.success;
return;
}
for (var (i, j) in state.dirs) {
GridPoint newPoint = GridPoint(point.x + i, point.y + j);
if (state.isUntraversable(newPoint)) continue;
GridNode newNode = newPoint.get(state.grid);
if (newNode == GridNode.closed) continue;
if (newNode != GridNode.open) {
state.parents[newPoint] = point;
state.open.add(newPoint);
newPoint.set(state.grid, GridNode.open);
}
}
}