From 55c61ffb74f733f4f77843543ba4b521d44177d6 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Sun, 10 Apr 2022 18:59:20 +0800 Subject: [PATCH] refactor: 1st dir is always visitable --- src/experimental/_impl/_mz_cube_impl.scad | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/experimental/_impl/_mz_cube_impl.scad b/src/experimental/_impl/_mz_cube_impl.scad index 5942008f..ef998a52 100644 --- a/src/experimental/_impl/_mz_cube_impl.scad +++ b/src/experimental/_impl/_mz_cube_impl.scad @@ -152,7 +152,19 @@ function go_maze(x, y, z, cells, layers, rows, columns, x_wrapping = false, y_wr // have visitable dirs? leng_v_dirs == 0 ? nxcells0 : // road closed // try four directions - let(nxcells1 = next_cells(x, y, z, v_dirs[0], nxcells0, layers, rows, columns, x_wrapping, y_wrapping, z_wrapping, seed)) + let( + dir = v_dirs[0], + nx = next_x(x, dir, columns, x_wrapping), + ny = next_y(y, dir, rows, y_wrapping), + nz = next_z(z, dir, layers, z_wrapping), + nxcells1 = go_maze( // try the cell + nx, ny, nz, + carve(dir, x, y, z, nxcells0, layers, rows, columns), + layers, rows, columns, + x_wrapping, y_wrapping, z_wrapping, + seed + ) + ) leng_v_dirs == 1 ? nxcells1 : let(nxcells2 = next_cells(x, y, z, v_dirs[1], nxcells1, layers, rows, columns, x_wrapping, y_wrapping, z_wrapping, seed)) leng_v_dirs == 2 ? nxcells2 :