|
|
|
|
|
by ralfn
4190 days ago
|
|
A long time ago i also wrote a maze generator. It's helpfull to understand the algebra of (fully accessible) mazes: 1. Every wall may intersect with some other wall at most once. (this includes the outer wall) With the above rule in mind, you can create mazes with any type of random proccess (without the need for backtracking or bookkeeping). You don't have to check wether places are still accessible -- they just always are and will be. Back in those days (qbasic on a 268) just drawing randomly from some point in random directions was about ten times faster than the common path walking (backtracking) style algorithms. Taking two seconds instead of a full minute. Don't take my word for it. Grab a pencil. Start drawing random lines. They may only cross some other line at most once. You'll end up with a fully accessible maze. The maze may be complicated -- the walls in a proper maze are not. Its a great example of how understanding the invariants and rules that govern your problem domain will help you write faster and simpler code. |
|