Page 1 of 1

[2.0.11] Rail planner sometimes produces impossible rail paths

Posted: Sun Oct 27, 2024 8:23 pm
by AntiBlueQuirk
I've noticed that sometimes the rail planner, at least in ghost mode (holding shift) will sometimes produce impossible rail paths, and I've found a particularly bad example.

I'd never want to build the following path anyway, but I'm pretty sure the rail planner shouldn't be suggesting paths that can't actually be built. If you do try to place it, the first half of the ghosts place fine, but the rest just fail to appear where they would overlap with the ramp ghost that now exists.
Screenshot 2024-10-27 151351.png
Screenshot 2024-10-27 151351.png (1.11 MiB) Viewed 564 times
I've attached a minimal save that reproduces the issue in the screenshot. Simply start the rail planner at the right ramp, and while holding shift point it toward the outgoing track on the top side right lane.

I feel like I've noticed this a few other times too, with the rail planner suggesting a path, and then placing it only to find that some of the pieces didn't appear. I figured it was user error, and that was usually corrected by moving supports around, but it might be related. I don't have an example of that, and I might be misremembering anyway.

Re: [2.0.11] Rail planner sometimes produces impossible rail paths

Posted: Sun Oct 27, 2024 8:28 pm
by boskid
I know. That is a won't fix.

If i would want to handle those cases nicely, then the rail planner performance would hit the floor. Its primarily caused by the simplifications of the path finding algorithm that assumes that one part of a solution cannot affect other parts of the solution (Optimal substructure) which ramps do not obey. It was either what we have or no planner for elevated rails at all, and because we really wanted to have elevated rails, a decision was made that we will accept those rare unbuildable solution assuming that a player will see solution is invalid and decide not to built it.

(Ref: 120827)

Re: [2.0.11] Rail planner sometimes produces impossible rail paths

Posted: Sun Oct 27, 2024 8:35 pm
by AntiBlueQuirk
I had a feeling it might be something like that. Pathfinding is a hard problem. It does only seem to happen when the rail planner is getting really desperate anyway. I'm pretty sure the path I'm trying to solve there doesn't have a good solution. (I've been tweaking this intersection for quite a while.)

Re: [2.0.11] Rail planner sometimes produces impossible rail paths

Posted: Sun Oct 27, 2024 8:40 pm
by AntiBlueQuirk
I have an idea. Checking self collision for solutions while pathfinding is not possible for performance reasons, but would it be possible to check the final proposed solution for self collisions? Like, just turn the ghosts red where they would fail to place? That would keep the game from misleading the player about the path being valid, but you'd only need to check collision on one solution instead of every possible one.

Re: [2.0.11] Rail planner sometimes produces impossible rail paths

Posted: Sun Nov 10, 2024 11:35 pm
by untech
Maybe some popup message will be better than a silent fail? This way, it would look like a deliberate behavior, not a bug.

(Coming from 120827)