Open olanti-p opened 1 year ago
Got a PR for that WFC based prototype?
I didn't PR it, but it should be in one of these branches, don't recall which exactly: https://github.com/olanti-p/Cataclysm-BN/commits/railroads https://github.com/olanti-p/Cataclysm-BN/commits/railroads-cleaner https://github.com/olanti-p/Cataclysm-BN/commits/railroads-generation
Is your feature request related to a problem? Please describe.
There were supposed to be railroads once upon a time, but they were never implemented in game. Earlier prototypes date back to 2017, which is 6 years ago, but it didn't seem to have progressed anywhere https://github.com/CleverRaven/Cataclysm-DDA/pull/21792
Subways at the moment have multiple problems:
To mitigate the last issue, I've implemented "smooth" (aka "shifting") vehicle movement on rails in #1634 that allows trains to take somewhat smooth turns on appropriately-generated rails, but I haven't got around to implementing the actual railroad generation. The new movement algorithm also handles 45-degree railroad forks (see
vehicle_rails_test.cpp
), and should handle forks implemented for "shifting" movement, but I haven't checked the latter.Describe the solution you'd like
Railroads to be generated on surface, ideally with exit points connecting to overmap edges, railroad stations and other railroad-worthy specials (steel mill, mines, ...)
I made a few prototypes, and driving a train engine over overmap spanning railroads was fun, but I had issues balancing between generation speed, correctness of the generation and "curviness" of turns. Abrupt 45-degree turns ended up with the vehicle ramming terrain quite frequently and derailing the train engine, and more advanced algorithms ended up taking minutes to plot the network on a single overmap or just gave up and didn't connect the points. Curvy turns are just too large to fit into a single overmap tile, and multi-omt turns require much more complex code.
Subways to leverage the same code to generate curvy turns and connect to stations at correct turns. This is a stretch goal, but it would be nice to solve 2 problems with the same code.
Have some world generation connect surface railroad with different layers of subways. The purpose is increasing usefulness of rail vehicles, so if a player chose to use rails they wouldn't be constrained to above-ground locations. This could be themed as maintenance tunnels or secret government access to black sites (like D6 from Metro 2033).
An idea has been suggested on Discord to make the railroads monorail, this way the turns could be both smooth and fit inside a single (or few) overmap tiles.
Additional context
The most promising prototype borrowed some ideas from Wave Function Collapse algorithms and defined railroads as a set of overmap tiles with custom connections on each side, then entire map was scanned for possible placements (type + rotation) of such railroad tiles (graph nodes) and possible connections between the placements (graph edges), then it was just a matter of running A* over the resulting graph. There was an additional restrictions for rail forks and crossings, so the path can proceed inside an overmap tile only through one of the 2 variants (so there couldn't be sharp turns)
It is possible to see different types on the screenshot below by how they use different colors: green for straight, yellow for turn start and turn end, white for fork and x crossing, red for road crossing. Green RRRR is the rail station connected to the network.