Immersive Railroading

Immersive Railroading

3M Downloads

[suggestion] ability to automate trains railcraft style

cola98765 opened this issue ยท 14 comments

commented

I played a lot on railcraft with friends. we had long railways with many automated trains rolling around delivering resources from place to place. I really like this mod for what it is now, but to be useful I think it need a few things.

  1. stations
    There is already a way to automate stations on closed tracks using detectors and control augments.
    However an augment so trains would know where to stop, and after redstone is applied it would resume with previous speed settings.
    For ballance this block can work only at low speeds so near the stations i need to slow train in other ways.

  2. Smart switch track and ticket system
    In railway systems more complicated than 2 stations connected by track there is a need to correctly direct trains to correct stations.
    To make that work a train needs to know where to go hence the ticket with target station name OR set of nodes to that station... let me explain.
    a) target station approach
    By each switch track there should be detector that have list of stations and send signal to switch if I set that this station is there.
    b) set of nodes approach
    Instead of setting every switch track to ever station I set only the name of the next node/intersection.
    When new station is added I only change few nodes around it and I'm done

  3. layering tracks or better track itersections
    This idea comes more from factorio than railcraft. There you can layer normal tracks with curved ones which allows to create nice 4 way intersection like this
    image
    while in this mod T intersection (I didn't try to make 4 way yet) looks like this
    2018-08-13_19 15 45

  4. signals
    Maybe there is no collision damage, but making my trains organised would be nice.
    Signals would work similar to stations where train try to stop before it and see it from certain distance.
    the difference being that signal detects whether there is a train in next sector (for optimisation there may be distance limit) and change color accordingly.
    Signals can also look at next signal and if next is red it can change to yellow.
    Player can then set what train should do it it sees certain signal (slow at yellow, stop at red, return to speed limit at green)

  5. speed limits
    Power limiter is fine, but more automated approach where train looks at speed signs and try to restrict speed accordingly would be nice. This way if I have different trains on the track they all will be able to climb hills and come at station at save speeds.

  6. configurable size of cargo capacity
    108 stacks seems like a lot, but then it's only 4 chests. 85 buckets is better as it's 10 basic tanks in most mods

  7. more intuitive turns
    I like this system of customization of lengths of turns, but I'm missing something or tracks are often misaligned. Thay do work, but just look a bit off.
    Here I suggest some sort of presets... 45deg and aligned to grid... 22.5deg and move track by X...

This list will probably be expanded when i'll remember what things I miss.

commented

added 7.

about 2.
Even naming trains (and detecting that name) would work...
Without any system like that players are forces to lay new track when they want to create new automated line. I've been there (openTTD without lamps, factorio without lamps, vanilla MC) and believe me, it's not good solution.

about my picture in 3.
I checked and to make that kind of intersection, first I need to put tracks apart as far as I want the radius to be.

other attempts.
Brown means places where i would be able to place tracks, but I'm lazy.
Red means places where (afaik) I can't place track at the moment.
Blu part on second pic refers to 7. where i needed to use smooth mode, which triggers me.
2018-08-14_00 47 08
2018-08-14_00 50 12

commented
  1. A station system is already planned for 3.0.
  2. That feature is handy, but may not be in the base mod (possibly an add on later)
  3. have you tried switches and intersections? (Also in your picture, those radii are much to small for many trains in the mod)
  4. Some of our devs are working on a signals add on.
  5. Good idea, and I believe we have that on a to do list already.
  6. Might be a json file setting in the future.
commented

Just a note for signalling and automation in general from long term railcraft experience:

The core of the problem is chunkloading at high speeds and in general. You need to dynamically load chunks around the train (and even more of those around when player is in train), and especially ahead ones. The top speed and momentum are limited by this a lot, because you also need to fit all signalling into the interval of loaded chunks. And when you load the chunk ahead of you with another halted train, you need to have enough space to stop, or you get accident.

As trains in IR can decellerate based on their momentum, thus it can vastly exceed the area of loaded chunks ahead of the train (which won't be bigger than 7-10 chunks on default), the problem is that you need to get the signal and start braking way before the server will get the idea that there is another train ahead (it can be just a lonely cart without locomotive, standing on rails...).

So signalling is not really a trivial thing. Having all railroad chunks loaded is not quite an option, that would kill performance. Having tracked all trains and carts might be better, but then you also need to track on which rail line they are, and if it is same connected track, as just coords are not enough. As it is now (that you cannot cross the tracks randomly), the code might connect rails from intersection to intersection and track trains according to that. But the layering of tracks would completely kill such thing. It works in factorio or OTTD, because there the whole rail system is in memory and all trains tracked (while in both games the braking distance is perfectly inside one signal block compared to IR and Minecraft capabilities).

Btw - if there would be system to load chunks in tube rather than ball around player, then it would help enormously.

Also, @cola98765 : You are in Minecraft, use 3D for intersections. Get the main line elevated and T junction below it to cross without touching. Problem solved. Also it would be with least junctions possible, thus way easier to signal. (Yep, I did constructed full 4way clover junctions in OTTD so trains don't limit each other, but here you are thinking too much 2D factorio xD ). Also it is good idea to have tracks distanced from each other so you can do S from one line into another ;-)

commented

3D intersections.
Yes, it's possible, but problem of size still exist. I haven't tested that, but I believe that 1in10 would be very steep.
And let's just say making compact intersection is one of the smallest problems here...

Track layering
OK... forget about that... What I need is ability to cross tracks at different angles than 90deg. You could expand intersection (track) giving it angle setting, and ability to place it at angle.

about chunk loading
In that server I referenced all tracks were chunk loaded, but you are right that would kill performance on larger networks.

Tubular chuncklading
What if train were to spawn multiple fake chunk loaders along the track? I think that would work.

Long deceleration with signals
How far would you see from train anyway? 4 chunks? 8? I'm not saying about place to stop whatever happens, only sort of information for fake driver that he needs to stop. This is why I said about yellow signals so it can slow down to so it can stop in distance that is loaded. And if I made signals too dense so train does not have time to slow after yellow that's my problem.
Here you would need to chunk load only signals and 8 chunks in front of moving train.

Lone car placed in the middle of track
When placed and destroyed (and only then) it should look both ways in search of signals up to max distance between them, and update them.
In any other case you will go past the signal so it can send information back that train just passed.
It can also count individual cars in case of splitting train in the middle of section

Also what if you were to make a graph of railway, signals, and distances.
train asks where on that graph is rail that train is on and check signals that are not stored in the chunk itself... Just a thought, but this way you only need to load chunks that train is on, and distance between signals can be far greater.

commented

Speaking of keeping the rail system in memory, is it even feasible in IR?

commented

we already use a graph system to manage rails across the map, and will use a similar system for electric power.

commented

I have been working on this for a year now in my spare time. It is a separate mod, because in my opinion this kind of thing should not be in the main mod.

The following features are already working:

  • An in-memory graph of all rails in each world, which gets updated when rails are placed or removed. Currently supports the following rail types (but more will be added):
    • Straight
    • Turn
    • Crossing
    • Switch
  • A signaling graph that contains sections and signals.
  • The sections are created and updated based on the signals that are placed next to rails and is updated when rails get placed or removed.
  • Signals can have a station name.
  • Signals can be a "chain signal". This means that it will copy the aspect of the signal that is ahead in the path.
  • The aspect (the color red/yellow/green) of the signals get calculated based on the following things:
    • Section occupancy: when a rolling stock is occupying a section, all the signals pointing to that section turn RED.
    • When a train has acquired a section (after it reserved the section for itself), the section's signals will turn RED except the signal that the train will enter the section from.
    • When a path from a signal does not lead to another signal (because the state of switches or because the rail ends), the signal will turn RED.
    • When a signal is RED, the previous signal (based on the current active path) will turn YELLOW, unless it is a "chain signal" in which case the previous signal turns RED.
    • When a signal is YELLOW and the previous signal is a "chain signal", the previous signal turns YELLOW.
  • Path finding is implemented for automatic trains that have a set destination train stop.
  • Based on the path finding, the train adds reservations for the sections that it will visit.
  • The train will acquire (get exclusive access) a section when:
    • The train is 1st on the reservation list and the entry signal is not a chain signal. If the entry is a chain signal, the section after the current section needs to successfully be acquired too.
    • The train is not 1st on the section reservation list but can still acquire sections according to the rules above. Trains in this step are ranked by reservation rank over all its reserved sections, so that trains will acquire sections in a fair order.
  • Aspect calculation is multithreaded.
  • Section reservation and acquirement is multithreaded.
  • Rail graph and signaling graph get loaded into memory on world load. After the graphs are fully loaded, the chunks get unloaded so that only train chunks are loaded. This saves a lot on memory and performance, as the graphs have a small memory footprint. The benefit is also that train path finding and aspect calculation can use information from rails and signals that are currently not in a loaded chunk.
  • Signal aspect information gets synced with clients when the chunk is loaded.

The following features will be required for a v1 release:

  • Support more rail types.
  • Fix aspect calculation for section acquirement.
  • Recalculate optimal path for automatic trains, and remove reservations for sections that are not in the new path.
  • Implement train scheduling logic + make a GUI for configuration and setting a train to manual/automatic.
  • Remove section reservations when a train is set to manual.
  • Add train station logic, like when a train should leave for the next station.
  • Drive trains automatically (throttle, brake and switching rails) based on train destination.
  • Add support for manual trains; especially regarding path finding, active switch state, section acquirement and calculating aspect.
  • Fix item, block and error translations.

Here's a preview image:

https://i.imgur.com/KnyKZqP.png

commented

Wow, that's pretty awesome

commented

Any progress on this?

commented

Honestly not planned atm

commented

Sadly, I just lost all of my project files, and I cannot recover them; meaning the mod I mentioned I was making is also lost. Years of work poof gone.

I will probably not continue making the mod, so anyone who wants this feature can feel free to take inspiration from my earlier comment and make their own mod.

commented

ouch, that's a heavy loss...

commented

If you have a jar kicking around somewhere you can usually decompile it using a tool like jad to recover your source code in some form

commented

Sadly, no .jar. The latest sources I have are from late 2018, so that's too bad.