1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-03-14 02:59:42 +01:00
This commit is contained in:
Justin Lin 2021-03-14 16:10:23 +08:00
parent cd21c6437b
commit 4109d964dc

View File

@ -164,23 +164,23 @@ function wf_not_collapsed_coords(wf) = [
[x, y]
];
function coord_min_entropy(wf) =
function wf_coord_min_entropy(wf) =
let(
coords = wf_not_collapsed_coords(wf),
coords_leng = len(coords),
entropyCoord = coords[0],
entropy = wf_entropy(wf, entropyCoord[0], entropyCoord[1]) - (rand() / 1000)
)
_coord_min_entropy(wf, coords, coords_leng, entropy, entropyCoord);
_wf_coord_min_entropy(wf, coords, coords_leng, entropy, entropyCoord);
function _coord_min_entropy(wf, coords, coords_leng, entropy, entropyCoord, i = 1) =
function _wf_coord_min_entropy(wf, coords, coords_leng, entropy, entropyCoord, i = 1) =
i == coords_leng ? entropyCoord :
let(
coord = coords[i],
noisedEntropy = wf_entropy(wf, coord[0], coord[1]) - (rand() / 1000)
)
noisedEntropy < entropy ? _coord_min_entropy(wf, coords, coords_leng, noisedEntropy, coord, i + 1) :
_coord_min_entropy(wf, coords, coords_leng, entropy, entropyCoord, i + 1);
noisedEntropy < entropy ? _wf_coord_min_entropy(wf, coords, coords_leng, noisedEntropy, coord, i + 1) :
_wf_coord_min_entropy(wf, coords, coords_leng, entropy, entropyCoord, i + 1);
width = len(sample[0]);
@ -200,4 +200,4 @@ for(y = [0:height - 1]) {
}
}
assert(wf_entropy(wf, 0, 0) == 1.458879520793018);
assert(coord_min_entropy(wf_collapse(wf, 0, 0)) != [0, 0]);
assert(wf_coord_min_entropy(wf_collapse(wf, 0, 0)) != [0, 0]);