[patch] Vehicle efficiency and cargo-tiles transported
Posted: 11 Feb 2018 12:34
Since first playing with Cargodist and transfer credits enabled, the false negative profits on slow vehicles in end legs have been a huge problem for me. Especially since they affect your performance rating, making the "Min. profit" element near-impossible to achieve.
So what other measures of "is this vehicle useful" could one make? How about, actual cargo amount over distance transported, compared to the potential cargo amount over distance it could have transported?
This patch adds an "Efficiency" statistic to all vehicles. The statistic is calculated based on "delivered cargo-tiles past year" divided by "potential cargo-tiles past year".
The two statistics are derived as follows:
- Delivered cargo-tiles is updated whenever the vehicle unloads cargo at a station, regardless of whether it's a transfer or a final delivery. The count of cargo-units unloaded is multiplied by the (Manhattan) distance between the pick-up station and the unload station, to get a cargo-tiles value.
- Potential cargo-tiles is updated both while a vehicle is traveling, and also while it's sitting idle at a station not active loading/unloading cargo. It multiplies total cargo capacity of a vehicle with distance actually traveled, or in the case of idling at a station the potential distance traveled.
These calculations lead to the following effects:
- Vehicles always running full will have (approximately) 100% efficiency rating.
- Goods vehicles only transporting cargo in one direction, and returning empty, will have efficiency around 50%.
- Vehicles running on "scenic" routes, that take more turns back and forth than necessary, will have lower efficiency, because delivered distance is as the bird flies, while potential distance is actual traveled distance.
- Having too many vehicles servicing a route will mean either running empty, or waiting for full load without receiving cargo, and will lower efficiency drastically.
As implemented right now, the calculation may be overly cruel, and probably needs tweaking.
The efficiency rating is also available in the vehicle list, and you can sort by it.
And, perhaps the part of this patch with the most potential for controversy: The performance rating is now calculated based not on worst vehicle profit, but on worst vehicle efficiency.
However I've prepared for making it a game setting, whether to use one or the other
As for the patch code itself, this is my first time hacking on OpenTTD, so there may be things that should be done differently. Please critique my code.
So what other measures of "is this vehicle useful" could one make? How about, actual cargo amount over distance transported, compared to the potential cargo amount over distance it could have transported?
This patch adds an "Efficiency" statistic to all vehicles. The statistic is calculated based on "delivered cargo-tiles past year" divided by "potential cargo-tiles past year".
The two statistics are derived as follows:
- Delivered cargo-tiles is updated whenever the vehicle unloads cargo at a station, regardless of whether it's a transfer or a final delivery. The count of cargo-units unloaded is multiplied by the (Manhattan) distance between the pick-up station and the unload station, to get a cargo-tiles value.
- Potential cargo-tiles is updated both while a vehicle is traveling, and also while it's sitting idle at a station not active loading/unloading cargo. It multiplies total cargo capacity of a vehicle with distance actually traveled, or in the case of idling at a station the potential distance traveled.
These calculations lead to the following effects:
- Vehicles always running full will have (approximately) 100% efficiency rating.
- Goods vehicles only transporting cargo in one direction, and returning empty, will have efficiency around 50%.
- Vehicles running on "scenic" routes, that take more turns back and forth than necessary, will have lower efficiency, because delivered distance is as the bird flies, while potential distance is actual traveled distance.
- Having too many vehicles servicing a route will mean either running empty, or waiting for full load without receiving cargo, and will lower efficiency drastically.
As implemented right now, the calculation may be overly cruel, and probably needs tweaking.
The efficiency rating is also available in the vehicle list, and you can sort by it.
And, perhaps the part of this patch with the most potential for controversy: The performance rating is now calculated based not on worst vehicle profit, but on worst vehicle efficiency.
However I've prepared for making it a game setting, whether to use one or the other
As for the patch code itself, this is my first time hacking on OpenTTD, so there may be things that should be done differently. Please critique my code.