I went back and forth with a few different revisions to my corridor codewall, all of which went nowhere. Then I thought about it for a minute, and looked at a piece of placeholder code I had commented out for testing purposes, when inspiration struck me.
It kept writing corridors all over the rooms, even though it wasn't supposed to... even though the code that was supposed to prevent that looks backwards to me, but Mego said it would work and it looked like it would. All the test runs showed the corridors were
trying to get to the doors, but they were either on the wrong side of the map or drawing off in weird directions. And then I figured it out.
It made a list of doors and their coordinates, and tried to walk paths onto one door from another... Except doors were part of its forbidden walking-spaces.
Whoops. So who knows what crazy crap it was trying to do, since the
code worked but the logical underpinnings didn't. Then I revived my test segment, and modified it to move the target-locations to next to the doors.
Okay, so it still looks like total shit, and is still drawing some corridors on the wrong side of the map, but it's not overwriting anything, it's reaching the doors, and it doesn't crash. It is technically everything I needed, and who knows, maybe the extra weird pathways give it some flavor. And I might be able to fix that. And in my desperation I may have come up with a whole new way of making maps, rather than trying to ape NetHack.
Point is, success. Onward and upward.