Package net.citizensnpcs.api.astar
Class AStarMachine<N extends AStarNode,P extends Plan>
java.lang.Object
net.citizensnpcs.api.astar.AStarMachine<N,P>
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <N extends AStarNode,
P extends Plan>
AStarMachine<N, P> Creates an AStarMachine usingSimpleAStarStorage
as the storage backend.static <N extends AStarNode,
P extends Plan>
AStarMachine<N, P> createWithStorage
(Supplier<AStarStorage> storageSupplier) Creates an AStarMachine that uses the given
to createAStarStorage
instances.getStateFor
(AStarGoal<N> goal, N start) Creates anAStarMachine<N extends AStarNode,
that can be reused across multiple invocations of {P extends Plan>.AStarState run(AStarState, int)
.run
(AStarMachine<N, P>.AStarState state) Runs theAStarMachine<N extends AStarNode,
until a plan is found.P extends Plan>.AStarState run
(AStarMachine<N, P>.AStarState state, int maxIterations) Runs the machine using the givenAStarMachine<N extends AStarNode,
'sP extends Plan>.AStarState AStarStorage
.Runs the machine until a plan is either found or cannot be generated.Runs the machine fully until the iteration limit has been exceeded.void
setStorageSupplier
(Supplier<AStarStorage> newSupplier) Sets theSupplier
to use to generate instances ofAStarStorage
for use while searching.
-
Method Details
-
getStateFor
Creates anAStarMachine<N extends AStarNode,
that can be reused across multiple invocations of {P extends Plan>.AStarState run(AStarState, int)
. -
run
Runs theAStarMachine<N extends AStarNode,
until a plan is found.P extends Plan>.AStarState - Parameters:
state
- The state to use- Returns:
- The generated
Plan
, ornull
- See Also:
-
run
Runs the machine using the givenAStarMachine<N extends AStarNode,
'sP extends Plan>.AStarState AStarStorage
. Can be used to provide a continuation style usage of the A* algorithm.- Parameters:
state
- The state to usemaxIterations
- The maximum number of iterations- Returns:
- The generated
Plan
, ornull
if not found
-
runFully
Runs the machine until a plan is either found or cannot be generated.- See Also:
-
runFully
Runs the machine fully until the iteration limit has been exceeded. This will use the supplied goal and start to generate neighbours until the goal state has been reached using the A* algorithm. -
setStorageSupplier
Sets theSupplier
to use to generate instances ofAStarStorage
for use while searching.- Parameters:
newSupplier
- The new supplier to use
-
createWithDefaultStorage
Creates an AStarMachine usingSimpleAStarStorage
as the storage backend.- Returns:
- The created instance
-
createWithStorage
public static <N extends AStarNode,P extends Plan> AStarMachine<N,P> createWithStorage(Supplier<AStarStorage> storageSupplier) Creates an AStarMachine that uses the given
to createAStarStorage
instances.- Parameters:
storageSupplier
- The storage supplier- Returns:
- The created instance
-