The crash was in a method of traincar.cs, and the cause was that the collection had changed during a loop operation. Apparantly, some part of the program was calculating something for a full train, while another part was detaching or attaching from or to that train. Should not really be possible, but it's just bad luck. Reran from the last save and the problem did not reoccur.
But that was not what shocked me. What had me completely baffled was the calculation where the program crashed.
It was a method named : UpdateTrainDerailmentRisk
Yes, in case you thought you misread this, it did indeed say Derailment Risk. Calculation derailment risk for AI trains? Really? :wtf01: :unknw:
Obviously, there is no intention whatsoever to derail an AI train, nomatter how the program makes it run. If the route is set up that the speed limit is 200 mph through a 100m radius curve, then that AI train will run through that curve at that speed.
So why on earth are we wasting CP time on calculations that have no use whatsoever?
And this is not the only one. There are a few more :
- Brake pressure propagation
- Coupler slack
- Drag resistance
And that's probably not all.
Now, don't get me wrong - I'm NOT saying that these calculations itself are useless. These are very sophisticated calculations which all increase the reality of the train performance - for the player train.
But, the AI train control is just basically 'rough and ready'. The 'proper' physics are first tried, increasing throttle to move the train, and applying brakes to stop it. But if the train does not react to this within the required time, the program intervenes and just moves or stops the train.
So, take for instance that brake pressure propagation. Suppose an AI train is applying the brakes as it approaches a signal at danger. The brake pressure propagation is neatly calculated using pipe diameter and who knows what other details. It calculates the resulting pressure, and with that the brake power, for each car in the train. But that train WILL STOP at that signal, regardless whether or not the brake pressure has been propagated or not. So what sense in calculating the pressure with this much detail? None, as it will not in any way affect the way the train will stop.
To make things worse - AI trains are not actually using all the new detailed parameters introduced to .eng and .wag files. Instead, they use default settings which are just as basic as the AI control itself.
So, I dare say that none of the outcome of all these calculations is used anywhere within the AI train control.
So here is my plea. Could those with knowledge of this part of the program - physics and control - have a good look at all these wonderfull calculations, and check on how usefull these are for AI trains? Most, I think, have no use at all.
So, with brake pressure propagation again as example, the present calculation must of course be maintained for the player train, but for AI trains it could just be made instantaneous. Might even improve AI train behaviour, as the train will react better to brakes being applied.
Something similar could be applied to other calculations as well.
And, of course, for that calculation of derailment risk for AI trains - could that be removed by tomorrow?
Regards,
Rob Roeterdink