Tutorial:Trains

This tutorial explains what there is to know about trains, how to set them up, how to calculate throughput etc.

NOTE: This article is still work-in-progress, images are to be added.

Prerequisites
Trains are unlocked in Tier 6. Before they can be unlocked, Oil processing has to be set up to allow for to be made - although Computers found at Crash Sites can allow a few early station setups. Beside Computers, a sufficient amount of and  are also required.

Track construction
are built using and. One railway segment can be up to 100 meters long. Railways take shape and angle based on the terrain they are built on, which can lead to very wiggly tracks or tracks that clip through the ground on uneven terrain. For optimal results, construct Railways on Foundations.

Switches
Switches are formed by joining Railway segments together:
 * This cannot be done directly before or after a Train Station
 * Railroad Switch Control will appear at each switch; it is only relevant for manual driving (automatic trains will always choose a path regardless of the switch control)
 * A switch doesn't have to be just 2-way, it is possible to keep on adding more tracks
 * A switch can be cross-shaped
 * Avoid: There is a bug, where if a single Railway segment has a switch on both ends, automatic trains will have trouble pathing through the switch. Instead of having one Railway segment with a switch on both ends, break the segment into two smaller segments, both of which only have a switch at one end.

Train composition
Trains are made up out of and. Trains with more carriages will speed up and brake more slowly, but most importantly, they will handle inclines worse. Therefore, having multiple Locomotives is a requirement unless the track is completely without inclines. The recommended ratio is one Locomotive for four Freight Cars. Whether a Freight Car is loaded does not affect the weight.

Freight Cars can carry either 32 stacks of items or 1,600 m, however, not fluids and items at the same time.

It is un-advisable to mix cargo in Freight Cars; the optimal solution is to have at least one Freight Car per item. See § Calculating throughput for how many Freight Cars should a train have to have sufficient capacity.

Train operation
A train can be only operated if it has at least one Electric Locomotive and is on a powered Railway. For manual driving, / to speed up or use engine brake (based on direction), to use rail brake and  to use the horn. Automated driving is set up using a timetable (explained in § Automation).

Trains cannot derail (the train is forcefully stopped at the end of the Railway) nor collide with other trains (they simply phase through each other). There are no train signals whatsoever.

Bi-directional trains
Placing a Locomotive (or Locomotives) on both ends of a train makes it bi-directional, as Locomotives on autopilot don't reverse. A bi-directional train can run as a shuttle without turning around.

Stations and loading cargo
Stations consist of four different buildings:, , and.

Starting with the Train Station, it is very important to note that it is directional. The direction of the Train Station dictates how will trains arrive in the station, but not depart. That means that for bi-directional trains, both Train Stations have to face the end of the track. Train Stations have to be powered and constantly consume 50 MW, they also power the railway network they are on and all other stations on the same network (making it an extension of the standard power grid).

Freight Platforms attach to the Train Station. They can be rotated either left or right, which does not affect how they behave. Inside their UI, they can be either set to "load" or "unload" (where the yellow button is the currently active option). One Freight Platform handles one Freight Car, therefore to load a train consisting of one Locomotive and three Freight Cars, the station will begin with a Train Station (for the Locomotive) followed by three Freight Platforms. Freight Platforms stop accepting or outputting items during the 25-second long loading animation. To keep items moving, Industrial Storage Containers or at least two Industrial Fluid Buffers should be placed before each loading and after each unloading Freight Platform.

Freight Platforms can be spaced out using Empty Platforms. For example, for a train made up of two Locomotives and seven Freight Cars where only the 3rd Freight Car has to be loaded, the station will consist of a Train Station, three Empty Platforms (one for the second Locomotive and two for the two Freight Cars that precede the 3rd one) and one Freight Platform (that handles the 3rd Freight Car). It is not necessary to add trailing Empty Platforms after the last used Freight Platform.

Building a complete railway
As an example, we'll automate the transportation of products:, ,  and  or. Packaging the fluid doubles the capacity one Freight Car can transport, at the cost of having to deal with recycling Empty Canisters or dedicating a part of the Plastic production, it is better to use double the number of Freight Cars in that scenario. It is best to avoid transporting fluids as much as possible (that's why we're transporting Crude Oil products and not Crude Oil itself; for power generation, burn all produced Fuel near the source without having to transport it, for Jetpack and Vehicle fuel only small amounts of either fluid or Packaged Fuel are necessary). For this tutorial, fluid Fuel will be transported.

Starting with the train, it will have five carriages (one for Plastic, Rubber, and Coke each and two for fluid Fuel, avoiding mixing cargo whatsoever). As mentioned above, the recommended ratio is one Locomotive per four Freight cars, and because five Freight Cars are used, the train will be hauled with two Electric Locomotives. It is very useful to define the order of the carriages, so we don't accidentally happen to mix cargo later on.

The station at the Crude Oil outpost will consist of a Train Station, one Empty Platform, and five Freight Platforms, of which the last two are for fluids. All of the Freight Platforms have to be set to "load" in their UI (each one individually). The Train Station can be renamed upon being interacted with.

The station at our destination will look the same, with the only exception that the Freight Platforms will be set to "unload".

Automation
Trains can be automated using a timetable. Despite the name, the timetable has nothing to do with time, only sets which stations the train should path to and stop at, it is not possible to e.g. make the train wait until it is fully loaded or unloaded. Setting up the timetable is quite primitive:


 * Make one entry for each Train Station, in order, only mentioning each station once
 * The train will complete the route in order and automatically go from the last station to the first one
 * Bi-directional train routes are set up the same way, however, ensure the train can actually reach all of the stations (as mentioned above, Train Stations are directional and trains can only arrive in them in that direction but can depart either forward or in reverse)
 * If the train cannot find a path, check if are all Train Stations rotated correctly, and the Railway is connected (easiest way to check if the Railway is connected is to drive the route manually if the train suddenly stops then the Railway is not connected)

Packed Buffer Strategy
The packed buffer strategy is meant to solve the following scenario:

Factory A produces some good that needs to be shipped to Factory B via Train. Factory A has a large storage reserve of this good, and all output of this good is put into storage, then drawn from storage into consuming machines. This is a common strategy to allow for overproduction of a good that meets demand while also allowing the Engineer an available supply for other uses. In our example, Factory A is better equipped to produce, which is needed by Factory B, some large distance away. We need to transport the via Train, but we also need to use our large storage reserve for output of the. The consumers of at Factory B only consume it at a rate of 5 parts/min, but the lowest we can ship it out of storage is 60 parts/min (unless we do a complicated series of divide back-merges into storage). If we allow our Freight Platform at Factory A to receive the at a rate of 60 parts/min (the minimum rate we can transport product out of a full storage container), it will fill up. So will the Freight Car that transports it, as well as the Freight Platform at Factory B. If we only have three Industrial Storage Container as a reserve, we will end up dumping almost our entire reserve into the Freight Platforms/Freight Car, without having any available at the producing factory for other uses.

To remedy a full drain of our reserves, we will need to use the packed buffer strategy. This involves filling all transport buffers with some other product that can be easily produced in abundance, and doesn't hold significant value (, or for example). Once we use the above tutorial (Tutorial:Train Throughput) to calculate how much we need to actually use (let's say we only need two stacks total to handle consumption at Factory B), we can pack our Freight Platforms and Freight Car with the buffer product to ensure the remaining storage slots will not fill up with our Industrial Beams.

The only tricky part of this is understanding how items will enter/leave a Freight Platform/Freight Car. The below pictures demonstrate how products flow through train storage: Products are shipped in a FIFO manner (First In, First Out). Products are extracted from output storage in a LIFO manner (Last In, First Out). If you arrange your Freight storage containers/cars with a packed buffer in this order, you will be able to transport only the minimal amount of the desired product ( in this case), while never transporting the buffer product ( in this case), while also keeping all of your storage reserves of in place back at Factory A where it is produced and reserved.