I've been enjoying Factorio, and I particularly enjoy all the mini optimization problems it presents. One of the issues I was trying to answer was whether roundabouts or cross intersections really are noticeably different for throughput. Thanks to viewtopic.php?f=18&t=18621 I managed to actually build them correctly. But one of the things I actually needed was a way to tell how many trains were passing through the intersection. I had tried to do the counting manually, but the raw throughput of a simple intersection is really hard to count, and even harder if you want to track directions separately.
Code: Select all
H4sIAAAAAAAA/+VXYW+bMBD9KxVfBxWG0E3qvD9STZFDnMQasZlttlUo/31nwhKbQGqTbuu0fckod+e7d+/dmbW4q0RJqrslbinXTDOqcNtysqc4UnsidcK4
olJTGcW1UGAgOG5/YHRfxM84WdwXh3jNJC27F1lcCs6PDxDnKULRZ9xuJaXgdDzgecnW+P0htp7QhwP8M65r1nuWTJYN07jdMKn0UrEtJxVu9XMNeTFN91Hc
56gprZK6IppGXQilCdc4hf/uayKJFhJHGF5VYsuUZqXyiSkk2dIEIn2ZDvopgpw3rAJoDGSMrynAMpYW2LX2n8sdVdqFMz3DaRlLwrY7ncBP5Zrnxtg2vdKp
xWinHhy4A8CR5HuyYWp3HZhTZr8iH4tOemjdDIux4psVxDYWrm2CjGnuV3pP0nweSZFD0hs4Woq6pvLtkdTNKwjSbK7uZ4PIpOBvD0I7K3+ZZ67MrxvnITMh
n1SepF8b+B3204Q3jsg0dEUkRqkXD0wNJ78/P1ZWREFlAAZXtYAkV7TS44WlA6YGVZeOVOczOdz9luXzaV8RyC/RjZRU29ggB5uPYcQPBPsqUuk0Dy6QknR9
FafMfSziHqbLaey+y14NX0VNlIH9NyZ1Q6rT2OheJmmHngPZ7xk+gz6MTIoEWXT1Av7BRRPmcjxC4+JwCDnemiHeK9Y+YEPUSzSbVPPLA8GKELLpZhE7ez1G
ThPjb7EtHXbbDxJXwMDAS25N9P44yQetX/hSrPi3h2/QGrd60hsup24uTm1wfGPqss4lkundnnYni/2KcZPbqCjRrJmTp+50HxtAro3RVPwUZRPBh10+FzDe
k/GpjqaWwPRHp4BLdPelgqN3USwaXTd+Z6XRIexKg85NtoTgJyJ0FpHnav4vdqrv3nDWhq8Tsp38BZX7tWh4Pzqr41JJl7ZhYrnyOfuiWpwvt9liQfPEkk+J
xTtCNj9CegoQ7JSHOfW5FjdXu7i12sWcaovAao9eD/Mvg321N0Q4pwCZs7JT0WDFjise7B9hMDaS3y0fKV//BNsuoIGDFQAA
The key part of the "counting" is being able to insert only a single stack onto the train at a time. So every station gets an item of copper/iron/steel plate, and when a train stops we load 1 stack of whatever item is available at this station.
- Is the reservoir of whatever material this station is going to be delivering.It is a smart chest limited to 1000 items.
- Is set up to load into the staging box only when there is nothing in the box already, and a token is waiting.
- Is the staging box. There should only ever be 1 stack of items in this box.
- Is the inserter. Set to only transfer items if there is a token in the token box.
- Is the token box. I chose a laser turret because of the icon.
- only takes the token out when it notices box 3 become empty.
- just returns the token once it has taken its time to get back.
- will be described later
- to be described later.
- A timing belt. I set my trains to stop for 5s, so this makes the token take slightly longer than 5s to arrive back at 7
8 & 9 are present just to allow me to use exactly the same pattern at all train stations. They count copper-plates + iron-plates => signal 1, steel-plates + signal 1 => signal 0. That way I can fill 1 with copper, iron or steel plates and everything just keeps working.
There is one other nice feature here, which is that all of these are set up with the Logistic parameter "number of Storage Drums > 0". It doesn't really matter what the token is, but it means that I can start (and stop) all of the counters at exactly the same time. I don't happen to be storing Storage Drums normally.
This is what actually counts where the trains came from. Only tricks here are that 2-4 all use the "number of Storage Drums" so that they stop accumulating at the same time. They also are on a green circuit network which says "don't accumulate whatever is in the storage pool". That way the station that delivers iron-plate won't count iron-plate.
This is the "initialize" / "reset" logic. I got really tired of putting 1 token into the token box all the time, and when you finish doing some counting, the trains will still have some items in them. Also, you need to fill the storage pool before you start doing anything.
1 is a simple requester box initialized to empty in the blueprint, so I don't end up filling the wrong item. But once I lay it down I can set it to request 100 of the right plate, and leave it. The inserter at 2 will fill the pool at 3 (which is capped at 1000 items).
4,5,6,7 is all my trick to get a single item initialized into the token box. With upgrades, inserters can move 5 items at once between boxes, but only 1 item to/from belts. So I use a requester (which requests a single token, but logistic bots carry at least 2), 5 loads it onto the belt 6, and 7 has circuit connection to only load onto 8 if it is empty. 2 & 7 also have a Logical connection that only when a "Raw Fish" > 0 do they do any work. This gives me a "when do I reset" phase.
9 is also watching for Raw Fish and just pulls whatever is left on the train off again, 10 is just a Logical Storage chest to allow the bots to take any waste.
Overall, it works pretty well. A few tweaks I might make if I play with it more:
- Don't use Iron/Copper/Steel plates. Changing to some other item would let you integrate it into a real system and have it running alongside for you to do debugging of your real network throughput.
- Accumulators could go to the same box. Slightly easier to count 1 box than 3. It would also allow for a "Reset" phase that automatically removed everything from the accumulator box into a Logical Storage chest. As it stands, I have to manually go around to read the final counts, so it isn't that hard to just shift-right-click the items away when I'm done counting.
- shrink it if possible. As it stands it *just* fits in a 4-wide train spacing, which sometimes means having to move other things out of the way.
- add a 4th item being tracked to allow for N, S, E, W tracking. Its really nice to measure something like a T junction, but if you wanted an 4-way it wouldn't quite work. Its a bit hard to get both horizontal and vertical tracking with too many more inserters, and I don't know a way to do a logical "don't pull out X if X is in that box over there" without manually tweaking the filters. As is, there is only 1 box you need to set up per location (the requester chest), and the rest is all handled by Fish vs Storage Drum, and manually emptying the accumulators.
I guess what I'd rather have is a crossing counter. Something that looked a bit like a Rail Chain Signal, that just had a counter for how many trains passed by it. This is slightly more flexible, as it lets you track where trains came from and where they went to (how many copper plates from South got to North, etc).