Railcraft

Railcraft

34M Downloads

[Request] Smart train routing with shortest path problem

liach opened this issue ยท 4 comments

commented

If you have a lot of stations and switches in a railway line, it would be confusing for players to write all the stations in a single routing table. A universal graph of all the stations and switches can be created and we can route trains based on the shortest path problem.

commented

Why would you ever list all your stations in every table? That is madness.

Define "regions", put those in the Routing Table, get more specific as you get closer to the goal.

Destinations are prefix matched against the routing table.

"north/forest/base/factory" will match against "north", "north/forest", "north/forest/base", and "north/forest/base/factory".

So if you have a bunch of different stations in your north forest base, you just need to tell the carts how to get "north", then to the "north/forest", then to the "north/forest/base" and finally to the station.

What you are suggesting is also madness of a different sort. That's a huge design problem, with many pitfalls and edge cases.

commented

I believe we can implement this. We may consider each switch as a node, and we don't necessarily need to list all the stations, but we just put the next node the switch goes to and the type of the railway (We can add one-directional restrictions, can handle trains in different directions, etc) The graph for trains will be like enet; you can make it in entity too if you'd like to.

commented

Also @Generalcamo for opinions

commented

I guess its possible if you serialize the graph separately from the nodes themselves. Seems annoying to build though.