mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-19 13:01:37 +02:00
try visitable dirs
This commit is contained in:
@@ -137,21 +137,24 @@ function try_block(dir, x, y, maze, rows, columns) =
|
|||||||
|
|
||||||
|
|
||||||
// find out visitable dirs from (x, y)
|
// find out visitable dirs from (x, y)
|
||||||
_visitable_dir_table = [0, 1, 2, 3];
|
function visitable_dirs(r_dirs, x, y, maze, rows, columns, x_circular, y_circular) = [
|
||||||
function visitable_dirs(x, y, maze, rows, columns, x_circular, y_circular) = [
|
for(dir = r_dirs)
|
||||||
for(dir = _visitable_dir_table)
|
|
||||||
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_circular), next_y(y, dir, rows, y_circular), maze, rows, columns))
|
||||||
dir
|
dir
|
||||||
];
|
];
|
||||||
|
|
||||||
// go maze from (x, y)
|
// 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_circular = false, y_circular = 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)
|
||||||
|
)
|
||||||
// have visitable dirs?
|
// have visitable dirs?
|
||||||
len(visitable_dirs(x, y, maze, rows, columns, x_circular, y_circular)) == 0 ?
|
len(v_dirs) == 0 ?
|
||||||
set_visited(x, y, maze) // road closed
|
set_visited(x, y, maze) // road closed
|
||||||
: walk_around_from(
|
: walk_around_from(
|
||||||
x, y,
|
x, y,
|
||||||
rand_dirs(x * rows + y + seed),
|
v_dirs,
|
||||||
set_visited(x, y, maze),
|
set_visited(x, y, maze),
|
||||||
rows, columns,
|
rows, columns,
|
||||||
x_circular, y_circular,
|
x_circular, y_circular,
|
||||||
|
Reference in New Issue
Block a user