static bool ctxDoNextActionInRule(WoodyRule rule) { L<CtxCase> actions = ctxCases(rule.body); if (nempty(actions)) { S actionSelector = rule.properties.get('ACTIONSELECTOR); if (empty(actionSelector)) actionSelector = 'TILLEND; bool random = eqOneOf(actionSelector, 'RANDOMLOOP, 'RANDOM); //bool loop = eqOneOf(actionSelector, 'RANDOMLOOP); S name = rule.longName(); BitSet bs = conversation->randomLoopMap.get(name); if (bs == null) { conversation->randomLoopMap.put(name, bs = new BitSet); conversation->change(); } new L<Int> candidates; for i over actions: if (!bs.get(i)) candidates.add(i); // start over with all candidates if (empty(candidates)) { bs.clear(); conversation->change(); for i over actions: candidates.add(i); } int idx = random ? random(candidates) : first(candidates); bs.set(idx); candidates.remove((Int) idx); conversation->change(); CtxCase action = actions.get(idx); ctxProcessAction(action.action); S a = mapGet(action.properties, 'ANALYZER); print("doNextAction analyzer=" + a); if (a != null) ctxContext().activeAnalyzer = a; ctxContext().nextRule = rule.properties.get('GOTO); S goTo = action.properties.get('GOTO); if (goTo != null) ctxContext().nextRule = goTo; print("Candidates left: " + l(candidates) + " of " + l(actions)); if (empty(candidates) && l(actions) > 1) { print("No more candidates. nextRule=" + ctxContext().nextRule); if (/*loop &&*/ ctxContext().nextRule == null) ctxContext().thinkagain = true; } true; } false; }
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1008936 |
Snippet name: | ctxDoNextActionInRule |
Eternal ID of this version: | #1008936/18 |
Text MD5: | 558c03ea9b37fe39a0032504a2548256 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-07-19 00:04:01 |
Source code size: | 1696 bytes / 46 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 437 / 503 |
Version history: | 17 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |