Passengers/Mail with Specific Destinations

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
TolgaAbaci
Engineer
Engineer
Posts: 46
Joined: 31 Jul 2004 21:56

Passengers/Mail with Specific Destinations

Post 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
User avatar
Darkvater
Tycoon
Tycoon
Posts: 3053
Joined: 24 Feb 2003 18:45
Location: Hong Kong

Re: Passengers/Mail with Specific Destinations

Post 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.
TrueLight: "Did you bother to read any of the replies, or you just pressed 'Reply' and started typing?"
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."
User avatar
lucaspiller
Tycoon
Tycoon
Posts: 1228
Joined: 18 Apr 2004 20:27

Post 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.
No longer active here, but you can still reach me via email: luca[at]stackednotion[dot]com
TolgaAbaci
Engineer
Engineer
Posts: 46
Joined: 31 Jul 2004 21:56

Post 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
TolgaAbaci
Engineer
Engineer
Posts: 46
Joined: 31 Jul 2004 21:56

Post by TolgaAbaci »

I forgot to add: I will upload a patch soon. I just want to test it a bit more.
User avatar
Villem
Tycoon
Tycoon
Posts: 3310
Joined: 28 Aug 2003 09:38

Post by Villem »

How are you gona handle trains that got more than 2 destinations, and train got passengers to em all?
TolgaAbaci
Engineer
Engineer
Posts: 46
Joined: 31 Jul 2004 21:56

Post 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.
kemkim
Engineer
Engineer
Posts: 53
Joined: 26 Jul 2004 20:24
Location: Helsinki, Finland

Post 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?
TolgaAbaci
Engineer
Engineer
Posts: 46
Joined: 31 Jul 2004 21:56

Post by TolgaAbaci »

kemkim wrote: Will you upload an .exe file for us to test that new feature?
Very soon. Probably tomorrow.
User avatar
Hadez
Traffic Manager
Traffic Manager
Posts: 217
Joined: 22 Jul 2004 21:25
Location: Jablonec nad Nisou, Czech republic
Contact:

Post 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?
TolgaAbaci
Engineer
Engineer
Posts: 46
Joined: 31 Jul 2004 21:56

Post by TolgaAbaci »

Hadez wrote:Can you upload some screenshots?
Here is something for you.
Attachments
Branley Transport, 31st Mar 1950.PNG
(247.92 KiB) Downloaded 3884 times
User avatar
lucaspiller
Tycoon
Tycoon
Posts: 1228
Joined: 18 Apr 2004 20:27

Post by lucaspiller »

Ooooh, that looks good. :wink:
No longer active here, but you can still reach me via email: luca[at]stackednotion[dot]com
User avatar
Hadez
Traffic Manager
Traffic Manager
Posts: 217
Joined: 22 Jul 2004 21:25
Location: Jablonec nad Nisou, Czech republic
Contact:

Post 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 :( )
TolgaAbaci
Engineer
Engineer
Posts: 46
Joined: 31 Jul 2004 21:56

Post 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.
Attachments
Hunhattan Transport, 8th Aug 1950.PNG
(277.72 KiB) Downloaded 3315 times
ChrisCF
Transport Empire Developer
Transport Empire Developer
Posts: 3608
Joined: 26 Dec 2002 16:39
Location: Over there --->

Post 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.
User avatar
Magic_Pixel
Engineer
Engineer
Posts: 80
Joined: 29 Jul 2004 07:56
Location: Tulcea/Bucharest, Romania
Contact:

Post 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
TolgaAbaci
Engineer
Engineer
Posts: 46
Joined: 31 Jul 2004 21:56

Post 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.
TolgaAbaci
Engineer
Engineer
Posts: 46
Joined: 31 Jul 2004 21:56

Post 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.
User avatar
Hadez
Traffic Manager
Traffic Manager
Posts: 217
Joined: 22 Jul 2004 21:25
Location: Jablonec nad Nisou, Czech republic
Contact:

Post 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!
User avatar
Darkvater
Tycoon
Tycoon
Posts: 3053
Joined: 24 Feb 2003 18:45
Location: Hong Kong

Post 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 ;)
TrueLight: "Did you bother to read any of the replies, or you just pressed 'Reply' and started typing?"
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 26 guests