Page 1 of 35

Passengers/Mail with Specific Destinations

Posted: 31 Jul 2004 22:25
by TolgaAbaci
Hello everybody, this is my first post here in TT-forums.

Couple of days ago, I checked-out the source of OTTD, and started to work on a new, optional feature for enabling passengers/mail to choose their destinations (like in Simutrans). I believe this will add more depth to the gameplay and make it more interesting to build a large passenger transport network with many cities. To me, it felt always a bit stupid that passengers were willing to go whereever you would take them.

It looked like there was no-one working on this, and I know that there are some other people interested too, so I started to experiment. At the moment, it kind of works, stations are able to generate passengers for different destinations and trains (or other vehicles, but untested) are able to carry them to their destinations. In case there is interest, I can explain more in detail how it is implemented. It needs quite a bit of more work, in GUIs, passenger-routing, gameplay tweaking, and save-games, about whom I have a question.

Now, this feature is optional, so if it is turned off, the game should behave exactly as before. But, it definitely requires change to the save-game format. This is because I had to modify the Vehicle and Station structs. The Vehicle struct was extended with CargoSlots, to keep track of multiple source-destination pairs. Now, the question is, is there some kind of mechanism for kind of "dynamic" save formats, that change depending on enabled features?

I would also like to hear your comments/questions/suggestions on this new feature.
-Tolga

Re: Passengers/Mail with Specific Destinations

Posted: 01 Aug 2004 00:01
by Darkvater
TolgaAbaci wrote:Hello everybody, this is my first post here in TT-forums.
Hello. Let me be the first one to welcome you here :D
TolgaAbaci wrote:It looked like there was no-one working on this, and I know that there are some other people interested too, so I started to experiment. ...I can explain more in detail how it is implemented. It needs quite a bit of more work, in GUIs, passenger-routing, gameplay tweaking, and save-games, about whom I have a question.
There was indeed no development in this area, so you are the first and only one making this feature. I would love to hear a simple general version of your algorithm. Does it work like in Simutrans, how do passangers choose their destinations, will they prefer a certain transportation system, etc. etc.
TolgaAbaci wrote:...it definitely requires change to the save-game format...Now, the question is, is there some kind of mechanism for kind of "dynamic" save formats, that change depending on enabled features?
The savegame is pretty static. There are a few unused bytes at the end of all structs in the savegame to allow for newer features, but not too much. It is mostly the OTTD version that tells the game what to and when to load. The savegame format might need to be upgraded, or a totally new format written with a wrapper for the old OTTD format, who knows.

Posted: 01 Aug 2004 19:09
by lucaspiller
Welcome TolgaAbaci, and congratulations. :D I attempted to start something like this a week or two ago, but my C skills are no way high enough to get anything out of it so well done. :wink:

Could you explain a bit more how it works (mainly how destinations are chosen) and maybe upload a patch for us to test?

My idea of getting it to work was each station searches for vehicles that come to it then ads the list of these destinations to a list, so then each station has a list of direct accessible routes - if you get what I mean.

To choose the destinations a random city is chosen and then a route is attempted to be found. A company station is searched for in this city, then each of these stations is searched from their destination list of the start station, if there is nothing there the lists of the stations on the list are searched. This wouldn't provide a brilliant system but when a destination is found it is added to the stations list of possible but not direct stations, these are also searched so as the game progresses you will get more and more destinations. These possible routes are also searched. If no route is found then another city is chosen.

Randomly choosing a city wouldn't be brilliant though, and it wouldn't be possible to implement a thing as in Simutrans (because that uses the factories worker list), so I was thinking of some sort of rating system. I am still not really sure how it could be brilliant though so thats about it.

This would be quite in depth and probably would provide good results, but the disadvantages are a bit too high. It would require a LOT of processing power and a lot of storage, and would probably need quite a lot of work to perfect it.

Posted: 01 Aug 2004 19:24
by TolgaAbaci
At the moment, it's quite basic.

Each station keeps track of passengers (GoodsEntry) for each possible destination station (displayed in the GUI). A station starts to accept passengers for a destination once it receives a vehicle that goes to that destination.

The number of passengers each house generates for a particular destination city depends on the population of that destination city. This total amount is then distributed among the stations in the destination city, according to the total acceptance value of the buildings around these stations.

This scheme increases the total number of passengers generated as the total number (population) of cities in the network increases. However, increasing the number of stations while the number of cities in the network remains the same does not result in higher number of passengers.

Each Vehicle has CargoSlots that keep track of passengers with different sources and destinations. Passengers only try to get on a vehicle if they can reach their destination by that vehicle. This is the relatively more complex part to implement. Right now, only the order-list of the vehicle is checked to see if the destination is in there, this means that passengers cannot transfer to different vehicles.

But, I am in the process of implementing a graph-based structure that contains all the available passenger routes. This will be used to identify possible destinations. It will also be used to select the best routes by running Dijkstra's shortest-path algorithm on it. First, I'll make some tests by using the number of stops as the parameter (all weights equal to 1). Then, we can experiment with different, dynamic weighting schemes to introduce more variety in passenger choices.

But before implementing all that, I need to find a solution to the save-game problem, since it will be difficult to make all those tests without being able to save the games.

-Tolga

Posted: 01 Aug 2004 19:30
by TolgaAbaci
I forgot to add: I will upload a patch soon. I just want to test it a bit more.

Posted: 01 Aug 2004 19:35
by Villem
How are you gona handle trains that got more than 2 destinations, and train got passengers to em all?

Posted: 01 Aug 2004 19:55
by TolgaAbaci
Akalamanaia: This is already handled. For example, you can already connect multiple cities/stations with a line and trains can carry the passengers to their specific destinations on this line. Atm, stations will not generate passengers to a destination if a train that goes there has not passed yet.

The only thing that is not handled at the moment is the passengers transferring between vehicles. But I am working on it, as I explained in my post above.

Posted: 01 Aug 2004 20:55
by kemkim
TolgaAbaci wrote:Akalamanaia: This is already handled. For example, you can already connect multiple cities/stations with a line and trains can carry the passengers to their specific destinations on this line. Atm, stations will not generate passengers to a destination if a train that goes there has not passed yet.

The only thing that is not handled at the moment is the passengers transferring between vehicles. But I am working on it, as I explained in my post above.
Will you upload an .exe file for us to test that new feature?

Posted: 01 Aug 2004 21:12
by TolgaAbaci
kemkim wrote: Will you upload an .exe file for us to test that new feature?
Very soon. Probably tomorrow.

Posted: 02 Aug 2004 16:11
by Hadez
Good work, that's a great feature :D! I was wondering that passengers were going anywhere I wanted but I stopped minding it. Now I wonder I didn't mind it :). Can you upload some screenshots?

Posted: 02 Aug 2004 17:07
by TolgaAbaci
Hadez wrote:Can you upload some screenshots?
Here is something for you.

Posted: 02 Aug 2004 19:08
by lucaspiller
Ooooh, that looks good. :wink:

Posted: 02 Aug 2004 19:35
by Hadez
Thanks :wink:. I'll like this feature so much. But I don't know when there will be a new nightlie (svn is not working :( )

Posted: 02 Aug 2004 22:05
by TolgaAbaci
OK, another WIP screenshot showing fresh results.

Bus #1 runs between Mundstone and Medtown. Bus #2 runs between Hunhattan and Medtown. They are able to drop passengers for transfer at Medtown, e.g. a passenger who wants to go to Hunhattan from Mundstone takes Bus #1, gets off at Medtown, and boards Bus #2 to go to Hunhattan.

The scheme works for networks of any complexity, also supports transfers between different type of vehicles. The only limitation at the moment is that passengers always take the route with the least number of stops. This is simple, it does not require too much CPU time and it will work fine for most networks. We can experiment with more complicated schemes later.

At the moment, the routing will screw up if you delete orders from a vehicle or the vehicle itself. This is not difficult to fix, but I haven't had time yet.

Posted: 02 Aug 2004 23:30
by ChrisCF
Very nice work. I'm drooling already. :)

Is it coded in a way that extending it to other cargoes might be possible, particularly goods? As we all know, goods from a factory typically go to more than just the local area.

Posted: 03 Aug 2004 06:46
by Magic_Pixel
Very nice work indeed. And it's also good that it is optional, 'coz I've seen complaints about this kind of micromanagement from people who think this is too complicated/boring. Even the devs didn't look very interested about this. (No offence).

Complicated or not, personally I LOVE IT and I was hoping one day someone will make this game even spicier. (I can imagine how this works with some bigger maps.. yummy!.. :) )

Keep up the good work

Posted: 03 Aug 2004 07:06
by TolgaAbaci
ChrisCF wrote:Is it coded in a way that extending it to other cargoes might be possible, particularly goods? As we all know, goods from a factory typically go to more than just the local area.
Yes. It should be straightforward to extend for mail & goods.

Posted: 03 Aug 2004 07:15
by TolgaAbaci
Magic_Pixel wrote:And it's also good that it is optional, 'coz I've seen complaints about this kind of micromanagement from people who think this is too complicated/boring. Even the devs didn't look very interested about this. (No offence).
This is probably also why we should keep the passenger generation/routing scheme simple. The more complicated schemes are computationally expensive and difficult to implement, but I am not sure whether they would be still fun to play.

Posted: 03 Aug 2004 08:34
by Hadez
My opinion on this feature now is: great :D! I hope I'll see it in my game a.s.a.p. Great work!

Posted: 03 Aug 2004 09:44
by Darkvater
As long as it can completely be disabled by a switch, and I mean COMPLETELY, I have no problems of adding this to the code. TolgaAbaci will then be the responsible person handling all bugs and improvements to that code.

I said completely not because I dislike the feature, which I like, but because other developers don't like the idea and certainly would frown upon things being changed.

Of course if you have in the meantime clarified&optimized the old passanger generation, etc. code, we won't have trouble adding that part ;)