@SuppressWarnings("deprecation")
  @Override
  public void run() {
    running = true;
    while (running) {
      try {
        String value = in.readLine();

        if (value == null) {
          running = false;
          break;
        }

        String newValue = "";
        // clears the string for errors.
        for (char c : value.toCharArray()) {
          if (c != 0) {
            newValue += c;
          }
        }
        value = newValue;
        LOG.info("Received: " + value);
        Literal l = Literal.parseLiteral(value);
        try {
          l.addSource(ASSyntax.parseTerm("percept"));
        } catch (ParseException ex) {
          LOG.log(Level.SEVERE, "Could not add source", ex);
        }
        pendingBeliefs.add(l);
      } catch (IOException ex) {
        LOG.log(Level.SEVERE, "Could not read BT input.", ex);
      }
    }
  }
Beispiel #2
0
 public boolean executeAction(String agName, Structure act) {
   String actName = act.getFunctor();
   System.out.println("Action " + actName + " received!");
   if (actName.equals("hello")) {
     Literal l = Literal.parseLiteral("world[source(lucca)]");
     addPercept(l);
   }
   if (actName.equals("clean")) {
     clearPercepts();
   }
   return true;
 }
Beispiel #3
0
  /** Called before the MAS execution with the args informed in .mas2j */
  @Override
  public void init(String[] args) {
    super.init(args);

    logger.info("Java version:" + System.getProperty("java.version"));
    logger.info("Java architecture:" + System.getProperty("sun.arch.data.model"));

    try {
      this.model = new TEPRModel();
    } catch (IOException e) {
      addPercept(Literal.parseLiteral("error(\"Could not inatantiate the model\")"));
      e.printStackTrace();
    }
  }
Beispiel #4
0
  public Collection<Literal> call(String... params) {

    String queryid = params[0]; // first param is the queryid
    // second param is the message. Discard in dummy

    Collection<Literal> res = new LinkedList<Literal>();
    res.add(Literal.parseLiteral("cityfrom(madrid)[query(" + queryid + ")]"));
    res.add(Literal.parseLiteral("cityto(barcelona)[query(" + queryid + ")]"));
    res.add(Literal.parseLiteral("ticket(bussiness)[query(" + queryid + ")]"));
    res.add(Literal.parseLiteral("travel(train)[query(" + queryid + ")]"));
    res.add(Literal.parseLiteral("departuretime(10,00)[query(" + queryid + ")]"));
    res.add(Literal.parseLiteral("departureday(8,5,2012)[query(" + queryid + ")]"));

    return res;
  }
 public PropositionImpl(String prop) {
   super(Literal.parseLiteral(prop));
 }