I'm sure there is a name for this sort of problem / algorithm but I can't seen to get anything useful off google.
Imagine you have an infinite grid, and you are generating a path along cells in the grid one cell at a time. Each cell (other than the first) has one side that is an entrance, and another side that is an exit. There is no branching.
For example, this is a finite grid where there is no dead end:
And here is one where the is an obvious inevitable dead end:
I'm looking for any sort of algorithm that would help be build this one cell at a time.
Ideally it could be implemented as a function that I provide a list of all cells in the current path, and it provides 1-3 directions that guarantee there will be no dead end.
The generated path does not have any constraints, I don't care if it is dense or sparse, as long as it can keep generating one cell at a time.
One idea I had was creating a “bounding shape” that contains all cells of the existing path, and not permitting generating in that. Maybe using some sort of string pulling algorithm to build the shape.
I'm open to any other suggestions.
Thanks