Understanding CargoDist

OpenTTD is a fully open-sourced reimplementation of TTD, written in C++, boasting improved gameplay and many new features.

Moderator: OpenTTD Developers

Post Reply
JaWood
Engineer
Engineer
Posts: 4
Joined: 06 Sep 2014 13:37

Understanding CargoDist

Post by JaWood »

OK, bear with me. This is a bit convoluted and even I have to step back every so often to make sure I'm still following myself. I'm going to change my map's city names to known world cities for ease of understanding.

There are 6 cities in a large circumference: Madrid, London, Paris, Berlin, Tokyo, and Rome. In the center of the circle is a large train hub. The hub is all by itself, outside of any city influence. There are 6 rail lines radiating out from the hub, each one terminating in an end-of-the-line station for each city. There are 6 trains, one for each line, going back and forth from its respective city picking up passengers, then unloading them at the hub for transfer.

Now here's the situation I just observed that has me confused about how CargoDist really works: The train servicing Madrid pulled into the city station and picked up 48 people. The station reported right before the passengers loaded that they were going to the following destinations: 3 to Paris, 16 to London, 7 to Berlin, 18 to Rome and 4 to Tokyo. They were then dropped off at the hub (which already had several hundred people at it) but the numbers increased showing the train dropped off 40 passengers going to Rome, 8 going to Paris, and 0 going anywhere else. Still 48 passengers total, but not the same original destinations as when they boarded.

So why did the distribution change? It's now becoming clear to me why I'm struggling to balance my passenger flow and train capacities since it seems passengers change destinations mid-trip! Is this normal behavior for CargoDist? Is there a setting I can adjust to help remedy this issue?

P.S. I did notice after the fact that the unloaded numbers (40 and 8 ) correspond to the car distribution during the trip (40 passengers in the first train car [full load] and 8 in the second car). Do initial destinations generated at the station get rearranged according to the cars they load onto? Or was this just a coincidence?
Transportman
Tycoon
Tycoon
Posts: 2781
Joined: 22 Feb 2011 18:34

Re: Understanding CargoDist

Post by Transportman »

IIRC the distribution is more of an estimated average than really set in stone. If you follow multiple runs, the observed distribution should come close to the numbers CargoDist gives.
Coder of the Dutch Trackset | Development support for the Dutch Trainset | Coder of the 2cc TrainsInNML
User avatar
Kevo00
Tycoon
Tycoon
Posts: 5646
Joined: 07 Feb 2004 01:51
Location: East Coast MainLine

Re: Understanding CargoDist

Post by Kevo00 »

JaWood raises an interesting question - when you click on a train, the load screen shows that all passengers in the same car are going to the same destination. I always assumed this was just representative. But perhaps they standardise up for ease?

I would think, though, that in the situation described above things would balance out?
User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: Understanding CargoDist

Post by fonso »

The vehicle GUI only shows "from" and that's for the first passenger or piece of cargo in a car.

The "to" numbers in the station GUI are indeed an estimate. Only the "via" numbers are really determined for each passenger or piece of cargo. Cargo and passengers are handled in packets, bundling multiple of then as a single unit. We don't want to split and merge those packets too much as that makes the game slow. Cargodist never splits a packet when transferring cargo but instead sends all of its contents to the same next hop. The next hops are drawn randomly from the available next hops in such a way that in the long run a distribution as described in the "planned" tab of the vehicle GUI will manifest itself.
The guy on the picture is not me, it's Alonso.
JaWood
Engineer
Engineer
Posts: 4
Joined: 06 Sep 2014 13:37

Re: Understanding CargoDist

Post by JaWood »

Ok, so what I'm understanding is that even though individual passenger's destinations are reorganized into larger single destination "packets", everything should average out in the long run. Am I correct?
User avatar
fonso
President
President
Posts: 945
Joined: 13 Oct 2007 08:28

Re: Understanding CargoDist

Post by fonso »

Pretty much. And also this is "cargo distribution", not "cargo destinations". The passengers don't actually know their destination when they get generated. They just look at the flow table at each station they arrive at and decide where to go next. The flows are periodically replanned for the whole network. Those flows are what you see in the "planned" mode of the station GUI and that's what the distribution should average out to in the end.
The guy on the picture is not me, it's Alonso.
Post Reply

Return to “General OpenTTD”

Who is online

Users browsing this forum: No registered users and 24 guests