plan method
Plan a sequence of action that bring you from origin
to desiredState
using actions
.
Failed action parameters are for replanning. Just after an action fails,
we don't want to replan beginning with that same previouslyFailedAction
.
We avoid it once time by default, but can avoid it for longer periods
by setting countdownFailedActionAvoidance
. Value -1
is magical: it
will avoid previouslyFailedAction
for the whole duration of the plan.
Implementation
Future<Queue<T>?> plan(
State origin, DesiredState desiredState, Iterable<T> actions,
{T? previouslyFailedAction,
int countdownFailedActionAvoidance: 1,
bool singleUseActions: false}) {
if (actions is! Set<T>) {
actions = new Set<T>.from(actions);
}
FindPathParams<T> params =
new FindPathParams<T>(actions, previouslyFailedAction);
params.countdownFailedActionAvoidance = countdownFailedActionAvoidance;
print("Starting search.");
return _aStar.findPath(origin, desiredState, actions,
singleUseWays: singleUseActions, params: params);
}