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

25
LINES

< > BotCompany Repo | #1013191 // ai_ifAndInput_v2 - X + Y in first condition; allow variables in input; match input first

JavaX fragment (include)

// e. g.
// if (Y -> is the opposite of -> X)
// and input (if something is not X, then it is...)
// then say (Y!)

static S ai_ifAndInput_v2(S rule, S input) {
  print("ai_ifAndInput_v2");
  new Matches m;
  if (!simpleStarMatchOnCTokensIC("if * and input * then say *",
    javaTokDroppingBracketsC_unquote(rule), m)) unsuitableRule();
    
  S d2 = $2;
  printStructs(+d2, +input);
  S x = matchBigX(d2, input);
  printStructs(+x);
  if (x == null) null;
  S pat = formatVars($1, litmap("X", x, "Y", "$X"));
  printStruct(+pat);
  T3<S> t = ai_tripelize(pat);
  printStruct(+t);
  
  S y = random(ai_texts(t));
  if (y == null) null;
  ret ai_replaceBigY($3, y);
}

Author comment

Began life as a copy of #1013172

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: #1013191
Snippet name: ai_ifAndInput_v2 - X + Y in first condition; allow variables in input; match input first
Eternal ID of this version: #1013191/6
Text MD5: 9d34769134a9deaec1db1c0e6c18f36f
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-12-27 07:07:57
Source code size: 691 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 277 / 321
Version history: 5 change(s)
Referenced in: [show references]