[Patch] Lazy Train Builder

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
knutux
Engineer
Engineer
Posts: 7
Joined: 22 Feb 2016 07:13

[Patch] Lazy Train Builder

Post by knutux »

Hi,

A month or two ago I have searched for open source alternatives for TTD and found openTTD. Since then I've been playing a lot, but there was one thing annoying me - purchasing a train is very long procedure. Click 'Buy', search for best engine, click buy, search for required wagons, many clicks to buy the required number of wagons, few clicks to refit (if FIRS or similar NewGRF used), click order icon, search for source station, click, search for target station, click, and one more click to start the train.
Usually I do not care much about the engine (buy fastest at later game stages, in earlier stages - fast, but not very expensive), I do not do refits at stations and use one or two types of wagons (just wood, just coal, passengers+mail, livestock + grain, etc). My trains are usually of the same length (5 or 7) and go between 2 stations (load at one, transfer or unload at another). And I do many mistakes using current openTTD "Buy vehicle" window - sometimes I give orders and start train forgetting to buy wagons, often I forget to refit wagons.

So I have decided to implement a simple window which produces me a fully functional train of selected length. I had problems choosing the right name for the window (and a patch), so for now I will just call it "Lazy Train Builder" (window title is still "Casual Train Purchase" which was the name I have used earlier).

Here is the screenshot of a current version:
Image

As you can see, there is a new button "New train" in train depot which opens a new window. Lazy Builder window allows to select cargo type (and optionally second cargo), engine type, train length, source and target stations. It works best if depot is located near the source station - nearest station and its produced cargo are selected by default. So if your depot is near the farm station, this station will be selected as the source, livestock will be selected as first cargo and grain - as a second one. And it will works better if you build the target station before opening the window (as cargoes section filters out the cargoes which are not accepted in any of your stations).
The patch is not meant to cover all the needed cases, so some things are simplified - it only shows cargoes which are both produced and accepted by some of your stations, cheapest wagon is selected for each cargo (if there are multiple possible wagons), if stations are selected first orders is "full load", and the second one - "unload" (if passengers are selected, second order is also "full load"). Expert user will often find old style "Build vehicle" window more efficient, but for casual users it might make game more enjoyable.

I have tested the patch in single player games using clean trunk build (r27505) and multiplayer games using BTPro server/client (which is based on 1.5.3 with multiple patches applied).

I have many plans how to improve the window, but I'm not sure which ones I will ever implement:
  • Add filters. For wagons it would allow to filter "Produced+accepted", "Produced anywhere", "Accepted anywhere", "All cargoes". For engines I should probably add the "Show/Hide" functionality (as in original "Build vehicle" window) and a filter to show hidden engines. For wagons there could also be an option to prefer cheapest or highest capacity wagon (if there are multiple choices)
  • Make some labels and add warnings ("selected station does not produce the cargo", "no path found between stations", etc.)
  • In station drop-down list order stations by cargo production/acceptance and by distance (so if coal is selected, in target stations selection first show nearest power station). Stations producing/accepting the cargo should be marked in a list.
  • [DONE in 1.0.0] Calculating profitability estimates. I would like to make a rough estimate of how much trips per year could the train make and how much max profit can be made assuming indefinite production (knowing the distance between stations, capacity, engine running cost, aging vehicle price decline, cargo price it should be possible to make some guess). I do not plan to make a very realistic estimate
  • Allow to select order types (full load or load any for source, transfer or unload for target)
  • [DONE in 0.9.5] Option to build train stopped (to have ability to add tertiary cargoes, etc)
  • If there are trains with same order need an option to make this train orders shared (quick way to clone vehicle using newer engine type)
  • Better error handling. As train building is not an atomic process, it can fail at any step (for example, there is autoreplace going in background and company runs out of money after building engine with some wagons) and the half-built train will be left. Need to sell it in this case.
lazy-train.1.0.5.zip
Newest release (1.0)
(39.29 KiB) Downloaded 78 times
Image of the old version - http://www.knutux.com/lazy-train-0.8.1.png
Attachments
lazy-train.0.8.5.zip
Newer version of the patch
(27.6 KiB) Downloaded 60 times
lazy-train.0.9.5.diff.zip
Path version 0.9.5
(33.71 KiB) Downloaded 64 times
Last edited by knutux on 15 Mar 2016 14:06, edited 5 times in total.
_dp_
Transport Coordinator
Transport Coordinator
Posts: 278
Joined: 18 Dec 2013 12:32

Re: [Patch] Lazy Train Builder

Post by _dp_ »

Nice to see someone else trying to improve train purchasing. Did you try it with custom train newgrfs? They screw up length/cargo calculations and that's what stopped me from doing anything with train building when I tried.

I like the idea of separating engines and wagons, but generally you patch looks like it's useful for your style of play only. Players (and especially good ones) use all kinds of train types. With more than one engine, for example, or much longer than 7 tiles, and so on. Sometimes players are balancing trains for particular industry cluster, depending on it's production, which can result in smth like 6 grain 4 livestock 3 wood 1 oil train. Also you can assign all kinds of orders with hotkeys and do that even faster than with dropdowns.
knutux
Engineer
Engineer
Posts: 7
Joined: 22 Feb 2016 07:13

Re: [Patch] Lazy Train Builder

Post by knutux »

_dp_ wrote:Nice to see someone else trying to improve train purchasing. Did you try it with custom train newgrfs? They screw up length/cargo calculations and that's what stopped me from doing anything with train building when I tried.
I did not yet test with custom length wagons, but I have tried to take that in mind while coding, so it should need a fix or two to work.
_dp_ wrote: I like the idea of separating engines and wagons, but generally you patch looks like it's useful for your style of play only. Players (and especially good ones) use all kinds of train types. With more than one engine, for example, or much longer than 7 tiles, and so on. Sometimes players are balancing trains for particular industry cluster, depending on it's production, which can result in smth like 6 grain 4 livestock 3 wood 1 oil train. Also you can assign all kinds of orders with hotkeys and do that even faster than with dropdowns.
I did intend this patch for non "professional" players - those who play occasionally or just start to play. So they can easily create trains for simple workflows and fine-tune them later if they need to. Those who play a lot are used to the current system which is much more flexible and there is no need for them to switch. Most of them would not even notice the new button as I guess "Build vehicle" button is attached to some hotkey on their environment.
As for order assignment - yes, dropdown is not the quickest control to use. But as you have mentioned, it fit my style of play - first order is always the nearest station, so it is enough to click "Build" and new train is running towards the loading station (I'm adding the target station with ordinary orders window while it goes).
Eddi
Tycoon
Tycoon
Posts: 8272
Joined: 17 Jan 2007 00:14

Re: [Patch] Lazy Train Builder

Post by Eddi »

i've only skimmed this, and i'm not sure how the "clone train" feature doesn't already do like 90% of what you want, but just for the sake of argument..

i'd find it more logical if you flipped your UI, so you pick engine on the left and wagon on the right.

i find the UI is a bit overloaded, trying to achieve too much. i'd drop the ability to have a second wagon type completely. and the station assignment should stand out more, or be dropped as well.
knutux
Engineer
Engineer
Posts: 7
Joined: 22 Feb 2016 07:13

Re: [Patch] Lazy Train Builder

Post by knutux »

Eddi wrote:i've only skimmed this, and i'm not sure how the "clone train" feature doesn't already do like 90% of what you want...
My patch does not introduce any new functionality, just enhances UI. So yes, experienced users will find 'Build vehicle' and clone train much efficient to use. But for the starter user it might be simpler to open a window which allows building a functional train without knowing any shortcuts.
Eddi wrote:i'd find it more logical if you flipped your UI, so you pick engine on the left and wagon on the right.
My initial thought was to make engine on the left, but later I decided that cargo selection is the most important one and moved engine to the right. But now I'm not sure that was the best decision. Maybe it is more logical to switch panels.
Eddi wrote:i find the UI is a bit overloaded, trying to achieve too much. i'd drop the ability to have a second wagon type completely. and the station assignment should stand out more, or be dropped as well.
Train is a complex vehicle, so "one-click" creation need to have many options. I still believe that this window needs secondary cargo and stations, but there might be a better way to show those options (maybe multi-select list for cargoes, some button to switch between info panel and stations, etc.).
knutux
Engineer
Engineer
Posts: 7
Joined: 22 Feb 2016 07:13

Re: [Patch] Lazy Train Builder

Post by knutux »

Just added the newer version which works with non-standard length wagons (at least with those newgrf's which I have tested)
User avatar
Redirect Left
Tycoon
Tycoon
Posts: 7249
Joined: 22 Jan 2005 19:31
Location: Wakefield, West Yorkshire

Re: [Patch] Lazy Train Builder

Post by Redirect Left »

Nice addition, I like it. Would love to see you keep going on this!
Image
Need some good tested AI? - Unofficial AI Tester, list of good stuff & thread is here.
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: [Patch] Lazy Train Builder

Post by Zuu »

It is a bit weird to have the panel with data for selected wagon/engine below some controls that doesn't connect as strongly to the list of wagon/engine. For example train station selection has no connection to wagon or engine list.

Also, it probably look better two use two panels with vertical split rather than one with just content-wise split.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
knutux
Engineer
Engineer
Posts: 7
Joined: 22 Feb 2016 07:13

Re: [Patch] Lazy Train Builder

Post by knutux »

Posting the new version (0.9.5) with the following new features:
  • Selected train preview is shown with ability to select individual wagons and to define which cargoes to carry in which wagon. "Secondary cargo" dropdown removes as it is no longer applicable
  • Wagon selection is adjusting to the engine type selected. So if there is some non-standard wagon with speed limit of 56 km/h, it is not suggested for high speed locomotives (unless there is no quicker wagon to choose)
  • Additional buttons "Buy & start and "Buy stopped"
  • Multiple fixes to better support wagons of non standard size (wagon selection still acts weird in rarer cases - this will be fixed in next releases)
  • Engine is refitted to selected cargo (if can carry cargo of selected type)
Please look for the download link in the first post.

Nearest plans:
  • Support multiple engines
  • Estimate how many trips (or how many tons) selected train can make in a year
Image
knutux
Engineer
Engineer
Posts: 7
Joined: 22 Feb 2016 07:13

Re: [Patch] Lazy Train Builder

Post by knutux »

Adding the latest version which includes Estimation feature (see screenshot in the first post). This feature allows you to evaluate which train chain would be most efficient in ideal conditions. It calculates (guesses) how much single trip will take, sums potential profit of cargoes (assuming indefinite resources), subtracts running costs and vehicle price decline over year. I found it very interesting to get a better idea which engine is most efficient, especially with newGRFs and adjusted costs.
Smaller feature included in this release - suggesting train length by nearest platform length.

As this patch received only a little attention, I do not plan on further major developments of the patch in the nearest future.
lazy-train.1.0.5.zip
Newest release
(39.29 KiB) Downloaded 68 times
heppers
Engineer
Engineer
Posts: 108
Joined: 10 Jun 2004 07:09
Location: Staffordshire, UK

Re: [Patch] Lazy Train Builder

Post by heppers »

I'm not a coder or in any way have the ability to incorporate your patch myself, but for what it's worth (or not worth!) i quite liked the idea :)
Pedro The Fisherman
User avatar
Awesometrains
Traffic Manager
Traffic Manager
Posts: 129
Joined: 22 Nov 2015 17:07

Re: [Patch] Lazy Train Builder

Post by Awesometrains »

knutux wrote:Adding the latest version which includes Estimation feature (see screenshot in the first post). This feature allows you to evaluate which train chain would be most efficient in ideal conditions. It calculates (guesses) how much single trip will take, sums potential profit of cargoes (assuming indefinite resources), subtracts running costs and vehicle price decline over year. I found it very interesting to get a better idea which engine is most efficient, especially with newGRFs and adjusted costs.
Smaller feature included in this release - suggesting train length by nearest platform length.

As this patch received only a little attention, I do not plan on further major developments of the patch in the nearest future.
lazy-train.1.0.5.zip
I'm not a programmer so it would be nice if you added this to OpenTTD yourself and uploaded the whole OpenTTD folder
Qa'pla!
knutux
Engineer
Engineer
Posts: 7
Joined: 22 Feb 2016 07:13

Re: [Patch] Lazy Train Builder

Post by knutux »

Awesometrains wrote: I'm not a programmer so it would be nice if you added this to OpenTTD yourself and uploaded the whole OpenTTD folder
Hi,

I have done a custom openTTD build, so you can preview the Lazy Train feature without having to patch and build it. It is for Windows and not tested on various environments, so I cannot guarantee it will work.
heppers
Engineer
Engineer
Posts: 108
Joined: 10 Jun 2004 07:09
Location: Staffordshire, UK

Re: [Patch] Lazy Train Builder

Post by heppers »

great thank you! :)
Pedro The Fisherman
User avatar
Awesometrains
Traffic Manager
Traffic Manager
Posts: 129
Joined: 22 Nov 2015 17:07

Re: [Patch] Lazy Train Builder

Post by Awesometrains »

knutux wrote:
Awesometrains wrote: I'm not a programmer so it would be nice if you added this to OpenTTD yourself and uploaded the whole OpenTTD folder
Hi,

I have done a custom openTTD build, so you can preview the Lazy Train feature without having to patch and build it. It is for Windows and not tested on various environments, so I cannot guarantee it will work.
both me and 'hepper' thank you :D :D
Qa'pla!
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 47 guests