!7

static JPanel form;

p {
  fS concept = 
    //"kthpatohcsbblavt"; // a human
    "dtzdwdnouygluaql"; // human
  
  time2 {
    Collection<S> pos = whatIs(concept);
    Collection<S> neg = whatIsNot(concept);
    Collection<S> other = otherAnswers(concept);
    Collection<S> unknown = listMinusList(aiConceptIDs(), concatLists(pos, neg, other));
    unknown = [S id : unknown | !containsXYZVariables(conceptToName(id))];
  }

  print("IS:");
  printAIConcepts(pos);
  print();
  print("ISN'T:");
  printAIConcepts(neg);
  print();
  print("OTHER:");
  printAIConcepts(other);
  print();
  
  /*print("UNKNOWN:");
  printAIConcepts(unknown);
  print();*/
  fS id = random(unknown);
  if (id != null) {
    final Lisp q = lisp("pyzgofzoejdprkow", id, concept);
    fS qq = "Is " + quote(conceptToName(id)) + " " + firstToLower(conceptToName(concept)) + "?";
    print(qq);
    showControls(vstackWithSpacing(jcenteredlabel(qq),
      jcenteredline(
        jbutton("Yes", r { answerWith(lisp("fgvvrzypbkqomktd", id, concept)) }),
        jbutton("No", r { answerWith(lisp("aajsjaczgasbazcu", id, concept)) }),
        //jbutton("Question makes no sense", r { answerWith(lisp("lnxlavjirjaeeuil", q)) }),
        jbutton("Other...", r { other(q, qq) })
    )));
    consoleProgramTitle();
    sleepQuietly();
  }
}

svoid answerWith(final Lisp statement) {
  disableAllButtons(getControls());
  if (form != null) { disposeFrame(form); form = null; }
  thread {
    addTruth(statement);
    clearStatementCaches(10);
    clearConsole();
    runMain();
  }
}

svoid other(final Lisp q, S qq) {
  if (form != null) ret;
  final new JTextField tf;
  form = showFormTitled("Your response",
    "Question", qq,
    "Your response", tf,
    r {
      answerWith(lisp("tlwrjpzuteopednt", q, or2(getTextTrim(tf), "?")))
    });
}

static Collection<S> otherAnswers(S concept) {
  new TreeSet<S> out;
  for (Lisp l : lispTruthByHead("tlwrjpzuteopednt")) {
    Lisp q = l.get(0);
    if (q != null && q.is("pyzgofzoejdprkow") && eq(q.rawOrNull(1), concept))
      addIfNotNull(out, q.rawOrNull(0));
  }
  ret out;
}