svoid applyRule_random(S ruleID) { // process the rule Lisp rule = getLispTruth(ruleID); if (rule == null) { print("Rule not found: " + ruleID); ret; } //print("Applying rule " + ruleID); print_setPrefixForThread(ruleID + "> "); try { L conditions = dropLast(rule.args); Lisp out = last(rule.args); //for (Lisp cond : conditions) print("Condition: " + cond); new Map matches; int n = matchConditions_random(conditions, matches); if (n == -1) { print("Yo! " + struct(matches)); out = lispReplaceVars(out, matches); if (lispTrue(out)) print("Already had: " + out); else { print("Defining: " + lispToEnglish_prettier(out)); emit(out, ruleID); } } else print("Only " + n + " of " + n(conditions, "condition") + " met"); } finally { print_setPrefixForThread(""); } }