For some reason, there are crashes due to mergers. The merging logic has changed quite a fair bit in the (upcoming) recent commit, so it may be due to that. In any case, in order to try and catch it, I've added a few debugging methods to Car (see, Car.debugcounter) and VisualSimulation - after the 10th crash, it will follow that car along. It hasn't been of great help, because the debugged car seems to be stacked on top of another car, but again, needs further investigation.
Changes to the merging logic:
Reworked the function so that if there's only 1 car in the desired lane, the indices will be [0,0] to scan, but [1,1] to replace
Implemented scaling of the "slamming break distance" with respects to a car's desired velocity. They will be more eager to overtake if they want to go fast (caring less about the car behind em slamming brakes) and less eager to merge (caring more of being forced to slam their brakes) [*]
Replaced the exponential scale factor of safety distance with a linear one - thinking it would help. It reduced the number of crashes (it was really bad before) but didn't fix it. Does however fix some major rubberbanding issues that cars would have even on one lane, where they would steadfastly refuse to break until they almost crash into the slow car in front of them.
Replaced the slamming break distance logic with the inbuilt Car.inDist function. Maybe this is where it went wrong
[] now that I write this, I think maybe we could implement an if statement, if the othercar's velocity is simply slower than the desired velocity (scaled to, say, 90%), then we don't merge. It would prevent rubberbanding. OTOH it would mean during times of traffic where everyone's slow, the fast lane ends up being congested.*
For some reason, there are crashes due to mergers. The merging logic has changed quite a fair bit in the (upcoming) recent commit, so it may be due to that. In any case, in order to try and catch it, I've added a few debugging methods to Car (see, Car.debugcounter) and VisualSimulation - after the 10th crash, it will follow that car along. It hasn't been of great help, because the debugged car seems to be stacked on top of another car, but again, needs further investigation.
Changes to the merging logic:
[] now that I write this, I think maybe we could implement an if statement, if the othercar's velocity is simply slower than the desired velocity (scaled to, say, 90%), then we don't merge. It would prevent rubberbanding. OTOH it would mean during times of traffic where everyone's slow, the fast lane ends up being congested.*