jfreerails.controller
Class SimpleAStarPathFinder

java.lang.Object
  extended by jfreerails.controller.SimpleAStarPathFinder
All Implemented Interfaces:
java.io.Serializable, IncrementalPathFinder

public class SimpleAStarPathFinder
extends java.lang.Object
implements java.io.Serializable, IncrementalPathFinder

A simple A* pathfinder implementation. It uses int's to avoid the cost of object creation and garbage collection. 26-Nov-2002

Author:
Luke Lindsay
See Also:
Serialized Form

Field Summary
private  int bestPath
           
private  int bestPathF
           
private  java.util.HashMap<java.lang.Integer,java.lang.Integer> closedList
           
private  GraphExplorer explorer
           
private static java.util.logging.Logger logger
           
private  OpenList openList
           
private  IntArray path
          Note, IntArray is not Serializable.
private  long searchStartTime
           
private static long serialVersionUID
           
private  java.util.HashMap<java.lang.Integer,java.lang.Integer> shortestPath
           
private  java.util.HashSet<java.lang.Integer> startingPositions
           
private  int status
           
 
Fields inherited from interface jfreerails.controller.IncrementalPathFinder
PATH_FOUND, PATH_NOT_FOUND, SEARCH_NOT_STARTED, SEARCH_PAUSED
 
Constructor Summary
SimpleAStarPathFinder()
           
 
Method Summary
 void abandonSearch()
           
 IntArray findpath(int[] currentPosition, int[] targets, GraphExplorer e)
           
 int findstep(int currentPosition, int[] targets, GraphExplorer tempExplorer)
           
 int getStatus()
           
 IntArray retrievePath()
           
 void search(long maxDuration)
           
 void setupSearch(int[] currentPosition, int[] targets, GraphExplorer e)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

logger

private static final java.util.logging.Logger logger

openList

private OpenList openList

startingPositions

private final java.util.HashSet<java.lang.Integer> startingPositions

closedList

private final java.util.HashMap<java.lang.Integer,java.lang.Integer> closedList

shortestPath

private final java.util.HashMap<java.lang.Integer,java.lang.Integer> shortestPath

status

private int status

path

private transient IntArray path
Note, IntArray is not Serializable.


bestPath

private int bestPath

bestPathF

private int bestPathF

explorer

private GraphExplorer explorer

searchStartTime

private long searchStartTime
Constructor Detail

SimpleAStarPathFinder

public SimpleAStarPathFinder()
Method Detail

getStatus

public int getStatus()
Specified by:
getStatus in interface IncrementalPathFinder

retrievePath

public IntArray retrievePath()

findstep

public int findstep(int currentPosition,
                    int[] targets,
                    GraphExplorer tempExplorer)

findpath

public IntArray findpath(int[] currentPosition,
                         int[] targets,
                         GraphExplorer e)
                  throws PathNotFoundException
Throws:
PathNotFoundException

search

public void search(long maxDuration)
            throws PathNotFoundException
Specified by:
search in interface IncrementalPathFinder
Throws:
PathNotFoundException

setupSearch

public void setupSearch(int[] currentPosition,
                        int[] targets,
                        GraphExplorer e)
                 throws PathNotFoundException
Throws:
PathNotFoundException

abandonSearch

public void abandonSearch()
Specified by:
abandonSearch in interface IncrementalPathFinder