Examples of GdlSentence


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

    //Injection: Go from the intersections of variable values in rules to the
    //values in their heads
    boolean somethingChanged = false;

    for (GdlRule rule : getRules(model.getDescription())) {
      GdlSentence head = rule.getHead();

      Map<GdlVariable, Set<GdlConstant>> domainsOfHeadVars = Maps.newHashMap();
      for (GdlVariable varInHead : ImmutableSet.copyOf(GdlUtils.getVariables(rule.getHead()))) {
        Set<GdlConstant> domain = getVarDomainInRuleBody(varInHead, rule, newPossibleConstantsByForm, curDomain, model);
        domainsOfHeadVars.put(varInHead, domain);
View Full Code Here

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

    //then all the values that are in the intersections of all the
    //domains from the positive conjuncts containing the variable
    //become needed.

    for (GdlRule rule : getRules(model.getDescription())) {
      GdlSentence head = rule.getHead();
      Set<GdlVariable> varsInHead = ImmutableSet.copyOf(GdlUtils.getVariables(head));

      Map<GdlVariable, Set<GdlConstant>> varDomains = getVarDomains(rule, curDomains, model);
      for (GdlVariable var : ImmutableSet.copyOf(GdlUtils.getVariables(rule))) {
        if (!varsInHead.contains(var)) {
View Full Code Here

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

    //current domain) in every appearance of the variable in
    //positive conjuncts in the rule's body, then the value is
    //needed in every appearance of the variable in the rule
    //(positive or negative).
    for (GdlRule rule : getRules(model.getDescription())) {
      GdlSentence head = rule.getHead();
      SentenceForm headForm = model.getSentenceForm(head);
      List<GdlTerm> headTuple = GdlUtils.getTupleFromSentence(head);

      Map<GdlVariable, Set<GdlConstant>> varDomains = getVarDomains(rule, curDomains, model);
View Full Code Here

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

      Map<SentenceForm, SetMultimap<Integer, GdlConstant>> neededConstantsByForm,
      SentenceFormModel model) throws InterruptedException {
    if (conjunct instanceof GdlSentence) {
      return addPossibleValuesToSentence(neededAndPossibleConstants, (GdlSentence) conjunct, curVar, neededConstantsByForm, model);
    } else if (conjunct instanceof GdlNot) {
      GdlSentence innerSentence = (GdlSentence) ((GdlNot) conjunct).getBody();
      return addPossibleValuesToSentence(neededAndPossibleConstants, innerSentence, curVar, neededConstantsByForm, model);
    } else if (conjunct instanceof GdlOr) {
      throw new IllegalArgumentException("The SentenceDomainModelOptimizer is not designed for game descriptions with OR. Use the DeORer.");
    } else if (conjunct instanceof GdlDistinct) {
      return false;
View Full Code Here

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

        {
            GdlRule rule = (GdlRule) gdl;
            String name = rule.getHead().getName().toString();
            if(name.equals("next"))
            {
                GdlSentence head = rule.getHead();
                if(head.arity()!=1)
                    throw new RuntimeException("Can't next more than one thing as far as I know.");
                if(head.get(0) instanceof GdlVariable)
                {   //weird case where you have rule like (next ?q)
                    Location l = new Location();
                    l.idx = 0;
                    l.name = head.getName();
                    Domain dom = domains.get(l);
                    for(GdlConstant c : dom.values)
                    {
                        List<GdlTerm> body = new ArrayList<GdlTerm>();
                        body.add(c);
                        baseRelations.add(GdlPool.getRelation(baseConstant, body));
                    }
                }
                else
                    instantiateBasePropsWithRHS(head.get(0).toSentence(), rule.getBody());
            }
        }
    }
View Full Code Here

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

            }
        }
        else if(gdl instanceof GdlRule)
        {
            GdlRule rule = (GdlRule)gdl;
            GdlSentence head = rule.getHead();
            if(head instanceof GdlRelation)
            {
                GdlRelation rel = (GdlRelation)head;

                int i=0;
View Full Code Here

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

        //TODO: Implement correctly.
        throw new UnsupportedOperationException("We can't currently handle (not (distinct <function> <function>)).");
    }

    private static GdlRule cleanParentheses(GdlRule rule) {
    GdlSentence cleanedHead = cleanParentheses(rule.getHead());
    List<GdlLiteral> cleanedBody = new ArrayList<GdlLiteral>();
    for(GdlLiteral literal : rule.getBody())
      cleanedBody.add(cleanParentheses(literal));
    return GdlPool.getRule(cleanedHead, cleanedBody);
  }
View Full Code Here

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

    ImmutableSetMultimap.Builder<SentenceForm, GdlSentence> builder =
        ImmutableSetMultimap.builder();

    for(Gdl gdl : gameRules) {
      if(gdl instanceof GdlSentence) {
        GdlSentence sentence = (GdlSentence) gdl;
        for (SentenceForm form : sentenceForms) {
          if(form.matches(sentence)) {
            builder.put(form, sentence);
            break;
          }
View Full Code Here

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

        newInternals.add(replaceVariables(or.get(i), assignment));
      }
      return GdlPool.getOr(newInternals);
    } else if (gdl instanceof GdlRule) {
      GdlRule rule = (GdlRule) gdl;
      GdlSentence newHead = replaceVariables(rule.getHead(), assignment);
      List<GdlLiteral> newBody = Lists.newArrayList();
      for (GdlLiteral conjunct : rule.getBody()) {
        newBody.add(replaceVariables(conjunct, assignment));
      }
      return GdlPool.getRule(newHead, newBody);
View Full Code Here

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

      varOrdering = new ArrayList<GdlVariable>(parent.varOrdering);
      functionalConjunctIndices = new ArrayList<Integer>(parent.functionalConjunctIndices);
      varSources = new ArrayList<Integer>(parent.varSources);
      //Add the new source conjunct
      sourceConjunctIndices.add(i);
      GdlSentence sourceConjunctCandidate = sourceConjunctCandidates.get(i);
      List<GdlVariable> varsFromConjunct = GdlUtils.getVariables(sourceConjunctCandidate);
      //Ignore both previously added vars and duplicates
      //Oh, but we need to be careful here, at some point.
      //i.e., what if there are multiple of the same variable
      //in a single statement?
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.