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
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic <N extends AStarNode,P extends Plan>
AStarMachine<N, P> Creates an AStarMachine usingSimpleAStarStorageas the storage backend.static <N extends AStarNode,P extends Plan>
AStarMachine<N, P> createWithStorage(Supplier<AStarStorage> storageSupplier) Creates an AStarMachine that uses the givento createAStarStorageinstances.getStateFor(AStarGoal<N> goal, N start) Creates anAStarMachine.AStarStatethat can be reused across multiple invocations of {run(AStarState, int).run(AStarMachine.AStarState<N> state) Runs theAStarMachine.AStarStateuntil a plan is found.run(AStarMachine.AStarState<N> state, int maxIterations) Runs the machine using the givenAStarMachine.AStarState'sAStarStorage.Runs the machine until a plan is either found or cannot be generated.Runs the machine fully until the iteration limit has been exceeded.voidsetStorageSupplier(Supplier<AStarStorage> newSupplier) Sets theSupplierto use to generate instances ofAStarStoragefor use while searching.
-
Method Details
-
getStateFor
Creates anAStarMachine.AStarStatethat can be reused across multiple invocations of {run(AStarState, int). -
run
Runs theAStarMachine.AStarStateuntil a plan is found.- Parameters:
state- The state to use- Returns:
- The generated
Plan, ornull - See Also:
-
run
Runs the machine using the givenAStarMachine.AStarState'sAStarStorage. 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, ornullif 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 theSupplierto use to generate instances ofAStarStoragefor use while searching.- Parameters:
newSupplier- The new supplier to use
-
createWithDefaultStorage
Creates an AStarMachine usingSimpleAStarStorageas 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 givento createAStarStorageinstances.- Parameters:
storageSupplier- The storage supplier- Returns:
- The created instance
-