public double GetAcceleration(Car car, Car next, ITrack track) { var distance = track.Distance(car, next); if (distance < ComfortDistance) { _targetVelocity = next.Velocity / 2; } if (distance > ComfortDistance * 5) { _targetVelocity = _comfortVelocity; } var a = (_targetVelocity - car.Velocity); if (a > MaxAceleration) a = MaxAceleration; if (a < -MaxAceleration) a = -MaxAceleration; return a; }