From 5ea4eaabf143ea11bd8d52e00ede02c640e21c86 Mon Sep 17 00:00:00 2001 From: ptaillandier Date: Wed, 1 Sep 2021 18:43:37 +0700 Subject: [PATCH] fixes an issue with randomdrive and road without any following roads --- .../src/simtools/gaml/extensions/traffic/DrivingSkill.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/simtools.gaml.extensions.traffic/src/simtools/gaml/extensions/traffic/DrivingSkill.java b/simtools.gaml.extensions.traffic/src/simtools/gaml/extensions/traffic/DrivingSkill.java index 8ea98de608..a9ea5b679b 100644 --- a/simtools.gaml.extensions.traffic/src/simtools/gaml/extensions/traffic/DrivingSkill.java +++ b/simtools.gaml.extensions.traffic/src/simtools/gaml/extensions/traffic/DrivingSkill.java @@ -1328,7 +1328,7 @@ public void primDriveRandom(final IScope scope) throws GamaRuntimeException { IAgent initNode = null; // initialize vehicle's location - if (getNextRoad(vehicle) == null) { + if (getCurrentRoad(vehicle) == null) { IList nodes = graph.getVertices(); IShape shape = Queries.closest_to(scope, nodes, vehicle); initNode = shape.getAgent(); @@ -1616,6 +1616,7 @@ private void moveAcrossRoads(final IScope scope, return; } else if (loc.equals(targetLoc)) { // Intermediate node in path IAgent newRoad = getNextRoad(vehicle); + if (newRoad == null) return; GamaPoint srcNodeLoc = (GamaPoint) RoadSkill.getSourceNode(newRoad).getLocation(); boolean violatingOneway = !loc.equals(srcNodeLoc); // check traffic lights and vehicles coming from other roads