Combinator Wizard needed! Train releaser logic

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
User avatar
TheApplemaster
Burner Inserter
Burner Inserter
Posts: 8
Joined: Thu Nov 09, 2017 9:36 pm
Contact:

Combinator Wizard needed! Train releaser logic

Post by TheApplemaster »

Hi all,

I have spent the past 2 days trying to figure out how to make my station effectively release trains when there is enough demand (e.g. a train load) at an outpost.

For this, I have each outpost wired up to the station which transmit a signal ('I') for every trainload (so 2 trainloads returnes 2 Is). So far so good.

I have a clock running at the stacker I want to manage from, which transmits the above info to each station in the stacker with time inbetween (5 ticks), so that they don't all go at the same time a load is available.

Now the tricky part:
To ensure that the trains don't all go to the same outpost at the same time, I want to provide a negative signal to the trainload 'I' signal the moment a train departs. This I just cannot figure out! I have tried different setups which do provide the correct signal but are reliant on an extra train signal relaying the information - this does not work as the 5 tick pulse already passed to the other stations causing the trains to have their next destination already set, regardless of the signal.

Current setup:
Image


Help is greatly appreciated! My head is spinning all day T_T.

thedarkbunny
Inserter
Inserter
Posts: 46
Joined: Mon Oct 23, 2017 10:46 pm
Contact:

Re: Combinator Wizard needed! Train releaser logic

Post by thedarkbunny »

I've got a few ideas, but I want to make sure I'm clear on the constraints:

- A pulse of negative 'I' should be sent when a train departs the station
- The amount of signal I doesn't matter, so long as it's negative
- The pulse should be sent within five ticks of the train departing, and last no more than five ticks

If yes, I think I can solve the problem with two combinators.

User avatar
TheApplemaster
Burner Inserter
Burner Inserter
Posts: 8
Joined: Thu Nov 09, 2017 9:36 pm
Contact:

Re: Combinator Wizard needed! Train releaser logic

Post by TheApplemaster »

Almost - the negative signal is important as it states that 1 less load is available to the red network. If this increases too much the system will think too many loads are already being serviced.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3713
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Combinator Wizard needed! Train releaser logic

Post by DaveMcW »

You can read the train ID at the station. If the train ID decreases from positive to zero, it has just left.

The logic to detect a decreasing signal is called a "falling edge detector" and can be built in 2 combinators.

Arithmetic combinator: T + 0 → U (saves the value from last tick)
Decider combinator: T < U → I = -1 (input count)

adam_bise
Filter Inserter
Filter Inserter
Posts: 431
Joined: Fri Jun 08, 2018 10:42 pm
Contact:

Re: Combinator Wizard needed! Train releaser logic

Post by adam_bise »

Would this work?

I > 0 output green input

Train 1 wait until green >=1 train 2 until green >=2 etc.

Send train ID to T > 0 output T 1 then to T * -1 output green.

zOldBulldog
Smart Inserter
Smart Inserter
Posts: 1161
Joined: Sat Mar 17, 2018 1:20 pm
Contact:

Re: Combinator Wizard needed! Train releaser logic

Post by zOldBulldog »

My train philosophy is quite different but accomplishes the same thing. Since trains are cheap and easy to build, my goal is to keep the load stations at the mines and unload stations at the base stuffed with trains so that they can move into the stop quickly once they open up. So I don't "send a train" to a mine. Instead I use the same name name for all mines of the same ore and disable them once they are stuffed so that the Pathfinder will route any "on the way" trains to the closest open station, and my stacking is "on arrival" rather than "on departure".

And yet both approaches rely on the same kind of circuitry. You can find my station design at the link below. You can study it to see how to adapt the circuitry to your needs.

https://factorioprints.com/view/-LCyNqfc04vWxjS8v8DG

Key factors to "full/available" design is to either monitor the state of the stop (T > 0 when occupied) or to monitor the state of the signals behind the stop.

If you rely on signals, keep in mind of how your logic will interact with trains as they enter/exit the station... Perfectly good logic for trains "at the stop" might fail while the trains enter/exit.

In the end the best logic is often the simplest one that fully satisfies your goal.

Dimanper
Inserter
Inserter
Posts: 47
Joined: Sat Sep 17, 2016 9:50 am
Contact:

Re: Combinator Wizard needed! Train releaser logic

Post by Dimanper »

You can make a counter somewhere to store how many trains are on their way to the destination at any given moment. It would require additional signal to work from sending station to the destination without any additional fancy pulse logic. [a] is the signal in my example. Send [a = -1] single pulse to circuit network every time a train leaves the sending station/stacker and [a = 1] with each train leaving the outpost. then feed this [a] signal as to the train sending logic.
If you don't like additional signal showing in the circuit network all the time, you could just make the counter local, even counting in signal straight away, with additional combinator which converts [a] to from the circuit network to this counter.
If you are interested in using only one or whatever signal without additional ones for this logic i could also give you some examples of how to it.

User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2638
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

Re: Combinator Wizard needed! Train releaser logic

Post by steinio »

Dimanper wrote:You can make a counter somewhere to store how many trains are on their way to the destination at any given moment. It would require additional signal to work from sending station to the destination without any additional fancy pulse logic. [a] is the signal in my example. Send [a = -1] single pulse to circuit network every time a train leaves the sending station/stacker and [a = 1] with each train leaving the outpost. then feed this [a] signal as to the train sending logic.
If you don't like additional signal showing in the circuit network all the time, you could just make the counter local, even counting in signal straight away, with additional combinator which converts [a] to from the circuit network to this counter.
If you are interested in using only one or whatever signal without additional ones for this logic i could also give you some examples of how to it.


I had a similiar idea with a counter but there are not enough letters for all the materials.
Now i use a circular belt as time lock to let only one train depart in a given time if a requester signal is 1 - so not all trains will depart at the same time.
Image

Transport Belt Repair Man

View unread Posts

Post Reply

Return to “Gameplay Help”