diff --git a/src/maze/_impl/_mz_wang_tiles_impl.scad b/src/maze/_impl/_mz_wang_tiles_impl.scad index 0801efd3..360c1db7 100644 --- a/src/maze/_impl/_mz_wang_tiles_impl.scad +++ b/src/maze/_impl/_mz_wang_tiles_impl.scad @@ -1,4 +1,5 @@ -use <../../util/has.scad>; +use <../../__comm__/_pt2_hash.scad>; +use <../../util/set/hashset_has.scad>; function _mz_wang_tiles_top(x, y) = let( @@ -21,13 +22,14 @@ function _mz_wang_tiles_top_right(x, y) = ) [[nx + 1, ny + 2], [nx + 2, ny + 1]]; +hash = function(p) _pt2_hash(p); function _mz_wang_tile_type(dots, x, y) = let( px = x * 2 + 1, py = y * 2 + 1, - c1 = !has(dots, [px, py + 1], sorted = true) ? 1 : 0, - c2 = !has(dots, [px + 1, py], sorted = true) ? 2 : 0, - c3 = !has(dots, [px, py - 1], sorted = true) ? 4 : 0, - c4 = !has(dots, [px - 1, py], sorted = true) ? 8 : 0 + c1 = !hashset_has(dots, [px, py + 1], hash = hash) ? 1 : 0, + c2 = !hashset_has(dots, [px + 1, py], hash = hash) ? 2 : 0, + c3 = !hashset_has(dots, [px, py - 1], hash = hash) ? 4 : 0, + c4 = !hashset_has(dots, [px - 1, py], hash = hash) ? 8 : 0 ) c1 + c2 + c3 + c4; diff --git a/src/maze/mz_wang_tiles.scad b/src/maze/mz_wang_tiles.scad index afb7f4de..7c456db7 100644 --- a/src/maze/mz_wang_tiles.scad +++ b/src/maze/mz_wang_tiles.scad @@ -11,9 +11,7 @@ use <../__comm__/_pt2_hash.scad>; use <_impl/_mz_wang_tiles_impl.scad>; use ; -use <../util/sorted.scad>; use <../util/set/hashset.scad>; -use <../util/set/hashset_elems.scad>; function mz_wang_tiles(cells, left_border = true, bottom_border = true) = let( @@ -45,10 +43,7 @@ function mz_wang_tiles(cells, left_border = true, bottom_border = true) = [type == "TOP_WALL" || type == "NO_WALL" ? 1 : 0, y * 2 + 1] ] ), - dot_pts = sorted( - hashset_elems(hashset(all, hash = function(p) _pt2_hash(p))), - function(a, b) let(d = a - b) d.y == 0 ? d.x : d.y - ) + dot_pts = hashset(all, hash = function(p) _pt2_hash(p)) ) [ for(y = [0:rows - 1], x = [0:columns - 1])