I really like having a good excuse to break out the combinators for Factorio to optimize the heck out of my setups, particularly with trains.

A lot of us who have done this before know that you can disable your train stations until they have a full load of cargo, at which point they will enable and essentially call all of the available trains with that stop on the network. Furthermore you can set conditions that the station will disable when it is occupied so that all of the other trains have the ability to path to new stations.

Right now this is relatively simple to do; you just have one combinator each for checking one row of chests that loads into one wagon, tick over when it contains a full wagon's worth of cargo, and then send that signal along. At the end of this signal you have another combinator which will compare this number and if it's equal to N, where N is the number of wagons on each train, it enables the station.

However, this is a very simplistic design. It doesn't account for the fact that you only need one full train load for the station to enable, which might call multiple trains over. But then again, it doesn't need to be any more complex than this - because in 1.0 and earlier, trains are agnostic to how many of them can queue up at one station anyway.

According to the latest FFF, the new train stop limit mechanic which can be modified by the circuit network has some HUGE implications for optimization. To put it this way: theoretically, you could have a train stop that instead of enabling/disabling, will keep the limit at 0 until it has one full load of cargo, then when it has a full load, increase to 1, then 2, etc. The end result is having a train stop that only calls the number of trains needed to empty out the station's stockpile. This would be a very elegant solution in comparison to the aforementioned, sloppier station behavior.

In the interest of getting a blueprint designed for this new type of station, I got to work on building out this new logic in anticipation for 1.1. Specifically, the intended behavior is to have one combinator for each row of chests, then have each of those count how many wagon loads are available instead of the binary "there is one or more wagon load here". This in itself is trivial, since each wagon can hold 4.0k ore, you can simply take the input of all the chests and divide it by 4.0k, and the output will be 1 for one wagon load, 2 for two, etc.

However, I ran into a problem. How do I take N signals (where N is the number of wagons per train), and operate on them to determine what the lowest number of each one is, and set the train stop limit equal to that? This prevents a scenario where an uneven number of wagon loads in each row of chests causes more trains to arrive than resources are available. In my case, I use a 2-4-0 train convention, so each station has 4 wagon slots. I set each slot to A, B, C, and D respectively. I want to compare each of these signals against each other and pick the lowest number. I spent a good hour doing trial and error and could not for the life of me figure this out.

I googled the problem and the only thing I found was a post on arduino.cc detailing how to do the same thing with an arduino:

Code: Select all

```
lowVal = myArray[0]; // just to start it off
for (byte n = 0; n < 4; n++) {
if (myArray[n] < lowVal) {
lowVal = myArray[n];
}
}
```

Does anyone have any ideas on this? Thanks!