Commit 99d40599 authored by Julian Zobel's avatar Julian Zobel
Browse files

Bugfix in alternative routing for realworld street movement.

parent db095e8a
......@@ -246,14 +246,23 @@ public class RealWorldStreetsMovement extends AbstractLocalMovementStrategy {
// alternatives for routing are allowed for distances bigger than 50
if(allowAlternativeRoutes && rsp.hasAlternatives() && rsp.getBest().getDistance() > 50) {
// alternative route is taken with a certain chance
if(random.nextDouble() <= probabilityForAlternativeRoute) {
List<PathWrapper> paths = rsp.getAll();
int pick = random.nextInt(paths.size() - 1) + 1;
pointList = rsp.getAll().get(pick).getPoints();
if(random.nextDouble() <= probabilityForAlternativeRoute) {
List<PathWrapper> paths = rsp.getAll();
// remove the best, we do not want this!
paths.remove(rsp.getBest());
PathWrapper choice;
if(paths.size() == 1) {
choice = paths.get(0);
}
else {
choice = paths.get(random.nextInt(paths.size() - 1) + 1);
}
pointList = choice.getPoints();
}
}
//PointList pointList = rsp.getBest().getPoints();
}
if (isCalculateRouteSegments()) {
/*
......@@ -262,7 +271,7 @@ public class RealWorldStreetsMovement extends AbstractLocalMovementStrategy {
trajectory = new RouteImpl(comp.getRealPosition(),
destination, pointList,
routeSensor.getSegmentListeners(), routeSensor,
calculateSegments(rsp.getBest()));
calculateSegments(pointList));
} else {
trajectory = new RouteImpl(comp.getRealPosition(),
destination, pointList);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment