Answer the question
In order to leave comments, you need to log in
Has anyone seen a fast algorithm to dynamically generate an endless cave maze?
All the algorithms that I have found so far are generated in a field of a given size. And you need to generate on the go as you move, while avoiding collisions.
Can someone tell me the name of a ready-made algorithm that works according to such a scheme, or the direction in which to dig information to build the desired cave))
Answer the question
In order to leave comments, you need to log in
The condition is simple: in order to always have a way out, you need to maintain a turn gap - at least 2 tunnels nearby. U-turn - do along your "body" outward, so as not to run into a dead end.
(I.e., here is an algorithm to prevent snake entanglement)
It seems to be the same algorithm, with the only difference that the generation is carried out not until the space for generation runs out, but until the specified depth (or distance) from the current position is reached.
And then optimization moments begin, which depend on the nuances of the task. For example, in 2D you will most likely need to fill the screen and a little bit behind the screen. And in 3D, a straight corridor will have to be made endlessly until it finally turns, because the first-person user must see the end of the corridor, and not the void, no matter how long it may be.
Further it is not clear how you store the data. If you don't have a field of a given size, then at least some field is there? Or do you have each cell/room/connection as a separate object in the heap? And the labyrinth is essentially not a grid, but a graph? The algorithm also depends on this.
If there is a formula, then by analogy with fractals (you can also connect a random number generator).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question