1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-19 04:51:26 +02:00

refactor: replace states directly

This commit is contained in:
Justin Lin
2022-03-20 18:03:18 +08:00
parent 27190008bf
commit 6f13757cbc

View File

@@ -79,12 +79,10 @@ function _wf_collapse(wf, x, y, states_weights, leng, threshold, i = 0) =
threshold < 0 || i == leng ? wf : threshold < 0 || i == leng ? wf :
let(state_weight = states_weights[i]) let(state_weight = states_weights[i])
_wf_collapse( _wf_collapse(
threshold < state_weight[1] ? _oneStateAt(wf, x, y, state_weight[0]) : wf, threshold < state_weight[1] ? _replaceStatesAt(wf, x, y, [state_weight[0]]) : wf,
x, y, states_weights, leng, threshold - state_weight[1], i + 1 x, y, states_weights, leng, threshold - state_weight[1], i + 1
); );
function _oneStateAt(wf, x, y, state) = _replaceStatesAt(wf, x, y, [state]);
// Shannon entropy // Shannon entropy
function wf_entropy(wf, x, y) = function wf_entropy(wf, x, y) =
let( let(