public void changeLanes(StreetMobilityInfo smi, Integer id) { if (DEBUG) { System.out.println("Node " + id + ": Beginning to change lanes!"); } int nextLane = -1; LaneChangeInfo lci = new LaneChangeInfo(); LinkedList nextLaneList; // set state info lci.changeTime = smi.extraSpeed * speedFactor + LANE_CHANGE_TIME; if (lci.changeTime < MIN_CHANGE_TIME) lci.changeTime = MIN_CHANGE_TIME; if (lci.changeTime > MAX_CHANGE_TIME) lci.changeTime = MAX_CHANGE_TIME; lci.remainingTime = lci.changeTime; // pick lane (prefer left lane) if (safeLeft) { lci.toLeft = true; nextLane = smi.current.getLane(smi.currentLane) - 1; } else { lci.toLeft = false; nextLane = smi.current.getLane(smi.currentLane) + 1; } // store state laneChangers.put(id, lci); // add car to new lane, but don't remove from old while changing smi.current.addToLane(smi, nextLane); nextLaneList = smi.current.getLanes(smi)[nextLane]; lci.nextLane = nextLane; lci.nextCar = getNextCar(nextLaneList, smi); updateLaneChangeInfo(smi, lci); }