1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-16 13:50:05 +01:00

ci as a seed factor

This commit is contained in:
Justin Lin 2022-08-31 09:48:53 +08:00
parent 7af26906d0
commit 264d83cdf1

View File

@ -24,16 +24,16 @@ function _join(str_lt) =
let(leng = len(str_lt))
[for(i = 0, s = str_lt[0]; i < leng; i = i + 1, s = str(s, str_lt[i])) s][leng - 1];
function c_or_v(c, v, rules, rules_pr, leng, seed, i = 0) =
function c_or_v(c, v, rules, rules_pr, leng, seed, ci, i = 0) =
i == leng ? c :
let(idx = search([v[i]], rules, num_returns_per_match=0, index_col_num = 1)[0][0])
rand(0, 1, seed + i) <= rules_pr[idx] ? v[i] : c_or_v(c, v, rules, rules_pr, leng, seed, i + 1);
rand(0, 1, seed + ci + i) <= rules_pr[idx] ? v[i] : c_or_v(c, v, rules, rules_pr, leng, seed, ci, i + 1);
function _derive1_p(base, rules, rules_pr, seed) =
_join([
for(c = base)
let(v = [for(r = rules) if(r[0] == c) r[1]])
v == [] ? c : c_or_v(c, v, rules, rules_pr, len(v), seed)
for(ci = [0:len(base) - 1])
let(c = base[ci], v = [for(r = rules) if(r[0] == c) r[1]])
v == [] ? c : c_or_v(c, v, rules, rules_pr, len(v), seed, ci)
]);
function _derive1(base, rules) = _join([