Cargo Distribution Destination Generation Change
Posted: 03 Oct 2018 23:28
Hi y'all, this is going to be very very specific and statistical, so if you're not into stats, this isn't the thread for you.
I tried to read the source code on cargo dist to determine how it generates the trip for each unit of cargo that is spawned, but I absolutely got nowhere. My main suggestion (conversation point?) is with the distance parameter. The setting reads "Effect of distance on demands" and describes how, when set to 0%, the distance between stations doesn't influence where the cargo will want to go and that increasing the percentage will give closer stations a preference over further stations.
My understanding of this is that, when set at 0%, the distance the cargo will travel is a random number drawn from a uniform distribution that gives all distances an equal chance at being selected. See below for what it would look like, where bar height corresponds with the amount of cargo sent that distance.
Thus, as you increase the "Effect of distance on demands" setting, you simply tilt the density to be higher on the left and lower the right like a see-saw. However, I believe there is a statistically better way to handle this that will increase the realism: drawing trip distance from the Gamma distribution.
Most people who travel don't take buses just to go 3 city blocks, and thus a straight increase of density for low-distance trips makes the game more unrealistic in that people won't hop onto trains between cities, but prefer a bus the goes 10 tiles away. As seen above, a Gamma distribution (shown are 10,000 pulls from a Gamma distribution with shape=3 and scale=50) will allow for most of the passengers to go on medium-distance trips, which would be a town or two away.
In the above draw, 0.07% of passengers traveled 1-10 tiles, which would be a ridiculously short trip. 1.36% traveled 11-25 tiles, which could be reasonable for a small amount of people, so this seems appropriate. 6.76% traveled 26-50 tiles, which would be from a city to a suburb or between close towns. 24.47% traveled 51-100 tiles, which is a strongly common distance, equating to between two regional hubs. Similarly, 25.01% traveled 101-150 tiles, which would be again a regional intercity distance. 18.41% traveled 151-200 tiles, which would be a long intercity travel. 17.99% traveled 201-300 tiles, a 100-tile range that is just as frequent as the 50-tile range prior. Only 5.93% of passengers traveled over 300 tiles, which would make for interesting networks on the larger maps.
Settings could be put in place to adjust the shape and scale parameters of the Gamma distribution to adjust for larger maps (a shape of 4 and a scale of 50 makes the above percentage breakdowns: 0.02%, 0.14%, 2.16%, 12.48%, 20.58%, 21.81%, 28.21%, and 14.6% respectively and sent cargo over 600 tiles away).
Changing the shape of the distribution of cargo based on distance from station of origin could really improve the feel of the game in my opinion and I would love to talk more about it. If I was any use coding, I would definitely try to develop a mock-up patch that would accomplish this.
I tried to read the source code on cargo dist to determine how it generates the trip for each unit of cargo that is spawned, but I absolutely got nowhere. My main suggestion (conversation point?) is with the distance parameter. The setting reads "Effect of distance on demands" and describes how, when set to 0%, the distance between stations doesn't influence where the cargo will want to go and that increasing the percentage will give closer stations a preference over further stations.
My understanding of this is that, when set at 0%, the distance the cargo will travel is a random number drawn from a uniform distribution that gives all distances an equal chance at being selected. See below for what it would look like, where bar height corresponds with the amount of cargo sent that distance.
Thus, as you increase the "Effect of distance on demands" setting, you simply tilt the density to be higher on the left and lower the right like a see-saw. However, I believe there is a statistically better way to handle this that will increase the realism: drawing trip distance from the Gamma distribution.
Most people who travel don't take buses just to go 3 city blocks, and thus a straight increase of density for low-distance trips makes the game more unrealistic in that people won't hop onto trains between cities, but prefer a bus the goes 10 tiles away. As seen above, a Gamma distribution (shown are 10,000 pulls from a Gamma distribution with shape=3 and scale=50) will allow for most of the passengers to go on medium-distance trips, which would be a town or two away.
In the above draw, 0.07% of passengers traveled 1-10 tiles, which would be a ridiculously short trip. 1.36% traveled 11-25 tiles, which could be reasonable for a small amount of people, so this seems appropriate. 6.76% traveled 26-50 tiles, which would be from a city to a suburb or between close towns. 24.47% traveled 51-100 tiles, which is a strongly common distance, equating to between two regional hubs. Similarly, 25.01% traveled 101-150 tiles, which would be again a regional intercity distance. 18.41% traveled 151-200 tiles, which would be a long intercity travel. 17.99% traveled 201-300 tiles, a 100-tile range that is just as frequent as the 50-tile range prior. Only 5.93% of passengers traveled over 300 tiles, which would make for interesting networks on the larger maps.
Settings could be put in place to adjust the shape and scale parameters of the Gamma distribution to adjust for larger maps (a shape of 4 and a scale of 50 makes the above percentage breakdowns: 0.02%, 0.14%, 2.16%, 12.48%, 20.58%, 21.81%, 28.21%, and 14.6% respectively and sent cargo over 600 tiles away).
Changing the shape of the distribution of cargo based on distance from station of origin could really improve the feel of the game in my opinion and I would love to talk more about it. If I was any use coding, I would definitely try to develop a mock-up patch that would accomplish this.