View Javadoc

1   package cz.cuni.amis.pogamut.ut2004.agent.navigation;
2   
3   import cz.cuni.amis.pogamut.base.agent.navigation.IPathFuture;
4   import cz.cuni.amis.pogamut.base.agent.navigation.IPathPlanner;
5   import cz.cuni.amis.pogamut.base3d.worldview.object.ILocated;
6   import cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004Bot;
7   import cz.cuni.amis.utils.exception.PogamutException;
8   
9   /**
10   * Finds the shortest through internal A* algorithm in the UT2004. The path info is send through GB2004 messages.
11   * <p><p>
12   * Returns {@link UT2004AStarPathFuture} that contains the logic for obtaining the path from UT2004 (note that it takes
13   * some time then UT2004 sends you a path).
14   * <p><p>
15   * <b>IMPORTANT:</b> Due to restrictions of the UnrealScript path planner this implementation returns only paths of maximal length 16.
16   * Therefore returned path may end on the half way trough. Therefore, whenever the {@link IPathExecutor} reports that
17   * the bot has reached its target, you should compare bot's current position and the {@link UT2004AStarPathFuture#getPathTo()}.
18   * 
19   * @author Ik
20   * @author Jimmy
21   */
22  public class UT2004AStarPathPlanner implements IPathPlanner<ILocated> {
23  
24  	private UT2004Bot bot;
25  
26  	public UT2004AStarPathPlanner(UT2004Bot bot) {
27  		this.bot = bot;
28  	}
29  	
30  	@Override
31  	public IPathFuture<ILocated> computePath(ILocated from, ILocated to) {
32  		return new UT2004AStarPathFuture(bot, from, to);
33  	}
34  	
35  	public double getDistance(ILocated from, ILocated to) {
36  		throw new PogamutException("Could not compute path-distances on the fly!", this);
37  	}
38  
39  }