Examples of GdlConstant


Examples of org.ggp.base.util.gdl.grammar.GdlConstant

    private class SortTerms implements Comparator<GdlTerm>
    {
        @Override
    public int compare(GdlTerm arg0, GdlTerm arg1) {
            GdlConstant a1 = (GdlConstant)arg0;
            GdlConstant a2 = (GdlConstant)arg1;
            String s1 = a1.toString();
            String s2 = a2.toString();

            int num1 = -1;
            int num2 = -1;

            try {num1 = Integer.parseInt(s1);} catch(Exception ex) {}
View Full Code Here

Examples of org.ggp.base.util.gdl.grammar.GdlConstant

      Map<GdlVariable, ? extends GdlTerm> assignment) {
    if (gdl instanceof GdlProposition) {
      return gdl;
    } else if (gdl instanceof GdlRelation) {
      GdlRelation relation = (GdlRelation) gdl;
      GdlConstant name = relation.getName();
      List<GdlTerm> newBody = new ArrayList<GdlTerm>(relation.arity());
      for(GdlTerm term : relation.getBody()) {
        newBody.add(replaceVariables(term, assignment));
      }
      return GdlPool.getRelation(name, newBody);
    } else if (gdl instanceof GdlConstant) {
      return gdl;
    } else if (gdl instanceof GdlVariable) {
      if(assignment.containsKey(gdl))
        return assignment.get(gdl);
      else
        return gdl;
    } else if (gdl instanceof GdlFunction) {
      GdlFunction function = (GdlFunction) gdl;
      GdlConstant name = function.getName();
      List<GdlTerm> newBody = new ArrayList<GdlTerm>(function.arity());
      for (GdlTerm term : function.getBody()) {
        newBody.add(replaceVariables(term, assignment));
      }
      return GdlPool.getFunction(name, newBody);
View Full Code Here

Examples of org.ggp.base.util.gdl.grammar.GdlConstant

        } else {
          queryTuple.add(remainingTuple.get(queryInputIndices.get(i)));
        }
      }
      //The query is filled; we ask the map
      GdlConstant answer = function.get(queryTuple);

      for (AssignmentFunction internalFunction : internalFunctions) {
        if (internalFunction.getValue(remainingTuple) != answer) {
          return null;
        }
View Full Code Here

Examples of org.ggp.base.util.gdl.grammar.GdlConstant

    }
    return o.matches(underscoreSentence.get());
  }

  private static List<GdlConstant> getNUnderscores(int numTerms) {
    GdlConstant underscore = GdlPool.UNDERSCORE;
    List<GdlConstant> terms = Lists.newArrayListWithCapacity(numTerms);
    for (int i = 0; i < numTerms; i++) {
      terms.add(underscore);
    }
    return terms;
View Full Code Here

Examples of org.ggp.base.util.gdl.grammar.GdlConstant

    }

    try
    {
      GdlRelation relation = (GdlRelation) results.iterator().next();
      GdlConstant constant = (GdlConstant) relation.get(1);

      return Integer.parseInt(constant.toString());
    }
    catch (Exception e)
    {
      throw new GoalDefinitionException(state, role);
    }
View Full Code Here

Examples of org.ggp.base.util.gdl.grammar.GdlConstant

        }

        public void addAssignmentToIndex(Assignment assignment) {
            for(int i=0; i<assignment.size(); i++)
            {
                GdlConstant c = assignment.get(i);
                if(indices.size() <= i)
                    indices.add(new Index());
                Index index = indices.get(i);

                if(!index.containsKey(c))
View Full Code Here

Examples of org.ggp.base.util.gdl.grammar.GdlConstant

    }
    return isConstant;
  }

  private boolean isTrueOrDoesSentence(GdlSentence sentence) {
    GdlConstant name = sentence.getName();
    return name == GdlPool.TRUE || name == GdlPool.DOES;
  }
View Full Code Here

Examples of org.ggp.base.util.gdl.grammar.GdlConstant

  {
    contents = new HashMap<GdlConstant, List<GdlRule>>();
    for (Gdl gdl : description)
    {
      GdlRule rule = (gdl instanceof GdlRule) ? (GdlRule) gdl : GdlPool.getRule((GdlSentence) gdl);
      GdlConstant key = rule.getHead().getName();

      if (!contents.containsKey(key))
      {
        contents.put(key, new ArrayList<GdlRule>());
      }
View Full Code Here

Examples of org.ggp.base.util.gdl.grammar.GdlConstant

    }
  }

  public synchronized List<GdlRule> fetch(GdlSentence sentence)
  {
    GdlConstant key = sentence.getName();

    if (contents.containsKey(key))
    {
      return contents.get(key);
    }
View Full Code Here

Examples of org.ggp.base.util.gdl.grammar.GdlConstant

    {
        // Skip all propositions that aren't GdlPropositions.
      if (!(proposition.getName() instanceof GdlProposition))
          continue;

      GdlConstant constant = ((GdlProposition) proposition.getName()).getName();
      if (constant.getValue().toUpperCase().equals("INIT")) {
        return proposition;
      }
    }
    return null;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.