Global Pathfinding
Really getting around...
The Pathfinder is a new system that is capable of building a Path
that can traverse across the game world, handling the majority of teleports and transports.
Ideally, only one Pathfinder instance should be created per bot session - this instance registers a few listeners with the EventDispatcher, and is responsible for monitoring the context used to build paths. This context tracks things like the items you have on your character, the quests it has completed, and other essential information for finding the most optimal path.
Pathfinding
The bot can use two different algorithms to calculate paths, Dijkstra's and A*. Dijkstra's Algorithm should always return the shortest path, but that accuracy comes at the cost of speed. A* is a more efficient algorithm, but may result in less accurate paths. The default algorithm used is A*.
Walking
As you will see in the usage guide, the Path computed by findPath() is fully re-usable until it is invalidated (either by straying too far from it, or being unable to continue along it). The last Path generated will be accessible via Pathfinder#getLastPath().
As with other Path implementations, TraversalOptions can be passed to the step() method to change the walking behavior. For example, passing TraversalOption.USE_DIRECT_INPUT will allow the walking API to use Direct Input.
Usage
The library is automatically added to your project when using the RuneMate Gradle plugin (from v1.4.X).
The recommended approach is to create and store an instance of Pathfinder in your bot main class (or some other path management class) and ensuring that you only create one instance per instance of your bot.
The PathBuilder (via Pathfinder#pathBuilder()) allows for both the start and destination position(s) to be configured, as well as configuring the transports/teleports that are accessible to the pathfinding algorithm. Most notable of these is the #poh() method which configures the pathfinder with the teleports available when using the player's POH.
Here is an example usage:
The Pathfinder must not be created before onStart, as it needs to register listeners to track context.
Contributing
Similar to the Game API, the Pathfinder API is fully open-source, and the code can be found on the RuneMate Community GitLab. We encourage developers to submit changes as required to expand our coverage of the game map.
Last updated