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

67
LINES

< > BotCompany Repo | #1005031 // Calendar AI [dev.]

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Uses 13052K of libraries. Click here for Pure Java version (5954L/41K/135K).

!752

!include #1004972 // Text AI Include

concepts.

concept Question extends Interpretation {}

concept HowManyMonthsInYear extends Question {
  int year;
}

concept NumberOfMonthsInYear {
  new Ref question;
  int year, months;
}

static Concept answerQuestion(Question q) {
  if (q instanceof HowManyMonthsInYear) {
    sleepSeconds(1);
    new NumberOfMonthsInYear a;
    a.question.set(q);
    copyFields(q, a, "year");
    a.months = 12; // The answer!
    change();
    ret a;
  }
  null; // unknown question
}

static S renderAnswer(Concept a) {
  if (a instanceof NumberOfMonthsInYear) {
    NumberOfMonthsInYear aa = cast a;
    ret "There are " + n(aa.months, "month") + " in the year " + aa.year + ".";
  }
  null;
}

static S dbName;

p {
  dbName = fsI(programID());
  loadAndAutoSaveConcepts();
  makeBot("Calendar AI 1.");
  methodsBot(dbName, listPlus(exposedDBMethods, "xfindLine"));
  initConsole();
  print("AI ready to rock. Go \"Admin\" to see my commands.");
  //kevin("Hello");
  print();
}

static S answerInterpreted(S s, Interpretation ip) {
  if (ip instanceof Question) {
    Concept a = answerQuestion((Question) ip);
    if (a == null)
      ret "No idea";
    else {
      S text = renderAnswer(a);
      if (nempty(text)) ret text;
      ret "I have an answer, but don't know how to tell you unfortunately";
    }
  }
  
  null;
}

svoid admin {}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xhsrmoityime

No comments. add comment

Snippet ID: #1005031
Snippet name: Calendar AI [dev.]
Eternal ID of this version: #1005031/1
Text MD5: dd58ab3d2637c623ea6393bcacd098b6
Transpilation MD5: 1922f44777a91f9facf27becebf9706c
Author: stefan
Category: javax / a.i.
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-09-29 19:49:04
Source code size: 1447 bytes / 67 lines
Pitched / IR pitched: No / No
Views / Downloads: 491 / 550
Referenced in: [show references]