E - type of the blackboard object that tasks use to read or modify game state@TaskConstraint(minChildren=0, maxChildren=1) public class Random<E> extends Decorator<E>
Random decorator succeeds with the specified probability, regardless of whether the wrapped task fails or succeeds.
Also, the wrapped task is optional, meaning that this decorator can act like a leaf task.
Notice that if success probability is 1 this task is equivalent to the decorator AlwaysSucceed and the leaf
Success. Similarly if success probability is 0 this task is equivalent to the decorator AlwaysFail and the leaf
Failure.
Task.Status| Modifier and Type | Field and Description |
|---|---|
FloatDistribution |
success
Optional task attribute specifying the random distribution that determines the success probability.
|
| Constructor and Description |
|---|
Random()
Creates a
Random decorator with no child that succeeds or fails with equal probability. |
Random(FloatDistribution success)
Creates a
Random decorator with no child that succeeds with the specified probability. |
Random(FloatDistribution success,
Task<E> task)
Creates a
Random decorator with the given child that succeeds with the specified probability. |
Random(Task<E> task)
Creates a
Random decorator with the given child that succeeds or fails with equal probability. |
| Modifier and Type | Method and Description |
|---|---|
void |
childFail(Task<E> runningTask)
This method will be called when one of the children of this task fails.
|
void |
childSuccess(Task<E> runningTask)
This method will be called when one of the children of this task succeeds.
|
protected Task<E> |
copyTo(Task<E> task)
Copies this task to the given task.
|
void |
run()
This method contains the update logic of this task.
|
void |
start()
Draws a value from the distribution that determines the success probability.
|
addChildToTask, childRunning, getChild, getChildCountpublic FloatDistribution success
ConstantFloatDistribution.ZERO_POINT_FIVE.public Random()
Random decorator with no child that succeeds or fails with equal probability.public Random(Task<E> task)
Random decorator with the given child that succeeds or fails with equal probability.task - the child task to wrappublic Random(FloatDistribution success)
Random decorator with no child that succeeds with the specified probability.success - the random distribution that determines success probabilitypublic Random(FloatDistribution success, Task<E> task)
Random decorator with the given child that succeeds with the specified probability.success - the random distribution that determines success probabilitytask - the child task to wrappublic void start()
This method is called when the task is entered.
public void run()
TaskTask.running(),
Task.success() or Task.fail() exactly once.public void childFail(Task<E> runningTask)
Taskpublic void childSuccess(Task<E> runningTask)
TaskchildSuccess in class Decorator<E>runningTask - the task that succeededCopyright © 2017. All rights reserved.