diff --git a/examples/maze/cylinder_maze.scad b/examples/maze/cylinder_maze.scad index b534d5f6..362c71b7 100644 --- a/examples/maze/cylinder_maze.scad +++ b/examples/maze/cylinder_maze.scad @@ -38,7 +38,7 @@ module cylinder_maze() { maze_blocks = mz_square_blocks( [1, maze_rows], maze_rows, maze_columns, - x_circular = true + x_wrapping = true ); walls = mz_square_walls(maze_blocks, maze_rows, maze_columns, block_width, left_border = false); diff --git a/examples/maze/heart2heart_maze.scad b/examples/maze/heart2heart_maze.scad index 3123e610..3fc43e31 100644 --- a/examples/maze/heart2heart_maze.scad +++ b/examples/maze/heart2heart_maze.scad @@ -33,7 +33,7 @@ module heart_base(name, font_name, font_size, radius, ring_thickness, tip_r_of_h module heart2heart_maze(names, font_name, font_size, radius_of_heart, tip_r_of_heart, wall_thickness, cblocks, levels, spacing) { maze = mz_square_blocks( [1, 1], - cblocks, levels, y_circular = true + cblocks, levels, y_wrapping = true ); translate([0, 0, wall_thickness]) diff --git a/examples/maze/heart_maze.scad b/examples/maze/heart_maze.scad index aa252727..11066da1 100644 --- a/examples/maze/heart_maze.scad +++ b/examples/maze/heart_maze.scad @@ -108,7 +108,7 @@ module heart_maze(maze, radius, cblocks, levels, thickness = 1) { maze = mz_square_blocks( [1, 1], - cblocks, levels, y_circular = true + cblocks, levels, y_wrapping = true ); intersection() { diff --git a/examples/maze/mobius_maze.scad b/examples/maze/mobius_maze.scad index 28481123..24e7118a 100644 --- a/examples/maze/mobius_maze.scad +++ b/examples/maze/mobius_maze.scad @@ -17,7 +17,7 @@ a_step = 360 / leng; blocks = mz_square_blocks( [1, 1], rows, columns, - y_circular = true + y_wrapping = true ); walls = mz_square_walls(blocks, rows, columns, block_width, bottom_border = false); diff --git a/examples/maze/regular_polygon_maze.scad b/examples/maze/regular_polygon_maze.scad index 5f6244cf..8632d755 100644 --- a/examples/maze/regular_polygon_maze.scad +++ b/examples/maze/regular_polygon_maze.scad @@ -51,7 +51,7 @@ module regular_polygon_maze(radius, cblocks, levels, thickness = 1, sides) { maze = mz_square_blocks( [1, 1], - cblocks, levels, y_circular = true + cblocks, levels, y_wrapping = true ); difference() { diff --git a/examples/maze/sphere_maze.scad b/examples/maze/sphere_maze.scad index b5351481..81fd895b 100644 --- a/examples/maze/sphere_maze.scad +++ b/examples/maze/sphere_maze.scad @@ -54,7 +54,7 @@ module sphere_maze() { blocks = mz_square_blocks( [1, 1], rows, columns, - y_circular = true + y_wrapping = true ); p_offset = [block_width * rows, pole_offset, 0]; diff --git a/examples/maze/torus_maze.scad b/examples/maze/torus_maze.scad index f682d7b8..62279fd7 100644 --- a/examples/maze/torus_maze.scad +++ b/examples/maze/torus_maze.scad @@ -17,7 +17,7 @@ a_step = 360 / leng; blocks = mz_square_blocks( [1, 1], rows, columns, - x_circular = true, y_circular = true + x_wrapping = true, y_wrapping = true ); walls = mz_square_walls(blocks, rows, columns, block_width, left_border = false, bottom_border = false); diff --git a/src/maze/_impl/_mz_blocks_impl.scad b/src/maze/_impl/_mz_blocks_impl.scad index bdeac84d..33832467 100644 --- a/src/maze/_impl/_mz_blocks_impl.scad +++ b/src/maze/_impl/_mz_blocks_impl.scad @@ -56,9 +56,9 @@ function rand_dirs(c, seed) = // get x value by dir _next_x_table = [1, 0, -1, 0]; -function next_x(x, dir, columns, circular) = +function next_x(x, dir, columns, wrapping) = let(nx = x + _next_x_table[dir]) - circular ? + wrapping ? nx < 1 ? nx + columns : ( nx > columns ? nx % columns : nx ) @@ -67,9 +67,9 @@ function next_x(x, dir, columns, circular) = // get y value by dir _next_y_table = [0, 1, 0, -1]; -function next_y(y, dir, rows, circular) = +function next_y(y, dir, rows, wrapping) = let(ny = y + _next_y_table[dir]) - circular ? + wrapping ? ny < 1 ? ny + rows : ( ny > rows ? ny % rows : ny ) @@ -115,17 +115,17 @@ function carve(dir, x, y, maze, rows, columns) = // find out visitable dirs from (x, y) -function visitable_dirs(r_dirs, x, y, maze, rows, columns, x_circular, y_circular) = [ +function visitable_dirs(r_dirs, x, y, maze, rows, columns, x_wrapping, y_wrapping) = [ for(dir = r_dirs) - if(visitable(next_x(x, dir, columns, x_circular), next_y(y, dir, rows, y_circular), maze, rows, columns)) + if(visitable(next_x(x, dir, columns, x_wrapping), next_y(y, dir, rows, y_wrapping), maze, rows, columns)) dir ]; // go maze from (x, y) -function go_maze(x, y, maze, rows, columns, x_circular = false, y_circular = false, seed) = +function go_maze(x, y, maze, rows, columns, x_wrapping = false, y_wrapping = false, seed) = let( r_dirs = rand_dirs(x * rows + y, seed), - v_dirs = visitable_dirs(r_dirs, x, y, maze, rows, columns, x_circular, y_circular) + v_dirs = visitable_dirs(r_dirs, x, y, maze, rows, columns, x_wrapping, y_wrapping) ) // have visitable dirs? len(v_dirs) == 0 ? @@ -135,33 +135,33 @@ function go_maze(x, y, maze, rows, columns, x_circular = false, y_circular = fal v_dirs, set_visited(x, y, maze), rows, columns, - x_circular, y_circular, + x_wrapping, y_wrapping, seed = seed ); // try four directions -function walk_around_from(x, y, dirs, maze, rows, columns, x_circular, y_circular, i = 0, seed) = +function walk_around_from(x, y, dirs, maze, rows, columns, x_wrapping, y_wrapping, i = 0, seed) = // all done? i < len(dirs) ? // not yet walk_around_from(x, y, dirs, // try one direction - try_routes_from(x, y, dirs[i], maze, rows, columns, x_circular, y_circular, seed), + try_routes_from(x, y, dirs[i], maze, rows, columns, x_wrapping, y_wrapping, seed), rows, columns, - x_circular, y_circular, + x_wrapping, y_wrapping, i + 1, seed) : maze; -function try_routes_from(x, y, dir, maze, rows, columns, x_circular, y_circular, seed) = +function try_routes_from(x, y, dir, maze, rows, columns, x_wrapping, y_wrapping, seed) = // is the dir visitable? - visitable(next_x(x, dir, columns, x_circular), next_y(y, dir, rows, y_circular), maze, rows, columns) ? + visitable(next_x(x, dir, columns, x_wrapping), next_y(y, dir, rows, y_wrapping), maze, rows, columns) ? // try the block go_maze( - next_x(x, dir, columns, x_circular), next_y(y, dir, rows, y_circular), + next_x(x, dir, columns, x_wrapping), next_y(y, dir, rows, y_wrapping), carve(dir, x, y, maze, rows, columns), rows, columns, - x_circular, y_circular, + x_wrapping, y_wrapping, seed ) // road closed so return maze directly diff --git a/src/maze/mz_square_blocks.scad b/src/maze/mz_square_blocks.scad index 31db5ba9..d6fc096c 100644 --- a/src/maze/mz_square_blocks.scad +++ b/src/maze/mz_square_blocks.scad @@ -1,9 +1,9 @@ use <_impl/_mz_blocks_impl.scad>; use ; -function mz_square_blocks(start, rows, columns, maze, x_circular = false, y_circular = false, seed) = +function mz_square_blocks(start, rows, columns, maze, x_wrapping = false, y_wrapping = false, seed) = go_maze( start[0], start[1], // starting point is_undef(maze) ? mz_square_initialize(rows, columns) : maze, - rows, columns, x_circular, y_circular, seed + rows, columns, x_wrapping, y_wrapping, seed );