Maze generation: Difference between revisions

m
→‎{{header|POV-Ray}}: Explanation added about iterative approach
(Added POV-Ray solution)
m (→‎{{header|POV-Ray}}: Explanation added about iterative approach)
(2 intermediate revisions by the same user not shown)
Line 7,279:
 
=={{header|POV-Ray}}==
This POV-Ray solution uses an iterative rather than recursive approach because POV-Ray has a small stack for recursion (about 100 levels) and so the program would crash on even quite small mazes. With the iterative approach it works on very large mazes.
<syntaxhighlight lang="pov">
#version 3.7;
Line 7,289 ⟶ 7,290:
#declare Cols = 17;
 
#declare Seed = seed(2); // A seed willproduces alwaysa produce the samefixed sequence of pseudorandom numbers
 
#declare Wall = prism {
0, 0.8, 7,
<0, -0.5>, <0.05, -0.45>, <0.05, 0.45>, <0, 0.5>, <-0.05, 0.45>, <-0.05, -0.45>, <0, -0.5>
<-0.05, 0.45>, <-0.05, -0.45>, <0, -0.5>
texture {
pigment {
Line 7,348 ⟶ 7,350:
#local Col = floor(rand(Seed)*(Cols-1) + 0.5); // Random start column
#local Top = -1;
#local Max = -1;
Push(Stack, Top, Row, Col, Row, Col)
 
Line 7,377 ⟶ 7,378:
Push(Stack, Top, Row, Col, Row, Col-1)
#end
#end
 
#if (Top > Max)
#declare Max = Top;
#end
 
Line 7,441 ⟶ 7,438:
 
light_source {
<-0.1*Cols, Rows, 0.5*Rows>, colour rgb <1, 1, 1>
area_light
x, y, 3, 3
Line 7,467 ⟶ 7,464:
</syntaxhighlight>
{{out}}
[[File:Povray maze solution 640px.png|640px|frame|none|alt=POV-Ray maze with red brick walls|POV-Ray solution with 15 rows and 17 columns]]
 
=={{header|Processing}}==
12

edits