src/model/pathfinding/ConcurrentPathFinder.java
@Override
    public List<Direction> computePath(int fromX, int fromY, int toX, int toY) {
        FutureTask<List<Direction>> routeTask;
        List<Direction> route = null;
        int job = Objects.hash(fromX, fromY, toX, toY);
        
        if (pendingJobs.containsKey(job)) {
            routeTask = pendingJobs.get(job);
        } else {
            routeTask = createJob(fromX, fromY, toX, toY);
        }
        
        if (routeTask.isDone()) {
            pendingJobs.remove(job);
            try {
                route = routeTask.get();
            } catch (InterruptedException | ExecutionException e) {
                log.severe("Failed to calculate path, retrying");
                route = null;
                createJob(fromX, fromY, toX, toY);
            }
        }
        
        return route;
    }
/**
     * Computes a regular path, accounting for obstructions but not agents. The first time
     * this is called, the task to compute it is sent to the thread pool. Calling this again
     * with the same parameters returns null until the job is done, at which point the route
     * is returned. Calling it again after that creates a new task.
     */
Computes a regular path, accounting for obstructions but not agents. The first time
this is called, the task to compute it is sent to the thread pool. Calling this again
with the same parameters returns null until the job is done, at which point the route
is returned. Calling it again after that creates a new task.
Computes a regular path accounting for obstructions but not agents . The first time this is called the task to compute it is sent to the thread pool . Calling this again with the same parameters returns null until the job is done at which point the route is returned . Calling it again after that creates a new task .
@Override
    public List<Direction> computePath(int fromX, int fromY, int toX, int toY) {
        FutureTask<List<Direction>> routeTask;
        List<Direction> route = null;
        int job = Objects.hash(fromX, fromY, toX, toY);
        if (pendingJobs.containsKey(job)) {
            routeTask = pendingJobs.get(job);
        } else {
            routeTask = createJob(fromX, fromY, toX, toY);
        }
        if (routeTask.isDone()) {
            pendingJobs.remove(job);
            try {
                route = routeTask.get();
            } catch (InterruptedException | ExecutionException e) {
                log.severe("Failed to calculate path, retrying");
                route = null;
                createJob(fromX, fromY, toX, toY);
            }
        }
        return route;
    }
@ Override public List < Direction > computePath ( int fromX , int fromY , int toX , int toY ) { FutureTask < List < Direction > > routeTask ; List < Direction > route = null ; int job = Objects . hash ( fromX , fromY , toX , toY ) ; if ( pendingJobs . containsKey ( job ) ) { routeTask = pendingJobs . get ( job ) ; } else { routeTask = createJob ( fromX , fromY , toX , toY ) ; } if ( routeTask . isDone ( ) ) { pendingJobs . remove ( job ) ; try { route = routeTask . get ( ) ; } catch ( InterruptedException | ExecutionException e ) { log . severe ( "Failed to calculate path, retrying" ) ; route = null ; createJob ( fromX , fromY , toX , toY ) ; } } return route ; }
Computes a regular path, accounting for obstructions but not agents.
Computes a regular path accounting for obstructions but not agents .