-
-
Notifications
You must be signed in to change notification settings - Fork 27
PathfinderFactory
The entry point. We use a standard Factory Pattern so you don't have to glue your code directly to the implementation.
This abstracts the engine away. If we ever decide to add a different algorithm (or if you write your own), you won't have to rewrite your entire codebase. You're welcome.
The interface is simple. Pick your poison:
-
createPathfinder()The "I trust you" option. Creates an engine with sensible defaults. Good for 99% of use cases. -
createPathfinder(PathfinderConfiguration)The "Control Freak" option. Inject your own custom configuration to fine-tune performance or break physics. -
createPathfinder(PathfinderConfiguration, PathfinderInitializer)The "Deep Integration" option. Used for complex post-creation setup. You probably don't need this.
Currently, Pathetic provides A*. Why? Because it's the best. If you want Dijkstra, go read a history book.
// 1. Get the factory
PathfinderFactory factory = new AStarPathfinderFactory();
// Option A: Vanilla (Fast & Simple)
Pathfinder simple = factory.createPathfinder();
// Option B: Custom (For edge cases)
PathfinderConfiguration customConfig = PathfinderConfiguration.builder()
.maxLength(500) // Don't search forever
.neighborStrategy(NeighborStrategies.VERTICAL_AND_HORIZONTAL) // No diagonals
.build();
Pathfinder custom = factory.createPathfinder(customConfig);