Evaluator class
An Evaluator instance updates its children nodes as an unordered sequence.
Composite child nodes will be updated until they return Status.success,
then they are ignored in any future calls update()
method of the
Evaluator until all other children nodes have returned Status.success.
The Evaluator will only call reset()
on children Node instances that
have not yet evaluated to one of the accepted Status values. By default,
only children nodes that return Status.success
are considered as
evaluated.
Example:
void evaluatorExample() {
final random = Random();
final randomSuccess0 = Closure(() {
if (random.nextDouble() > 0.95) {
print('rs0');
return Status.success;
}
return Status.failure;
});
final randomSuccess1 = Closure(() {
if (random.nextDouble() > 0.95) {
print('rs1');
return Status.success;
}
return Status.failure;
});
final evaluator = Sequence([
Evaluator([
Identity.success,
randomSuccess0,
randomSuccess1
]),
Print('evaluator finished'),
], isPartial: false);
while (evaluator.update() != Status.success) {}
// sometimes prints rs0, then rs1
// sometimes prints rs1, then rs0
}
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- index → int
-
Index of the current Node of the Composite. The value should represent
the index of the child Node that is in execution. The index is not
guaranteed to be inside the bounds of the List that holds the children
Node instances of the Composite.
no setterinherited
- length → int
-
Count of the number of Node instances in the Composite.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reset(
) → void -
override
-
toString(
) → String -
A string representation of this object.
inherited
-
update(
) → Status -
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator [](
int index) → Node -
Indexes into the List of children Node instances.
inherited