001/*
002 * This file is part of Baritone.
003 *
004 * Baritone is free software: you can redistribute it and/or modify
005 * it under the terms of the GNU Lesser General Public License as published by
006 * the Free Software Foundation, either version 3 of the License, or
007 * (at your option) any later version.
008 *
009 * Baritone is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012 * GNU Lesser General Public License for more details.
013 *
014 * You should have received a copy of the GNU Lesser General Public License
015 * along with Baritone.  If not, see <https://www.gnu.org/licenses/>.
016 */
017
018package baritone.api.pathing.calc;
019
020import baritone.api.pathing.goals.Goal;
021import baritone.api.utils.PathCalculationResult;
022
023import java.util.Optional;
024
025/**
026 * Generic path finder interface
027 *
028 * @author leijurv
029 */
030public interface IPathFinder {
031
032    Goal getGoal();
033
034    /**
035     * Calculate the path in full. Will take several seconds.
036     *
037     * @param primaryTimeout If a path is found, the path finder will stop after this amount of time
038     * @param failureTimeout If a path isn't found, the path finder will continue for this amount of time
039     * @return The final path
040     */
041    PathCalculationResult calculate(long primaryTimeout, long failureTimeout);
042
043    /**
044     * Intended to be called concurrently with calculatePath from a different thread to tell if it's finished yet
045     *
046     * @return Whether or not this finder is finished
047     */
048    boolean isFinished();
049
050    /**
051     * Called for path rendering. Returns a path to the most recent node popped from the open set and considered.
052     *
053     * @return The temporary path
054     */
055    Optional<IPath> pathToMostRecentNodeConsidered();
056
057    /**
058     * The best path so far, according to the most forgiving coefficient heuristic (the reason being that that path is
059     * most likely to represent the true shape of the path to the goal, assuming it's within a possible cost heuristic.
060     * That's almost always a safe assumption, but in the case of a nearly impossible path, it still works by providing
061     * a theoretically plausible but practically unlikely path)
062     *
063     * @return The temporary path
064     */
065    Optional<IPath> bestPathSoFar();
066}