In other languages: Deutsch 한국어 Português, Brasil Русский 简体中文

Transport belts/Physics: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
m (fixed link)
m (→‎Belt properties: fix redirect)
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Languages}}
{{Languages}}
{{sublinks}}
The [[belt transport system]] in Factorio is among the most detailed simulations in the game. Items in chests and other containers are stored simply as summed totals, and items on uninterrupted stretches of belts are [https://www.factorio.com/blog/post/fff-176 moved in aggregate] as an optimization, but in the end items on belts are simulated individually, especially when they get picked up or put down by inserters. This leads to some intricate behaviors, in particular when it comes to [[Inserters#Inserter_Throughput|inserter throughput]].


In Factorio, every item on screen is a real object in memory that follows the rules of the Game engine. For simulation games, this is not typical; it's much more common to generalize. For example, the older versions of SimCity do not simulate every inhabitant in the city.
== Belt properties ==


The reason for this is CPU performance. Real-time game physics for up to tens of thousands of objects at the same time is not typical for a simulation game. The Factorio Game engine creates an exact and reproducible simulation of the Factorio world, so exact that it can be used to measure some astonishing behaviors of belts.
* '''Density'''. How many items fit onto a certain length of belt, measured in items per [[Map_structure#Tile|tile]] per belt lane. This is 4 on a straight belt, regardless of the type of item and type of belt. The item density on belts can be different from what they take up when just dropped on the ground (using the Z key).


== What to measure ==
* '''Speed'''. The speed of items on a belt is measured for practical reasons in tiles per second. Note that internally it is measured in positions (1/256 tile) per tick (1/60 sec). More on that below. The speed of a basic [[transport belt]] is 1.875 tiles per [[Time#Seconds|game-second]]. [[Fast transport belt]] is twice as fast, and [[express transport belt]] is three times as fast.
Some stats can be measured for belts:


* '''Length''' (or area). Items have a collision box of 0.28125 × 0.28125 [[tile (unit)|tile]]s. So, 10 items laying in a single row on a belt non moving take the length of 2.8125 tiles.
* '''Throughput'''. How many items per second that are moved from one tile to the next. That is density (items per tile) multiplied by speed (tiles per second), e.g. for a basic belt it is 4 * 1.875 = 7.5 items per second, for one belt lane. For both lanes it is doubled, i.e. 15 items per second.
* '''Speed'''. The speed of items on a belt is measured for practical reasons in tiles/sec or tiles/min. Note that internally it's measured in tiles per tick (1/60 sec). The speed of basic belt is 0.03125 tiles per tick (1/32) or 1.875 tiles per [[Game-second]].
* '''Density'''. The density is ''items per tile''. How many items can lay on a tile or in conjunction with belts: how many items can lay in a row/lane. There are in average 3.5555556 items per lane or 7.11 (32/9*2) on a tile of belt (2 lanes). Which means in practical terms that on a fully compressed belt there can be either 6, 7 or 8 items during one tick.
* '''Throughput'''. How many items per minute are moved from one tile to the next. Measured in items/sec or better items/min. That is for basic belt density (items per tile) multiplied with speed (tiles per second): (1/32 tiles/tick) / (9/32 items/tile) = 0.111111111 items per tick or 6.666666667 items per second for one lane. For two lanes it is then 13.33 items/second.


== How to calculate these numbers yourself ==
* '''Compression'''. If there is no empty space between items on the belt it is called ''fully compressed'', otherwise its compression is only partial and it does not have optimal throughput. Entities that put items onto belts - [[inserters]], [[splitters]], other belts coming from the side, mining drills, etc - make room for their item by [https://forums.factorio.com/viewtopic.php?f=3&t=57993 enlarging a small gap] until it is exactly big enough for the item. That means belts naturally become fully compressed before items start to back up.


=== Introduction ===
* '''Lanes'''. Belts have two parallel lanes, and the density and speed of each lane is constant and independent of the other one, regardless of twists and turns. So items in the inner lane of a turn exit it before those in the outer lane, since their speeds are equal and the inner lane is shorter than the outer one.
Belts have two ''lanes'': The left and right lane.


Each lane of a belt consists out of 32 '''slots'''. A slot is just a virtual position on the belt with the width of 1/32 tiles (= 0.03125 tiles).
== Belt speeds ==


An item that is put on a belt (on a lane) takes 9 slots of space. This shows the size of items: 0.28125 × 0.28125 tiles (9/32 = 0.28125). 32/9 items (3.55 items) can fit on one lane of one belt. Essentially, up to 8 items can fit on one belt at any tick.
Given the values above we can calculate the speed and throughput of the three types of belts. Measurements confirm these values.
<pre>
Step by step movement of an item on a belt-lane. <---*---> represents an item, and the slots it consumes.
 
  |==============================|  <-----  32 slots
1  <---*---><---*---><---*---><---* 4 items
2  ><---*---><---*---><---*---><--- 3 items
3  -><---*---><---*---><---*---><-- 3 items
4  --><---*---><---*---><---*---><- 3 items
5  ---><---*---><---*---><---*--->< 3 items
6  *---><---*---><---*---><---*---> 4 items
7  -*---><---*---><---*---><---*--- 4 items
8  --*---><---*---><---*---><---*-- 4 items
9  ---*---><---*---><---*---><---*- 4 items
</pre>


Speed: Each [[Game-tick|tick]] an item on a belt (the 9 slots it takes) is moved by one slot. The least common multiple of 9 and 32 is 288. After 9 tiles, the slots are repeating their positions.  
{| class="wikitable"
! rowspan=2 | Belt type || colspan=2 | Speed || colspan=4 | Throughput
|-
! Factor || Tiles/sec || Single lane, items/sec || Single lane, items/min || Both lanes, items/sec || Both lanes, items/min
|- align="center"
| align="left" | {{Imagelink|Transport belt|Transport belt}} || 1 || 1.875 || 7.5 || 450 || 15 || 900
|- align="center"
| align="left" | {{Imagelink|Fast transport belt|Fast transport belt}} || 2 || 3.75 || 15 || 900 || 30 || 1800
|- align="center"
| align="left" | {{Imagelink|Express transport belt|Express transport belt}} || 3 || 5.625 || 22.5 || 1350 || 45 || 2700
|}


=== Curves ===
== Items on belts ==
The inner lane has 13.5 slots, compared to the outer 37 slots. In the end, 6 or 7 items can be in a curving belt at once.


Yes, the interior has a fractional slot: every odd interior curve is 14 slots and every even interior curve is 13 slots.
As mentioned earlier, items take space on belts in terms of density and compression. However, every item on a belt is logically ''on'' exactly one belt tile at any moment in time.


=== The faster belts ===
For example, even though in a screenshot it might look like an item is halfway out from one tile and halfway onto the next, it will be accounted to exactly one of the two tiles:
To obtain higher speeds on higher tier belts, the quantity of slots that each item moves per tick is multiplied. For [[Fast transport belt]]s two slots, for [[Express transport belt]]s 3 slots. That explains why fast belts are exactly 2 times faster, than basic and express belt is 3 times faster than basic.
* If you stop the belt tile the item is on, it stops; else it continues moving - there are no in-between states.
* If you connect the two belt tiles to a circuit network and get them to [[Belt_transport_system#Circuit_network|report statistics]] about the items they carry, you will see the item being accounted to exactly one of them.
* An inserter can only pick up items that are logically on the tile in front of it, not items butting in from the neighboring tiles.


== Theory ==
In this sense it is useful to think of items as points with a certain minimum distance between them, rather than things with an area lying next to each other. For belt calculations and circuit networks involving belts it doesn't really matter where those "center points" are within the graphic of the item, but they appear to be in the middle:
The data here is taken from the transport-belt prototypes (Version 0.13.3 until (excluding) 0.17).


{| class="wikitable"
[[Image:Belts-with-one-tick-offsets.png|center]]
|-
! scope="col" | belt-type
! scope="col" | factor basic belt speed
! scope="col" | speed (tiles/tick)
! scope="col" | speed (tiles/sec)
! scope="col" | speed (tiles/min)
! scope="col" | density (single lane) items/tile
! scope="col" | density (two lanes) items/tile
! scope="col" | throughput (2 lanes) items/sec
! scope="col" | throughput items/min
|-
|<span style="color:#FFFFC8">Basic</span>
|align="center" |1
|align="center" |0.03125
|align="center" |1.875
|align="center" |112.5
|align="center" |3.556
|align="center" |7.111
|align="center" |13.33
|align="center" |800.00
|-
|<span style="color:#FFB4B5">Fast</span>
|align="center" |2
|align="center" |0.0625
|align="center" |3.75
|align="center" |225
|align="center" |3.556
|align="center" |7.111
|align="center" |26.66
|align="center" |1600.00
|-
|<span style="color:#D7D7FF">Express</span>
|align="center" |3
|align="center" |0.09375
|align="center" |5.625
|align="center" |337.5
|align="center" |3.556
|align="center" |7.111
|align="center" |40.00
|align="center" |2400.00
|}


We assume here that the density of items is always equal and maximum compressed (see above), so the transported amount should reflect the speed.
In the image above the belts have been started at 1 tick offsets, then all the top row tiles have been stopped at once, causing the front-most stopped items to poke out by varying amounts. The items on the leftmost belt are almost halfway into the next tile, which means their center points are the closest to the edge of the upper stopped tile.


For measured results see '''[[Transport_belt_experiments|Transport belt experiments]]'''.
Below is a schematic example showing some items moving over two straight [[fast transport belt]] tiles and what their read signals would be at each tick. Their center points are marked with <code>*</code>. (The space between belt tile 1 and 2 is only for visualisation - in the game there are no such gaps between tiles.)


== History ==
<pre>
'''This is outdated and should be outsourced from this article but not deleted, because it is an interesting fact.'''
Tick  Belt tile 1                      Belt tile 2                      Read belt tile 1  Read belt tile 2
<div class="toccolours mw-collapsible mw-collapsed" style="width:800px">
      |------------------------------| |------------------------------|    Pulse  Hold      Pulse  Hold
Kept for historical purposes, expand to view
  0        <---*-->  <---*--> <---*-- ><---*-->            <---*-->        0      3        0      2
<div class="mw-collapsible-content">
  1          <---*-->  <---*--> <---* --><---*-->            <---*-->      0      3        0      2
   
  2            <---*-->  <---*--> <-- -*--><---*-->            <---*--      0      2        1      3
; Theory
  3              <---*-->  <---*--> < ---*--><---*-->            <---*      0      2        0      3
  4  ->            <---*-->  <---*-->  <---*--><---*-->           <--      0      2        0      2
  5  *-->            <---*-->  <---*- -> <---*--><---*-->            <      1      3        0      2
  6  --*-->            <---*-->  <--- *--> <---*--><---*-->                 0      2        1      3
  7  <---*-->            <---*--> <- --*--> <---*--><---*-->              0      2        0      3
  8    <---*-->            <---*-->  <---*--> <---*--><---*-->            0      2        0      3
</pre>


{| class="wikitable"
== Belt positions and lengths ==
|+Expected results 13.2 or older
|-
! scope="col" | belt-type
! scope="col" | factor basic belt speed
! scope="col" | speed (tiles/tick)
! scope="col" | speed (tiles/sec)
! scope="col" | speed (tiles/min)
! scope="col" | density (single lane) items/tile
! scope="col" | throughput (2 lanes) items/sec
! scope="col" | throughput items/min
|-
|Basic
|align="center" |1
|align="center" |0.03125
|align="center" |1.875
|align="center" |112.5
|align="center" |3.571
|align="center" |13.39125
|align="center" |803.475
|-
|Fast
|align="center" |2
|align="center" |0.0625
|align="center" |3.75
|align="center" |225
|align="center" |3.571
|align="center" |26.7825
|align="center" |1606.95
|-
|Express
|align="center" |3
|align="center" |0.09375
|align="center" |5.625
|align="center" |337.5
|align="center" |3.571
|align="center" |40.17375
|align="center" |2410.425
|}


; Measured Results for v0.11 or Older
[https://forums.factorio.com/viewtopic.php?f=5&t=70055 Careful measurement] shows that the outer lane of a turn is exactly 1.15234375 times longer than a straight belt, or 295/256 in fractional format. That means each straight belt tile has 256 ''positions'' an item can be in, even though measuring the position with that precision can only be done indirectly.


With Factorio v0.12 new belt physics was introduced. Before that the items where moved as real objects (which means, they need to look forward, if there is space to move), with 0.12 the items are moved "per lane". Also the physics in curves changed so that curves are now not longer have lower throughput.
Here are the speeds and lengths of the various types of belt tiles in terms of these positions:


{| class="wikitable"
{| class="wikitable"
| This results have been measured with a special designed factory (a complicated setup to guarantee, that only the running items on a belt are measured and a "timer" which stops the measuring exactly) and Factorio v0.6.x, so this has to be redone.
! colspan=2 | What || Number of positions
See [http://www.factorioforums.com/forum/viewtopic.php?f=8&t=1144&start=10#p8361 forum article]
|}
 
{| class="wikitable"
|+Simple straight belt
|-
|-
! scope="col"| belt-type
| colspan=2 | Basic [[transport belt]] speed, per tick || align="center" | 8
! scope="col"| throughput items/min
! scope="col"| throughput items/sec
! scope="col"| percent of awaited
! scope="col"| comments
|-
|-
|Basic
| colspan=2 | [[Fast transport belt]] speed, per tick || align="center" | 16
|align="center" | 719
|align="center" | 11.98
|align="center" | 90%
|
|-
|-
|Fast
| colspan=2 | [[Express transport belt]] speed, per tick || align="center" | 24
|align="center" | 1184
|align="center" | 19.73
|align="center" | 74%
|This is NOT double as fast as basic! it's only 1.65 times faster
|-
|-
|Express
| colspan=2 | Length of an item on a belt (of any speed) || align="center" | 64
|align="center" | 1775
|align="center" | 29.58
|align="center" | 74%
|About 2.5 times faster than basic
|}
 
 
{| class="wikitable"
|+Belt with 4 turns (2 left, 2 right, see down into next chapter)
|-
|-
! scope="col"| belt-type
| colspan=2 | Length of one lane of a straight belt tile, underground belt, and splitter || align="center" | 256
! scope="col"| throughput items/min
! scope="col"| comments
|-
|-
|Basic
| colspan=2 | Length of the inner lane of a turn || align="center" | 106
|align="center" | 477-486
| About 1.5 times slower. This is because the '''inner lane''' of a belt in a turn has only the half speed.
|-
|-
|Fast
| colspan=2 | Length of the outer lane of a turn || align="center" | 295
|align="center" | 786-792
|
|-
|-
|Express
| style="border-right: 0px" | Length travelled by an item sideloaded late on a straight belt or underground exit
|align="center" |1038-1042
| style="border-left: 0px" | [[Image:Sideload-late.gif]] || align="center" | 68
|
|}
 
 
{| class="wikitable"
|+Belt with 4 turns (2 left, 2 right), but faster belt at the edges
|-
! scope="col"| belt-type
! scope="col"| throughput items/min
! scope="col"| comments
|-
|Basic with fast edge-belts
|align="center" | 674-683
|
|-
|-
|Fast with express edge-belts
| style="border-right: 0px" | Length travelled by an item sideloaded early on a straight belt or underground entrance
|align="center" | 1058-1061
| style="border-left: 0px" | [[Image:Sideload-early.gif]] || align="center" | 188
|The fast belt with express edge seems to be faster, than pure express belt!
|}
|}


; Comments to the results
For example, given the figures above, we can deduce the speed of a basic belt:
 
The first surprising result is, that the theoretic throughput differs from real measured. Too much to be just measurement errors.The second result is, that the more speed a belt has, the more ineffective it becomes. That is in the first moment not clearly explainable. The awaited result is, that a fast belt can transport exactly the double amount of items, than a basic, because it is double as fast (1.875 tiles/sec vs. 3.75 tiles/sec).
 
The reason for this difference is the distance of the items on the belt when running. Items on the belt cannot run completely compressed, they need a small distance. This is the same problem as in a traffic jam: You cannot drive, when the first car drives, you need to wait until the car before you drives and then you have a reaction-time of about 1/2 second before yourself begin to drive. The same is it with the items on the belt and the reaction-time here is 1/60 or one tick [currently not really validated, but not more than 2 ticks; this can be calculated by measuring how fast the standing wave goes through the items (needs to built a very complicated testing factory)]. You can see this reaction time running through your items as a standing wave, when you have a belt, which is completely filled and only sometimes an item is removed. When you compare the speed of this standing waves, you can see clearly, that they are the same speed for all types of belts.
 
The reaction-distance for items on a basic belt is
  (1.875 tiles/sec) / 1 tick = 1.875 tiles/sec / 1/60 sec = 0.031125 tiles
or in other words: An item on a moving belt is not 0.28 tiles long, it is 0.31125 tiles, which makes it 11.2% longer
 
Overview for all belts:
  Basic:  0.28 tiles + 0.03125 tiles = 0.31125 tiles => 11.2%
  Fast:    0.28 tiles + 0.0625 tiles  = 0.3425 tiles  => 22.3%
  Express: 0.28 tiles + 0.09375 tiles = 0.37375 tiles => 33.5%
This explains the reduction to 90% of speed for basic belt and the 74% for the fast belt (all inside measuring errors), but doesn't explain the results for express belt. This is part of further research.
 
This shows clearly, that the faster a belt is, the more distance the items have on a moving belt. More distance means, the density is lighter and this means, there are not so many items transported.


(This may explain the discrepancy in transported items, but don't use the numbers for real calculations, because they need to be redone!)
: 8 (positions per tick) / 256 (positions per straight belt tile) * 60 (ticks per second) = 1.875 tiles per second
(This is eventually one reason: http://www.factorioforums.com/forum/viewtopic.php?f=8&t=3630 )


A possible reason for this: http://www.factorioforums.com/forum/viewtopic.php?f=16&t=6817
Its throughput per belt lane is:


</div></div>
: 8 (positions per tick) / 64 (positions per item) * 60 (ticks per second) = 7.5 items per second


== See also ==
== See also ==
* [[Belt transport system]]
* [[Belt transport system]]
* [https://forums.factorio.com/viewtopic.php?f=18&t=33685 Factorio: a quantitative guide]
* Jan 04 FFF #276: [https://www.factorio.com/blog/post/fff-276 Belt item spacing & Script rendering]
* Feb 03 FFF #176: [https://www.factorio.com/blog/post/fff-176 Belts optimization for 0.15]
* [https://forums.factorio.com/viewtopic.php?f=5&t=70055 Accurate belt segment measurements] (discusses 0.17)


{{C|Belt transport system}}
{{C|Belt transport system}}

Revision as of 12:45, 7 November 2019

The belt transport system in Factorio is among the most detailed simulations in the game. Items in chests and other containers are stored simply as summed totals, and items on uninterrupted stretches of belts are moved in aggregate as an optimization, but in the end items on belts are simulated individually, especially when they get picked up or put down by inserters. This leads to some intricate behaviors, in particular when it comes to inserter throughput.

Belt properties

  • Density. How many items fit onto a certain length of belt, measured in items per tile per belt lane. This is 4 on a straight belt, regardless of the type of item and type of belt. The item density on belts can be different from what they take up when just dropped on the ground (using the Z key).
  • Speed. The speed of items on a belt is measured for practical reasons in tiles per second. Note that internally it is measured in positions (1/256 tile) per tick (1/60 sec). More on that below. The speed of a basic transport belt is 1.875 tiles per game-second. Fast transport belt is twice as fast, and express transport belt is three times as fast.
  • Throughput. How many items per second that are moved from one tile to the next. That is density (items per tile) multiplied by speed (tiles per second), e.g. for a basic belt it is 4 * 1.875 = 7.5 items per second, for one belt lane. For both lanes it is doubled, i.e. 15 items per second.
  • Compression. If there is no empty space between items on the belt it is called fully compressed, otherwise its compression is only partial and it does not have optimal throughput. Entities that put items onto belts - inserters, splitters, other belts coming from the side, mining drills, etc - make room for their item by enlarging a small gap until it is exactly big enough for the item. That means belts naturally become fully compressed before items start to back up.
  • Lanes. Belts have two parallel lanes, and the density and speed of each lane is constant and independent of the other one, regardless of twists and turns. So items in the inner lane of a turn exit it before those in the outer lane, since their speeds are equal and the inner lane is shorter than the outer one.

Belt speeds

Given the values above we can calculate the speed and throughput of the three types of belts. Measurements confirm these values.

Belt type Speed Throughput
Factor Tiles/sec Single lane, items/sec Single lane, items/min Both lanes, items/sec Both lanes, items/min
Transport belt.png
Transport belt
1 1.875 7.5 450 15 900
Fast transport belt.png
Fast transport belt
2 3.75 15 900 30 1800
Express transport belt.png
Express transport belt
3 5.625 22.5 1350 45 2700

Items on belts

As mentioned earlier, items take space on belts in terms of density and compression. However, every item on a belt is logically on exactly one belt tile at any moment in time.

For example, even though in a screenshot it might look like an item is halfway out from one tile and halfway onto the next, it will be accounted to exactly one of the two tiles:

  • If you stop the belt tile the item is on, it stops; else it continues moving - there are no in-between states.
  • If you connect the two belt tiles to a circuit network and get them to report statistics about the items they carry, you will see the item being accounted to exactly one of them.
  • An inserter can only pick up items that are logically on the tile in front of it, not items butting in from the neighboring tiles.

In this sense it is useful to think of items as points with a certain minimum distance between them, rather than things with an area lying next to each other. For belt calculations and circuit networks involving belts it doesn't really matter where those "center points" are within the graphic of the item, but they appear to be in the middle:

Belts-with-one-tick-offsets.png

In the image above the belts have been started at 1 tick offsets, then all the top row tiles have been stopped at once, causing the front-most stopped items to poke out by varying amounts. The items on the leftmost belt are almost halfway into the next tile, which means their center points are the closest to the edge of the upper stopped tile.

Below is a schematic example showing some items moving over two straight fast transport belt tiles and what their read signals would be at each tick. Their center points are marked with *. (The space between belt tile 1 and 2 is only for visualisation - in the game there are no such gaps between tiles.)

Tick  Belt tile 1                      Belt tile 2                       Read belt tile 1  Read belt tile 2
      |------------------------------| |------------------------------|    Pulse   Hold      Pulse   Hold
  0         <---*-->  <---*--> <---*-- ><---*-->            <---*-->         0       3         0       2
  1           <---*-->  <---*--> <---* --><---*-->            <---*-->       0       3         0       2
  2             <---*-->  <---*--> <-- -*--><---*-->            <---*--      0       2         1       3
  3               <---*-->  <---*--> < ---*--><---*-->            <---*      0       2         0       3
  4   ->            <---*-->  <---*-->  <---*--><---*-->            <--      0       2         0       2
  5   *-->            <---*-->  <---*- -> <---*--><---*-->            <      1       3         0       2
  6   --*-->            <---*-->  <--- *--> <---*--><---*-->                 0       2         1       3
  7   <---*-->            <---*-->  <- --*--> <---*--><---*-->               0       2         0       3
  8     <---*-->            <---*-->   <---*--> <---*--><---*-->             0       2         0       3

Belt positions and lengths

Careful measurement shows that the outer lane of a turn is exactly 1.15234375 times longer than a straight belt, or 295/256 in fractional format. That means each straight belt tile has 256 positions an item can be in, even though measuring the position with that precision can only be done indirectly.

Here are the speeds and lengths of the various types of belt tiles in terms of these positions:

What Number of positions
Basic transport belt speed, per tick 8
Fast transport belt speed, per tick 16
Express transport belt speed, per tick 24
Length of an item on a belt (of any speed) 64
Length of one lane of a straight belt tile, underground belt, and splitter 256
Length of the inner lane of a turn 106
Length of the outer lane of a turn 295
Length travelled by an item sideloaded late on a straight belt or underground exit Sideload-late.gif 68
Length travelled by an item sideloaded early on a straight belt or underground entrance Sideload-early.gif 188

For example, given the figures above, we can deduce the speed of a basic belt:

8 (positions per tick) / 256 (positions per straight belt tile) * 60 (ticks per second) = 1.875 tiles per second

Its throughput per belt lane is:

8 (positions per tick) / 64 (positions per item) * 60 (ticks per second) = 7.5 items per second

See also