Let's talk train design
Posted: Wed Sep 24, 2025 12:53 pm
Here is something that's currently on my mind. We all want to build a logistic train system in vanilla. It sounded so easy in the FFF. Here's the problem: The natural way to do it with interrupts doesn't work with multiple provider stations. I think by now, all the train afficianados know the type of design I'm talking about. You have requester stations that put a request for X train loads of an item on the global (radar) circuit network, and provider stations open up based on that request. The trouble is that if you broadcast a need for 1 train load of red circuits, every red circuit provider turns on with a train limit of 1. Your logistic trains get deployed on the same tick and you end up with oversupply.
So I want to brain storm with people who know a lot about trains and the circuit network. Here are my current ideas, all of which are unsatisfying due to the included weaknesses.
- When a train arrives at a provider, have it double check demand levels before loading.
---- Weaknesses: Un-needed trains still get deployed. Some designs which are based on reducing requests by the C signal will briefly under-request while trains are leaving a provider and on the way to a requester, so additional delays may occasionally be introduced as trains are deployed, returned, and deployed again when the signal reappears.
- Have centralized deployment of trains from wait stations.
---- Reason: Allows for more complex logic in deployment of trains via complex combinator contraptions
---- Weaknesses: Trains can only be deployed from a wait station. During periods of high load, this will congest the train network further as trains are completing additional trips (back to the wait station). Also, adding a bunch of logic to determine how many trains to send increases complexity and thus makes the solution less maintainable and more brittle.
- Random assignment. When demand is positive, have providers randomly decide (by coin flip) whether to turn on. Only stop this procedure when the number of stations voting to enable equals the demand signal.
---- Weaknesses: Not sure I even have to state them. This is just a bad idea...but I had the idea, so I'm including it for completeness.
- Have centralized logic that determines which stations to turn on.
---- Weaknesses: How do you identify each individual station without a bunch of nasty circuit logic? I don't want to implement TDM or something just for my logistic train design.
- Round Robin activation. Let's say you have 2 providers of an item. Then station one sets its limit to (Demand+1 / 2) and station two sets it to (Demand / 2). So...for demand 1, station one has limit 1 and station 2 has limit 0. For demand 2, it's 1 and 1. For demand 3, it's 2 and 1. So on.
---- Reason: Simplicity. One additional combinator required at each provider.
---- Weaknesses: first of all you have an additional global variable to track (and update every time you add a stop!) which is the number of providers for an item type. This could be as simple as using an additional global signal of a different color. If you're broadcasting demand on red, broadcast the number of providers on green. The real issue is that you have to figure out how to deal with the situation when one of the stations is out of items or can't accept its assigned limit of trains. It needs additional logic to "put its assigned trains back on the global network" somehow. Once again, that means more combinators and more special cases that make it more fragile and harder to patch.
So. Please, if you are like me and like to think about trains and circuits, I'd love to hear your thoughts.
So I want to brain storm with people who know a lot about trains and the circuit network. Here are my current ideas, all of which are unsatisfying due to the included weaknesses.
- When a train arrives at a provider, have it double check demand levels before loading.
---- Weaknesses: Un-needed trains still get deployed. Some designs which are based on reducing requests by the C signal will briefly under-request while trains are leaving a provider and on the way to a requester, so additional delays may occasionally be introduced as trains are deployed, returned, and deployed again when the signal reappears.
- Have centralized deployment of trains from wait stations.
---- Reason: Allows for more complex logic in deployment of trains via complex combinator contraptions
---- Weaknesses: Trains can only be deployed from a wait station. During periods of high load, this will congest the train network further as trains are completing additional trips (back to the wait station). Also, adding a bunch of logic to determine how many trains to send increases complexity and thus makes the solution less maintainable and more brittle.
- Random assignment. When demand is positive, have providers randomly decide (by coin flip) whether to turn on. Only stop this procedure when the number of stations voting to enable equals the demand signal.
---- Weaknesses: Not sure I even have to state them. This is just a bad idea...but I had the idea, so I'm including it for completeness.
- Have centralized logic that determines which stations to turn on.
---- Weaknesses: How do you identify each individual station without a bunch of nasty circuit logic? I don't want to implement TDM or something just for my logistic train design.
- Round Robin activation. Let's say you have 2 providers of an item. Then station one sets its limit to (Demand+1 / 2) and station two sets it to (Demand / 2). So...for demand 1, station one has limit 1 and station 2 has limit 0. For demand 2, it's 1 and 1. For demand 3, it's 2 and 1. So on.
---- Reason: Simplicity. One additional combinator required at each provider.
---- Weaknesses: first of all you have an additional global variable to track (and update every time you add a stop!) which is the number of providers for an item type. This could be as simple as using an additional global signal of a different color. If you're broadcasting demand on red, broadcast the number of providers on green. The real issue is that you have to figure out how to deal with the situation when one of the stations is out of items or can't accept its assigned limit of trains. It needs additional logic to "put its assigned trains back on the global network" somehow. Once again, that means more combinators and more special cases that make it more fragile and harder to patch.
So. Please, if you are like me and like to think about trains and circuits, I'd love to hear your thoughts.