From 504d69b26a1be53aa4e6121685eda395ff10e47c Mon Sep 17 00:00:00 2001 From: pwarszawski Date: Sat, 10 Oct 2026 23:39:19 +0200 Subject: [PATCH] AI braking: keep braking for a lower speed inside the proximity range Inside the proximity range only a stop had a final approach of its own; for a lower speed ahead that branch set nothing, so AccDesired stayed at the preferred acceleration. With the range at 50 m, which this PR uses so that trains stop 8-15 m short of a signal, the AI stopped braking within the last 50 m before a speed restriction and even took power: EMUs reached a 20 km/h restriction at 25 km/h. On master the range is 15-40 m, which kept this mostly out of sight. A lower speed ahead now keeps the braking curve right up to where it begins. Stops are unchanged. Measured in real time on current master (with #199), with a 20 km/h restriction one coach long, two runs of 32 consists each: over 22 km/h in the restriction on the flat 9 on master, 15 before this change, 1 after (a 36WEa at 22.1 km/h); on the 20 per mille descent 15, 0 and 0. Stops 8-15 m short of the signal stay as they were (flat 57 and 55 of 64, descent 44 and 42), no overruns. --- vehicle/Driver.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vehicle/Driver.cpp b/vehicle/Driver.cpp index c0e78b7c..a5272b39 100644 --- a/vehicle/Driver.cpp +++ b/vehicle/Driver.cpp @@ -7518,7 +7518,10 @@ TController::adjust_desired_speed_for_target_speed( double const Range ) { } else if (ActualProximityDist > fMinProximityDist) { // jedzie szybciej, niż trzeba na końcu ActualProximityDist, ale jeszcze jest daleko - if (ActualProximityDist < fMaxProximityDist) { + // only a stop has a final approach of its own inside the proximity range; a lower speed ahead + // keeps the braking curve below right up to where it begins, or the train would stop braking + // (and even take power) that far out + if( ( VelNext == 0.0 ) && ( ActualProximityDist < fMaxProximityDist ) ) { // jak minął już maksymalny dystans po prostu hamuj (niski stopień) // ma stanąć, a jest w drodze hamowania albo ma jechać /*