You are on page 1of 99

Factorio Train

Automation
From Novice to Journeyman
by /u/Grays42
Introduction
Welcome to the Factorio Train Automation tutorials! This series is separated into
three parts: Novice, Apprentice, and Journeyman. Each part will help you
understand more complex workings of a functioning rail network in Factorio.

Before we get started, please make sure you are viewing in a slideshow format.
Many of the demonstrations will not flow smoothly if you are scrolling with a
mouse. For PDF readers, make sure you choose single page or fit to page
view. If you are viewing on imgur, make sure you put /all at the end of the
album address and choose Fullscreen at the right.
Part 1: Novice Stations, Signals, and Blocks
Lets begin with Part 1! Before we dive into automation, you should first learn to
run a train manually. Lay some track down, put down an engine, and move
around. Youll need to fuel it with this symbol: Enter gets in/out, W-A-S-D
moves and turns. W is always forward from where the train faces.

Set up the intersection to the right


and move around on it to see how
trains can navigate merges and
crossovers.

Once youre comfortable, lets automate a train!


Part 1: Novice Stations, Signals, and Blocks
To automate a train, first place a station along the
track in front of the train (cant go backwards).

Notice the arrows? Thats


because stations can only be
approached from one direction.
Give your station a name by clicking on it.
Next, click the train and use the train scheduler to add the station with !
(You can delete it with ). will begin automation and will revert to
manual operation. ( picks a specific station if you have a long list of them.)

Press to automate your train!


Part 1: Novice Stations, Signals, and Blocks
And away it goes!
Easy, right? So what happened here?
The train actually did two things:

1. It first had to find a path to the station by tracing a line through all areas it is
explicitly allowed to go. (It will display No path if it cant find a route.)
2. It then began to move to the station, stopping for any areas occupied by
other trains. In this case, it encountered no other traffic and just went to its
station. It will stay there for a number of seconds set by the train scheduler.

So how does a complex train system meet these two objectives?


Part 1: Novice Stations, Signals, and Blocks
Enter: the signal! When you place one, youll notice its one-way, like the station.

This is the first function of the signal: explicitly allows the train to use the track in
that direction. Trains will never go through signals that dont point the correct
direction. Trains that cant find a correct signal will not be able to find a path!

A signal on each side of one spot allows trains to travel in


either direction along the track:
Part 1: Novice Stations, Signals, and Blocks
The second function of a signal is to prevent collisions by breaking up groups of
track into sections called blocks.

A block is any number of tracks crossing, merging, or splitting


that is bounded by signals.

If the block in front of the signal is If theres something blocking


not obstructed, the signal turns green. the track, the signal is red.
Part 1: Novice Stations, Signals, and Blocks
Here, you can see the blocks identified as boxes. Red boxes are obstructed and
green boxes are available to be entered by trains.

Even though this second train isnt even on the path to the station, its still in the
third block. This prevents collisions!
Part 1: Novice Stations, Signals, and Blocks

Also, remember that our signals are one-way. If we put signals in the other
direction, the lights on those will show occupied blocks in that direction.
Part 1: Novice Stations, Signals, and Blocks

Creating and managing blocks are the basic function of signals and a
fundamental aspect of all rail networks.
Part 1: Novice Stations, Signals, and Blocks

So what happens if we automate that train?

I want to get
to that station.
Part 1: Novice Stations, Signals, and Blocks

Trains in Factorio will always move to the last available block on the path they
have chosen. In this case, it will move to the end of the second block and stop
until that block is clear.

The next block


is occupied.
Part 1: Novice Stations, Signals, and Blocks

Also, trains will always select the shortest route given multiple options.
Part 1: Novice Stations, Signals, and Blocks

If that route becomes obstructed somewhere, it will calculate a new path, as


long as it has an option to change to a different block somewhere down the line.
Part 1: Novice Stations, Signals, and Blocks

But what happens if its final block is obstructed?


Part 1: Novice Stations, Signals, and Blocks

The train will choose its best path and wait at


the final block for the obstruction to clear.
Part 1: Novice Stations, Signals, and Blocks
Last example: We have two trains going in opposite directions, and a third line
cuts across both. They should be able to safely cross at the same time.
Part 1: Novice Stations, Signals, and Blocks

However, the center is all one block. If one train enters, the second has to wait.
Part 1: Novice Stations, Signals, and Blocks
Any time you want to allow for multiple trains to pass, you can separate sections
of track into their own blocks with more signals.

Like this.

its a trap!
Part 1: Novice Stations, Signals, and Blocks

Both can pass through at once. Everyones happy! *

*Actually, we have now exacerbated a This concludes Part 1: Novice!


huge problem. More on that next. (ignore that guy, hes fine.)
Part 2: Apprentice Intersections, Chain Signals

Welcome to Part 2 on your path from Novice to Journeyman! In this section, we


will discuss intersections and chain signals.

In Part 1 we covered the basic components of a simple rail network: stations,


signals, and blocks. Using these, you should be able to get trains from point A to
point B fairly easily...assuming nothing else is moving in the network.

When you involve two, four, or twenty moving trains, things get considerably
more complicated. But we will come prepared!

Lets begin with the intersection we fixed at the end of Part 1.


Part 2: Apprentice Intersections, Chain Signals

An intersection is defined as any group of crossings and merges where a train


can encounter a train from a different line.

We set this up in Part 1, but we have a problem that we didnt notice.


Part 2: Apprentice Intersections, Chain Signals

Were in the same situation as before,


with our train wanting to get to the station.
Part 2: Apprentice Intersections, Chain Signals

This time, though, the train cant get to its station.


Theres another train there--it could be out of fuel, loading ore, or just waiting.
Part 2: Apprentice Intersections, Chain Signals

Our train doesnt know that. It sees a green


signal and pulls out into the intersection.
Part 2: Apprentice Intersections, Chain Signals

Now our train, who could have waited before the crossing,
is blocking the intersection...and another train is coming.
Part 2: Apprentice Intersections, Chain Signals

So our northbound train is now also stuck, and the problem


just keeps getting worse as another train approaches.
Part 2: Apprentice Intersections, Chain Signals
So now our problem with just one line is a problem for three, when those other
two could have been moving freely even with one stuck situation. This kind of
issue can quickly spiral into a deadlock, where every train is blocked by at least
one other train. It all started when our first train entered the intersection and
couldnt exit.
Part 2: Apprentice Intersections, Chain Signals

From this example, we can come up with a rule we can enforce for all trains so
that they never encounter a situation with a blocked intersection:
Part 2: Apprentice Intersections, Chain Signals

From this example, we can come up with a rule we can enforce for all trains so
that they never encounter a situation with a blocked intersection:

Golden Rule
Trains must never enter intersections
that they cant completely exit.
Part 2: Apprentice Intersections, Chain Signals

From this example, we can come up with a rule we can enforce for all trains so
that they never encounter a situation with a blocked intersection:

Golden Rule
Trains must never enter intersections
that they cant completely exit.

The Golden Rule of intersections? Great! So...how do we enforce that?


Part 2: Apprentice Intersections, Chain Signals

Enter: the chain signal!


Part 2: Apprentice Intersections, Chain Signals

Enter: the chain signal!

Chain signals have all of the existing functions of regular signals.


Part 2: Apprentice Intersections, Chain Signals

Enter: the chain signal!

They make blocks and check for obstructions just like regular signals.
Part 2: Apprentice Intersections, Chain Signals

Enter: the chain signal!

However, they also look ahead to the next signal and turn red if its obstructed!
Part 2: Apprentice Intersections, Chain Signals

Now lets go back and re-signal our intersection. Our intersection encompasses
every encounter between different lines.

Remember the Golden Rule! The train must only proceed if its exit block is clear.

Can I exit this


intersection?
Part 2: Apprentice Intersections, Chain Signals

We want to make decisions based on the exit blocks to the intersections, so we


put regular signals on those. The behavior of those signals determines what
everyone approaching the intersection is looking at.
Part 2: Apprentice Intersections, Chain Signals

Now we want to address the incoming traffic and tell them to watch what
happens to the exit block so they know whether its safe to enter the
intersection at all. We do this with chain signals before every crossing.

Nope! That chain


signal is red. My
exit isnt clear.
Part 2: Apprentice Intersections, Chain Signals

Great! Now our intersection is completely safe to use without deadlocks.

The blockage cleared up and the train is ready to move forward into our
completely safe intersection. Except...what if another train is passing?
Part 2: Apprentice Intersections, Chain Signals

Were back to our original problem that the intersection is one big block! The
first time, we solved this by placing a signal in the middle, but that caused a
deadlock. Fortunately, we now have a much better option.
Part 2: Apprentice Intersections, Chain Signals

By placing a chain signal, not a regular signal, in the center of the intersection,
we have safely split the eastbound and westbound lines so traffic can flow
freely without causing deadlocks!
Part 2: Apprentice Intersections, Chain Signals

Notice what happened here, though: This isnt really a clear block! The upper
block being occupied is telling the northbound line that it is not safe to enter, but
allowing traffic through the eastbound line. This incredibly powerful behavior is
what enables huge intersections to be safely used by many trains at once.
Part 2: Apprentice Intersections, Chain Signals

From this we can deduce several Principles used to enforce the Golden Rule.
Part 2: Apprentice Intersections, Chain Signals

From this we can deduce several Principles used to enforce the Golden Rule.

1. Signals before the exit blocks of the intersection.

As previously discussed, the exit block is the only thing that a train heading to
an intersection should be concerned about.
Part 2: Apprentice Intersections, Chain Signals

From this we can deduce several Principles used to enforce the Golden Rule.

1. Signals before the exit blocks of the intersection.


2. Chain signals every other time a line crosses or
merges with another line.

An intersection only begins when one line encounters another. At the moment
this occurs, until reaching the exit block signals, every encounter must have a
chain signal. We never want the train to be able to enter the intersection
without taking into consideration what is happening at its exit block.
Part 2: Apprentice Intersections, Chain Signals

From this we can deduce several Principles used to enforce the Golden Rule.

1. Signals before the exit blocks of the intersection.


2. Chain signals every other time a line crosses or
merges with another line.
3. ? ? ?
Theres a third intersection principle, but its actually outside the intersection, so
well cover it in Part 3 when we start having intersections interacting with one
another.

Hint: it enforces the last part of the Golden Rule that requires you to completely exit the intersection.
Part 2: Apprentice Intersections, Chain Signals

There is one unusual exception to these Intersection


Principles: merges at the exit block of an intersection.

In both of these examples, three trains need to


merge into one exit block.

In the top example, weve put regular signals exiting


the intersection, whereas in the bottom, weve used
chain signals.
Part 2: Apprentice Intersections, Chain Signals

What weve done on top is turned the entire merge


into one giant exit block.

For the bottom, we have three chained blocks.


Part 2: Apprentice Intersections, Chain Signals

However, when any one of the three enters the exit block,
both configurations perform exactly the same way.

This is because these three lines share a single output.


So for the case of exit merges only, the merges can be
combined into one large exit block.

(Note: This is a shortcut! Either


option will function just fine.)
Part 2: Apprentice Intersections, Chain Signals

We have one last thing to discuss about chain signals before we move on. A
train approaches a chain signal we will place here before the lane splits.

What color will it be?

Hints:
A chain signal will act like a signal and be green if its block isnt occupied.
A chain signal turns red if its block, or the block following it, is occupied.

However, one exit block is green, one is red. So which will the chain signal be?
Part 2: Apprentice Intersections, Chain Signals

Neither. It turns blue!

What does that tell the train?

I need to see my next


block, is it clear? Um...maybe? It depends on which
way youre going. You figure it out!
Part 2: Apprentice Intersections, Chain Signals

In Factorio, a moving train already knows the path it wants. A blue chain signal
tells the train to check the next block in its individual path, because chain signals
are global, not per-train. The chain signal itself has no idea which path the train
wants to take, it just knows that some exits are obstructed and some arent.
Part 2: Apprentice Intersections, Chain Signals

Next, were going to create a one-way spur coming off of a


block in an existing double-track network.

(Dont worry about the double-track bit


For nowwell discuss network types in Part 3.)
Part 2: Apprentice Intersections, Chain Signals

First, we need to figure out where we will put our


connecting rails; we only need two, because there
are only two ways to get to the new line.

These need room for signals. (This will require


some trial and error.)
Part 2: Apprentice Intersections, Chain Signals

Now, we need to identify: Where is the intersection?

The only place the intersection actually exists


is the group of crossings and merges where
one train can encounter a train from a
different line. We have one of each.

Splits are not part of the intersection


because there is no chance for one train
to encounter an occupied block until
the next signal down the line.
Part 2: Apprentice Intersections, Chain Signals

As we discussed before, we can consider this


merge at the exit to be one big exit block.

Again, this is an optional step. Chain signals will also


work exactly the same way, it will just make the exit
block further down the line.
Part 2: Apprentice Intersections, Chain Signals

(Enforcing Principle #1)

Now we need signals on the exit blocks.

One of them is already provided because


were modifying an existing block.

We could actually back this up to


just after the crossing if desired.
It actually does give us more room
in the larger network, so lets go
ahead and do that.
Part 2: Apprentice Intersections, Chain Signals

(Enforcing Principle #1)

Now we signal the northern exit block.


Part 2: Apprentice Intersections, Chain Signals

(Enforcing Principle #2)

Finally, every time an interior rail encounters


a different line, it needs a chain signal.

In this case, theres one other encounter in the intersection,


so we need a chain signal for each line leading to it.
Part 2: Apprentice Intersections, Chain Signals

And were done! That was easy, right?


Lets try it out. Here come two trains.
Part 2: Apprentice Intersections, Chain Signals

The westbound train arrived first, so the chain signal sees


an obstruction and stops our northbound train.
Part 2: Apprentice Intersections, Chain Signals

Our train sees that its chain signal is green, indicating


that all the blocks through to the exit block
are unoccupied. It begins to move into the
intersection.
Part 2: Apprentice Intersections, Chain Signals

The train crosses into the intersection, and now


occupies two blocks. This means we havent yet
cleared the lower, eastbound line.

In a real situation, this signal leading to the


exit block would turn red, because our northbound
train has reserved its path through the intersection
so it doesnt get stuck.
Part 2: Apprentice Intersections, Chain Signals

Now that weve cleared the bottom block, the lower


line becomes available for other traffic.
Part 2: Apprentice Intersections, Chain Signals

As we move into the exit block, we still occupy


the last bit of our intersection, so we cant
clear the westbound lane yet.
Part 2: Apprentice Intersections, Chain Signals

Weve cleared the intersection!

We have now restored traffic through the eastbound


and westbound lanes. Note the chain in the center,
though; its informing any new northbound
trains that it cant use the intersection yet.

Side note: As a rule of thumb, it is generally


preferable to place your exit signals as close to
the intersection as possible, so that exiting trains
clear mainline traffic faster. We did not do so in
every case for this example so that the signaling
demonstration is easier to understand.
Part 2: Apprentice Intersections, Chain Signals

Heres a complete summary of the process we use to signal an intersection:

1. Identify the intersection. This is the group of encounters (merges and


crossings) where two trains from different lines can meet.
a. Splits dont count because theres no way for two different lines to meet.
b. Merges at the exit only may be treated as one exit block because the lines all the way through
the intersection share one output.
2. Place signals before the exit blocks for each line exiting the intersection.
3. Place chain signals on each line leading to an encounter.

And thats it! Using those steps, based on the Principles, which enforce the
Golden Rule, you can correctly signal any intersection. Remember that were
missing one Principle; well learn about it in Part 3, when intersections interact.
Part 2: Apprentice Intersections, Chain Signals

Lets do one more example before we finish.

Lets signal a T-junction for a double-track network.

This may look more complicated, but


we can easily signal it using our same steps.
Part 2: Apprentice Intersections, Chain Signals

First, we identify the intersection. This is the group


of encounters where trains from two different
lines can meet.
Part 2: Apprentice Intersections, Chain Signals

Three of these encounters are merges at the


exits, which we can consider parts of the exit blocks.

We will not need chain signals here.


Part 2: Apprentice Intersections, Chain Signals

Now we identify and signal our exit blocks.

(Smaller for clarity, but normally


youd want to push these back)
Part 2: Apprentice Intersections, Chain Signals

Finally, we chain signal all other encounters between


different lines.

(Sometimes the positioning can be tricky


because you cant place a signal in the
middle of a curved piece of track.)
Part 2: Apprentice Intersections, Chain Signals

And thats it! Were done!

You now know where to place signals in any


intersection. This concludes Part 2!

You can now put intersections


anywhere you want to in your network!

its a tr

yes, I said that on purpose,


because we're discussing that
in Part 3. Go away.
Part 3: Journeyman Rail Systems and Networks
Welcome back to the final part of our series!

In Part 1 of this series, you learned the basic concepts of stations, signals, and
blocks. In Part 2, you learned how to build intersections and use chain signals.

So far, everything we have done has been in a vacuum; we havent made a rail
network and have had no discussion of how these pieces interact.

Now we need to tackle problems on a larger scale. Lets get started!


Part 3: Journeyman Rail Systems and Networks
Almost everything weve made so far has been one-way. Lets discuss why.

Suppose I want to connect these two sections of


my network that are some significant distance apart.

(far apart)
Part 3: Journeyman Rail Systems and Networks

We could use our intersection we made in Part 2,


but it will only allow for travel in one direction.

What if we want two-way travel?


Part 3: Journeyman Rail Systems and Networks

We can certainly build it!


We just follow our intersection steps.

But, watch what happens when a train uses it.


Part 3: Journeyman Rail Systems and Networks

The instant that the train enters the exit block,


the entire line becomes obstructed.

The other train has to wait on the mainline!

No amount of signaling can prevent this.


The entire line is one giant block.
Part 3: Journeyman Rail Systems and Networks
Have you ever stopped at a construction light that turns
a two-way road into a one-way road?

Thats what a two-way rail is


like, except all the time.

So, never let two-way rails merge with


your network at more than one intersection.
(Two-way rails are fine for spurs and stations.)
Part 3: Journeyman Rail Systems and Networks

Instead, every mainline (general transit line) in


your network needs to be at least two one-way lines.

This is called a double-track network.


Part 3: Journeyman Rail Systems and Networks
It is also important to distinguish between two types of double-track networks:
left-hand drive (LHD) and right-hand drive (RHD). There are no significant
advantages or disadvantages for either, but the signaling for all intersections is
completely inverted, so it is important to be consistent with whichever orientation
you pick for your network.

Left-Hand Drive (LHD) Right-Hand Drive (RHD)


Part 3: Journeyman Rail Systems and Networks
Next, lets make a station in our network!

Were going to use a standard one-way intersection


to get to a station off of a RHD double-track, just like we did
back in Part 2.

This time, though, it cant exit; trains can only move forward.
Part 3: Journeyman Rail Systems and Networks
In order to get back onto the mainline, we have
to choose a rail system. The two rail systems
available to choose from are:

The terminal system*


The loop system

There are advantages and disadvantages to both systems.

*The terminal system is often mis-stated as double-header, which means trains with two front engines.
Part 3: Journeyman Rail Systems and Networks

The terminal system involves trains with


engines at both ends (actually called top-and-tail trains, but
well just call them terminal trains).

Stations and spurs for this system are on two-directional lanes


and need a two-way intersection to get back on the mainline.
Part 3: Journeyman Rail Systems and Networks

Terminal system implementations are more


compact than loop system implementations and involve fewer
blueprints, so most Factorio players tend to prefer them.

On the other hand, terminal trains accelerate more slowly due to


the added weight, requiring more engines for larger trains, which
involves larger blocks and larger stations. (Also, theyre ugly.*)

*2-headed trains have no style or soul. There, I said it. -Zisteau


Part 3: Journeyman Rail Systems and Networks
Loop system implementations require extra rails to allow the train to turn around.

They occupy
considerably
more real and require more
estate consideration for For these reasons, loops
pathing/deadlock tend not to be as popular
issues. as terminal systems
for general-purpose use.
Part 3: Journeyman Rail Systems and Networks
Loop stations can also be implemented with a
second one-way intersection, but this
causes real estate problems as well.
In the end, the choice is
Also keep in mind that terminal yours, and since both work
trains can use loop stations, but on a double-track network,
loop trains (one engine) cant back you can use either for your
out of terminal stations. more specialized stations.
Part 3: Journeyman Rail Systems and Networks
Now lets talk block size. Small blocks are usually
fine, but in some cases can cause problems.

Were going to use


this loop station as an example,
but this can happen on any We have an obstruction:
intersection if not managed Theres a train out of fuel on
properly. the eastbound mainline.
Part 3: Journeyman Rail Systems and Networks

The train gets ready to get back onto


the mainline, and its signal is green
because its exit block is clear.
Part 3: Journeyman Rail Systems and Networks

However, its too big to fit into the exit


block, and now the tail of the train
is sticking into the intersection.

This is a big problem because


another train is coming.
Part 3: Journeyman Rail Systems and Networks

So what was once a problem for just


the eastbound line is now also a
problem for the westbound line,
which otherwise would have been
able to pass through.
Part 3: Journeyman Rail Systems and Networks

To fix this situation, we have to


make our exit block bigger.
If the entire train fits, it will
prevent the westbound lane Naturally, moving around all of
from being blocked*. this track is very annoying, so it
would be better for this not to
happen in the first place.

*as long as this station is only used by one train. (See links in the epilogue.)
Part 3: Journeyman Rail Systems and Networks

Well, good news! This just happens to be our final Intersection Principle!

1. Signals before the exit blocks of the intersection.


2. Chain signals every other time a line crosses or
merges with another line.
3. ? ? ?
Part 3: Journeyman Rail Systems and Networks

Well, good news! This just happens to be our final Intersection Principle!

1. Signals before the exit blocks of the intersection.


2. Chain signals every other time a line crosses or
merges with another line.
3. Each exit block must be at least as long as the
longest train that will use it.
Part 3: Journeyman Rail Systems and Networks

1. Signals before the exit blocks of the intersection.


2. Chain signals every other time a line crosses or
merges with another line.
3. Each exit block must be at least as long as the
longest train that will use it.

Following these Intersection Principles for the Golden Rule will make your rail
network almost* immune to deadlocks, as long as you have enough blocks.
Epilogue
So whats next?

Well, now you know how to build deadlock-resistant* rail networks to connect all
of your outlying outposts up to your main production hub.

There are going to be congestion concerns as your network gets bigger, but
theres a lot of subjectivity to how to handle those, which is outside the scope of
our tutorial. There are all kinds of community resources, but now you have the
tools to understand those pictures of giant intersections and how they work.

So congratulations on making it this far. You are now a Journeyman rail network
designer! Now, only practice and patience will make you a Master.
External Links
*It is important to note that high congestion and multiple trains using some stations can still cause
deadlocks. For more details, see Antaios guide to Stations, Junctions, and all things deadlock on the
official forums. As as your network grows, you will need to learn techniques to manage congestion.

There are also a few mods that enhance the rail design and management
experience that you might be interested in:

The Fat Controller is incredibly useful for remotely managing your trains.

Fully Automated Rail Layer (FARL) will place rail and blueprints while you
drive, making rail-laying in the late game much faster.

Resource Spawner Overhaul (RSO) spaces out ore patches and places rich
ore patches much further from the initial spawn, making rails necessary.
Credits
Special thanks to the redditors of /r/factorio who contributed advice, corrections,
and suggestions in discussion threads while I was building the tutorial series:

/u/ak47_killstreak /u/Artorp /u/Calbrenar /u/chocki305


/u/chummchumm /u/cosmicosmo4 /u/DartonRejen
/u/freetambo /u/ichthyos /u/kann_ /u/maxcreeger
/u/Michael_Lewandowski /u/michaelthe /u/NihilRexGaming /u/para_lu
/u/qulqu /u/RedditNamesAreShort /u/rootnegative /u/strangepostinghabits
/u/TeamMisha /u/uffefl /u/w3y

And of course, thanks to the developers of Factorio for making a fantastic game!
Goodbye!

/u/Grays42

You might also like