POV-Ray : Newsgroups : povray.binaries.images : Rectangular Mazes : Re: Rectangular Mazes Server Time
3 May 2024 05:52:40 EDT (-0400)
  Re: Rectangular Mazes  
From: Christian Froeschlin
Date: 11 Feb 2012 19:21:45
Message: <4f370619$1@news.povray.org>
Samuel Benge wrote:

> Care to give an overview of the algorithm?

I don't know what Robert used, but generating a maze was one of the
exercises in the introduction to computer science course I took way
back when I was young ;) There we were to apply a strategy called
union-find, a general way to manage disjoint partitions of sets.

The application here was to imagine a grid where each tile could
either be free or filled with a wall, and start out with a with a
"maze" consisting of completely disconnected rooms (or, in the
language of the data structure, one-element subsets).

######...
# # #
######...
# # #
######...
...

You can then randomly merge two rooms by removing a common wall,
if available. In the union-find structure they are replaced by a
two-element subset, so that basically manages the list of already
connected component. Repeat the process until only one subset is
left (this generates a maze where every two rooms are connected
by exactly one path).


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.