Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

11
LINES

< > BotCompany Repo | #1013445 - ai_ruleToJava

JavaX fragment (include)

static S ai_ruleToJava(S ruleName) {
  S ruleText = unquote(firstPossibleRule(ai_texts("$X", "is", ruleName)));
  if (ruleText == null) fail("Rule not found: " + ruleName);
  S op = joinWithSpace(ai_getOperator(ruleText));
  if (neq(op, "if input * then say *")) fail("Unknown rule op: " + op);
  L<S> l = ai_getOperands(ruleText);
  ret "static S rule_" + wordsToCamelCase(lower(ruleName)) + "() {\n" +
    "  ai_checkInput_match3(" + quote(deRoundBracket(first(l))) + ");\n" +
    "  ret " + quote(deRoundBracket(second(l))) + ";\n" +
    "}";
}

download  show line numbers  debug dex   

Travelled to 11 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz

No comments. add comment

Snippet ID: #1013445
Snippet name: ai_ruleToJava
Eternal ID of this version: #1013445/5
Text MD5: 5e9a00592a960eb510a3772a0b3c77fd
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-01-07 02:31:42
Source code size: 557 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 239 / 243
Version history: 4 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1013445 & http://1013445.tinybrain.de