CCCG 2009, Vancouver, BC, August 17–19, 2009 How to make a picturesque maze Yoshio Okamoto *† Ryuhei Uehara Abstract In the picturesque maze generation problem, we are given a rectangular black-and-white raster image and want to randomly generate a maze in which the solu- tion path fills up the black pixels. While a simple for- mulation of the problem faces with NP-hardness, the proposed method generates such a maze in polynomial time by appropriately changing the formulation itself. Therefore, the algorithm itself is quite simple. Figure 1: An example of a picturesque maze. (Up) A given black-and-white raster image. (Middle) An out- put, where two green rhombi represent the entrance and the exit. (Down) Showing that the solution path gives the input image. * Graduate School of Information Science and Engineering, Tokyo Institute of Technology, okamoto@is.titech.ac.jp Supported by Global COE Program “Computationism as a Foundation for the Sciences” and Grant-in-Aid for Scientific Re- search from Ministry of Education, Science and Culture, Japan, and Japan Society for the Promotion of Science. School of Information Science, Japan Advanced Institute of Science and Technology, uehara@jaist.ac.jp 1 Introduction The goal of this work is to solve the following pic- turesque maze generation problem. Picturesque Maze Generation Problem Input A black-and-white raster image with m rows and n columns. Output A maze in which the solution path fills up the input black pixels. Figure 1 shows an example. The specification of an input and an output is vague: This is intentional. Re- finement of this part is contained in the formulation (or the formalization) of the problem, and this also forms a core of this work. Our formalization and the algorithm have the follow- ing features. We only require the input image to be connected with respect to the 4-neighborhood 1 (good). The solution path of an output precisely coincides with the input image (good). We do not face with any NP-hard subproblems, and the core subroutine is random generation of a span- ning tree in an undirected graph. Therefore, we do not need any complicated algorithm (good). We cannot specify the entrance and the exit arbi- trarily (bad). The quality of an output maze does not have to be high (bad). Maze generation is a subfield of puzzle generation, and it strongly has an artistic aspect. There are some algorithmic studies on maze generation. First, it of- ten appears as an application of random generation of spanning trees, and for example a paper by Propp and Wilson [7] exhibits a randomly generated maze. The webpage “Think Labyrinth!” by Walter D. Pullen [8] explains the outlines of many maze generation algo- rithms. However, these algorithms do not generate a picturesque maze. Not much research has been done for generation of picturesque mazes. For mazes that show pictures as their solutions, as in this work, Conceptis Ltd. de- veloped a generation algorithm, and published several books with lots of picturesque mazes made by it (that 1 Equivalent to the von Neumann neighborhood in the field of cellular automata.