Cargo Distribution Destination Generation Change

Got an idea for OpenTTD? Post it here!

Moderator: OpenTTD Developers

Post Reply
Drummer17198
Engineer
Engineer
Posts: 9
Joined: 27 Jul 2013 00:44

Cargo Distribution Destination Generation Change

Post by Drummer17198 »

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.

Image

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.

Image

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.
Eddi
Tycoon
Tycoon
Posts: 8257
Joined: 17 Jan 2007 00:14

Re: Cargo Distribution Destination Generation Change

Post by Eddi »

Drummer17198 wrote:Most people who travel don't take buses just to go 3 city blocks
i highly dispute this statement. "most people" will travel to get to work and back, which is often in the same city.

the way i see it, the current distance setting has two problems:
  1. it is totally unclear how much of an impact this has. what does "100%" actually mean?
  2. it is unified between passengers and cargo, but often you want to differentiate here. with cargo you most likely want to have a uniform distribution independent of distance, while for passengers you might want to increase the effect of demand to take pressure off your (almost certainly) overcrowded network.
on other topic: your graphs are probably nonsense, because with each distance increase, there are (probably) more and more stations to cover. (unless your "network" is simply a straight line), and cargodist calculates the demand on a per-station basis, not a per-distance basis.
Drummer17198
Engineer
Engineer
Posts: 9
Joined: 27 Jul 2013 00:44

Re: Cargo Distribution Destination Generation Change

Post by Drummer17198 »

Eddi wrote:i highly dispute this statement. "most people" will travel to get to work and back, which is often in the same city.
I guess it depends what you're looking for. CargoDist to me has always been about adding realism about how cargo actually behaves and thus the burden is not on the transport company for travel that short. It would be intriguing to see people get on a city bus to go 3 blocks. Across town, sure, but that would likely by at least 10 in-game tiles, which would typically fall into a category that sees some demand by way of this method.
Eddi wrote:on other topic: your graphs are probably nonsense, because with each distance increase, there are (probably) more and more stations to cover. (unless your "network" is simply a straight line), and cargodist calculates the demand on a per-station basis, not a per-distance basis.
I haven't found it in the code (as I said before) but from my calculations of in-game actions, the summation of the demand to each station of equal distance does seem to add up to a over-arching distribution existing that CargoDist does adhere to. I am fully aware that the main factor is by the draw of the station, especially in any kind of symmetrical mode.

I would actually use that as a point to support the way this distribution method would work, because it emphasizes the mid- to mid-long distance that you likely have many stations to split the volume of cargo.

I super appreciate your feedback and I think that having a conversation about what people would expect is great and important, although until someone can fully explain the coding that makes CargoDist work, we may all be very wrong lol
Drummer17198
Engineer
Engineer
Posts: 9
Joined: 27 Jul 2013 00:44

Re: Cargo Distribution Destination Generation Change

Post by Drummer17198 »

Image

Here is a table that shows the % of cargo sent across varying distance ranges based on changing the parameters of the Gamma distribution just for more examination. It shows how the user could change settings to tailor the game to their liking. Someone who wants to play a very long game would be into option 4,50 or someone playing a short game would play 2,30. A short balance would be found at 2,40 or 2,50.

3,30 and 3,40 and 4,30 are pretty mid-range heavy, with 3,40 looking to have one of the best balances across distances for a mid-range game.
Post Reply

Return to “OpenTTD Suggestions”

Who is online

Users browsing this forum: No registered users and 5 guests