From 4a5c576630287a7b4b1c23e66fd7ee9f9a555359 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Thu, 17 Mar 2022 16:28:04 +0800 Subject: [PATCH] refactor --- src/maze/mz_hamiltonian.scad | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/maze/mz_hamiltonian.scad b/src/maze/mz_hamiltonian.scad index 2e903366..f2582bdb 100644 --- a/src/maze/mz_hamiltonian.scad +++ b/src/maze/mz_hamiltonian.scad @@ -28,15 +28,11 @@ function mz_hamiltonian(rows, columns, start = [0, 0], init_cells, seed) = all = concat( [ for(cell = cells) - let( - x = cell.x, - y = cell.y, - type = mz_square_get(cell, "t") - ) - each if(type == "TOP_WALL") _mz_hamiltonian_top(x, y) else - if(type == "RIGHT_WALL") _mz_hamiltonian_right(x, y) else - if(type == "TOP_RIGHT_WALL") _mz_hamiltonian_top_right(x, y) else - if(type == "MASK") _mz_hamiltonian_mask(x, y) + let(type = mz_square_get(cell, "t")) + each if(type == "TOP_WALL") _mz_hamiltonian_top(cell.x, cell.y) else + if(type == "RIGHT_WALL") _mz_hamiltonian_right(cell.x, cell.y) else + if(type == "TOP_RIGHT_WALL") _mz_hamiltonian_top_right(cell.x, cell.y) else + if(type == "MASK") _mz_hamiltonian_mask(cell.x, cell.y) ], [for(x = [0:c * 2 - 1]) [x, 0]], @@ -44,4 +40,4 @@ function mz_hamiltonian(rows, columns, start = [0, 0], init_cells, seed) = ), dot_pts = dedup(sort(all, by = "vt")) ) - _mz_hamiltonian_travel(dot_pts, start * 3, r * c * 4); \ No newline at end of file + _mz_hamiltonian_travel(dot_pts, start * 2, r * c * 4); \ No newline at end of file