static bool ctxDoNextActionInRule(WoodyRule rule) { L actions = ctxCases(rule.body); if (nempty(actions)) { bool random = eq(rule.properties.get("ACTIONSELECTOR"), "RANDOMLOOP"); // otherwise assume TILLEND S name = rule.longName(); BitSet bs = conversation->randomLoopMap.get(name); if (bs == null) { conversation->randomLoopMap.put(name, bs = new BitSet); conversation->change(); } new L candidates; for i over actions: if (!bs.get(i)) candidates.add(i); if (empty(candidates)) { bs.clear(); conversation->change(); for i over actions: candidates.add(i); } int idx = random ? random(candidates) : first(candidates); bs.set(idx); conversation->change(); CtxCase action = actions.get(idx); ctxProcessAction(action.body); S a = mapGet(action.properties, "ANALYZER"); if (a != null) ctxContext().activeAnalyzer = a; ctxContext().nextRule = rule.properties.get("GOTO"); true; } false; }