Template-based train replacement

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
User avatar
ffpp
Engineer
Engineer
Posts: 125
Joined: 29 Jan 2010 12:56

Template-based train replacement

Post by ffpp »

Hi,

yesterday I already talked about this on IRC and was told that there have already been lots of discussions about this. I didn't find any on the forums, though (lazy quick search).

First, for me this idea stems from the fact that I like to play games that have a continous succession through the years. I often use trainsets like the UK Renewal Set which feature weak engines. Those require short trains to work properly. And as the game progresses and better locos make longer trains feasible I usually run into the problem that I already have a lot of trains that are supposed to change in structure. So, for me the automatic engine replacement and automatic wagon removal doesn't do it.

So I'm proposing an alternative idea how to replace/change trains without too much user interference. This little draft is not final and there could be more suggestions which come to my mind yet.
  1. - the auto-replacement feature will stay as it is right now, at least for backwards compatibility with old habits.
    - in company->trains->Manage list there will be a new subpoint called 'template replacement'
    - a template should also include cargo types whereever this can be specified
    - there will be modes of replacement available:
    • - a general version to specify by template which trains to replace by another train-template
      - a more specific version that replaces all trains to match a given template
I think the latter version could be sufficient if one uses grouping in some appropriate way, but having the first mode also should be useful in the long run. Also, there might be many ways how people play this game and being more general to not limit them in those ways is definitely preferable.

The replacement gui will then be presented in a depot-like fashion, where you can build a template as you otherwise build trains in depots. Checks for feasibility (engine-wagon compatibility, ...) will be done immediatly. Such a template is then stored (and recreated upon loading the gui) automatically and there will be one template for each [group/vehicle-list]. Not 100% sure about this point. But this functionality should definitely not be limited to groups, as having to do the same template-replacement-steps for a lot of groups when it also could be done for all trains at once, would be tedious again.

There are more minor issues
  1. - where to store such a template (for each veh.list ?)
    - checking for sufficient money before replacing a whole train so that not half the train will be adjusted to the template before running out of money
    - (more ?)
I have never coded on openttd before, so I'm familiarizing myself with the code base right now. Mainly how the autoreplacement-gui and backend work to see how things are done.
Thats also why I post suggestions first and not an alpha version already :D

So any input is welcome.
Last edited by ffpp on 29 Apr 2011 17:38, edited 2 times in total.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Template-based train replacement

Post by planetmaker »

ffpp wrote:Hi,

yesterday I already talked about this on IRC and was told that there have already been lots of discussions about this. I didn't find any on the forums, though (lazy quick search).
.
quite.

< 30 seconds search:
http://www.tt-forums.net/search.php?key ... ce+consist
http://www.tt-forums.net/viewtopic.php? ... ce+consist
http://www.tt-forums.net/viewtopic.php? ... ce+consist
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: Template-based train replacement

Post by Alberth »

http://wiki.openttd.org/Requested_featu ... ked_groups is where Andy and me store pseudo random stuff about this topic.
User avatar
ffpp
Engineer
Engineer
Posts: 125
Joined: 29 Jan 2010 12:56

Re: Template-based train replacement

Post by ffpp »

Sry for opening up a somewhat redundant discours.

Is there currently some work being done on this topic or is it just ideas floating around so far ?
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: Template-based train replacement

Post by Alberth »

http://www.tt-forums.net/viewtopic.php?p=925656#p925656 is the closest that exists currently.
User avatar
ffpp
Engineer
Engineer
Posts: 125
Joined: 29 Jan 2010 12:56

Re: Template-based train replacement

Post by ffpp »

I see. Maybe I will just create the gui for defining a template for now and specify the data structure for a template without inserting it anywhere yet. If people are already fiddling with the group structure a more combined effort should be more resonable.
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: Template-based train replacement

Post by Alberth »

In my view, group selection and replacement using templates are quite independent.

The former increases flexibilty in selecting a subset of vehicles, the latter replaces the current replace interface with a new one (with much deeper changes than just the GUI).
Eventually you want to connect both, but they can be developed separately.

Besides, development of the groups is not going much forward at the moment, unless someone has a private repo hacking away at the challenge :)

So if you like to enhance replacement, just go ahead. Let's worry about connecting both later.
User avatar
ffpp
Engineer
Engineer
Posts: 125
Joined: 29 Jan 2010 12:56

Re: Template-based train replacement

Post by ffpp »

It took me a while to finally start with this. But now that I'm working on it one principal question comes to my mind.

Just from a practical stand point, would it be better to have a template for each group and just say 'Group members, make yourself fit to your group's template', or would it be better to have a global list of templates and upon replacement the user chooses one for a group to fit to ?

I think the latter approach might carry less redundancy as easily many groups could require the same kind of trains anyways but for a huge savegame the template list could become rather long which would be a point against this approach.

What should I stick with ?
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Template-based train replacement

Post by planetmaker »

How many groups would you have?

You'd probably have about as many templates as you have groups (maybe some more, but the order of magnitude should be the same). Having a list of pre-configured consists from which to choose for upgrade (or maybe even purchase, but that'd be a separate issue) would be nice from my POV. Personally I'd use one template for several groups, but not for all trains, thus it'd be handy.

But the other solution to configure the replacement per group individually (as now basically) is a just as valid approach tbh.
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4763
Joined: 09 Sep 2007 05:03
Location: home

Re: Template-based train replacement

Post by Alberth »

You want at least as many templates as you have vehicle layouts (consists), and possibly more than that (eg have a template for train layouts that are not instantiated yet).

Groups are (in my view) completely independent of templates, ie the user should decide how many layouts belong in a group.
(I am not even sure you'd want groups at all in the end. All vehicles have a number of properties, and as user you likely want to select or sort on those properties. Some of those properties are probably user-defined labels or so, which you could interpret as the equivalent of todays groups.)

For development however, I would pick whatever is most convenient. Getting templates into the game is more than complicated enough, you don't want to create more work just because of some final goal.
TERdON
Engineer
Engineer
Posts: 90
Joined: 09 Nov 2010 15:30

Re: Template-based train replacement

Post by TERdON »

Also, you probably should be able to have

* Trains consisting of several templates in order. E.g. it may be useful to have a standard consist of "engine + 5 passenger car + mail car" but also build trains consisting of two such consists.
* It may be relevant to have parametrizable consists. E.g. I don't want to specify a passenger train for each train length consist, it would be more relevant to set train length, and get an engine, possibly a mail car, and then passenger cars up to full length. This would probably make for a significantly shorter list of different consists, then if all consists should be made in a variant each for every train type...
User avatar
ffpp
Engineer
Engineer
Posts: 125
Joined: 29 Jan 2010 12:56

Re: Template-based train replacement

Post by ffpp »

My post from last time somehow didn't arrive at the forum, weird. I was to lazy to immediately rewrite everything, but here it is again:

Regarding the recent suggestions, this is how I intend to make it look:
  1. * the consists are stored seperately from groups
    * but they are applied group-wise, meaning a group will have only one kind of train after fully applying a replacement
    * the gui shows all trains from the selected group (with some additional information such as current value of a train)
    * it also shows the full list of templates that the user defined so far in this game
    * then there will be start/stop just as in autoreplace to initiate/interrupt the process
    * the gui for creating a template-train will at first just look similiar to what a depot-window looks like
    but because the template creation will be done in a seperate window, this part will be easily and independently extendable
And regarding TERdON's suggestion, this should be simple enough to implement too. Like instead of replacing a whole train to match a given template, one could have an additional [Add Consist to Train]-button in the gui that just extends a train by a selected consist. Nice idea, thanks.

Another issue I will run into is the deprecation of templates as new vehicles and wagons become available with time but older ones will vanish from the buy-lists. There should be some automatic way to keep the template-list clean of deprecated stuff or should at least inform the user that a desired replacement cannot be done anymore.
Maybe it would also be an option to specify a template in a parametric way, like
[One of most modern engine] + [5 of most modern / cheapest / largest / whatever passenger wagons] + [2 mail wagons]
and that those templates are kept up-to-date internally as the buyable vehicle lists change.

As I make some progress towards a working alpha-version I will post some screens of the gui, too. Should be quicker now that I have become more comfortable with the file and data structure of the game.

Btw: What do you exactly mean when saying template and when saying consist ? I was always using those two terms in an ambigious way as 'the-thing-the-real-game-trains-will-be-matched-against'.
Eddi
Tycoon
Tycoon
Posts: 8267
Joined: 17 Jan 2007 00:14

Re: Template-based train replacement

Post by Eddi »

one scenario that i would see with template based replacement is:

let's assume i play the DBSetXL and have my network with two classes of trains: local passenger trains and express passenger trains.

i may have my local passenger trains with a mixture of BR 75 (80km/h) and BR 38 (100km/h) engines, and my express passenger trains with BR 18 (115km/h) engines.

now a brand new vehicle becomes available, the BR 01 (130km/h), which is perfect for express passenger operation

now i could, like normal, have the BR 18 be replaced by BR 01, but that would be silly, because the BR 18 are not very old yet. instead i would like to order the replacement as "Detach the BR 18, buy a BR 01, but do not sell the BR 18, instead leave it in the depot"

then i would order the (fairly old, but still useful) local passenger trains with BR 38 to go to depot, and order a replacement "if a BR 18 is available in this depot (do not buy a new one), then detach the BR 38, attach the BR 18, but do not sell the BR 38" and also order the (really old) local passenger trains with BR 75 to "if a BR 38 or a BR 18 is available in this depot, sell the BR 75 and attach the BR 38 or BR 18"

this would model a fairly common railway operation of downgrading formerly high end engines to lower class service, and slowly rotate out the really old engines.
User avatar
ffpp
Engineer
Engineer
Posts: 125
Joined: 29 Jan 2010 12:56

Re: Template-based train replacement

Post by ffpp »

Your idea sounds nice and is being incorporated. Actually, the basic functionality for this project is finished and I made your idea the default case.

Right now I always tested with the same pre-constructed template. What needs to be done is a small gui for template creation.

What it is doing so far is, that a train which belongs to a group which is set up for template replacement enters a depot and is made to match the previously selected template. Idle vehicles that don't belong to a group are used for that and only if no vehicle in the depot can be used, a totally new vehicle is being bought. After finishing the replacement, all locos that are from the original train and aren't needed anymore remain in the depot, all by themselves. All wagons that belong to the old train remain as a chain in the depot. The locos that remain in the depot belong to the default_group, have no orders but still carry their age, profit statitics and value.
Maybe it could be helpful to add a single boolean value to trains which mark them as being re-usable by template replacement. So that the user might have vehicles in the depot and knows that some particular vehicles will never be used for template replacement.

And now I forgot something I intended to write. Well, if it comes back to my mind again, I will write it :roll:
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 31 guests