Package org.ggp.base.util.gdl.transforms

Examples of org.ggp.base.util.gdl.transforms.ConstantChecker


    model = SentenceDomainModelOptimizer.restrictDomainsToUsefulValues(model);

    if(verbose)
      System.out.println("Setting constants...");

    ConstantChecker constantChecker = ConstantCheckerFactory.createWithForwardChaining(model);
    if(verbose)
      System.out.println("Done setting constants");

    Set<String> sentenceFormNames = SentenceForms.getNames(model.getSentenceForms());
    boolean usingBase = sentenceFormNames.contains("base");
    boolean usingInput = sentenceFormNames.contains("input");


    //For now, we're going to build this to work on those with a
    //particular restriction on the dependency graph:
    //Recursive loops may only contain one sentence form.
    //This describes most games, but not all legal games.
    Multimap<SentenceForm, SentenceForm> dependencyGraph = model.getDependencyGraph();
    if(verbose) {
      System.out.print("Computing topological ordering... ");
      System.out.flush();
    }
    ConcurrencyUtils.checkForInterruption();
    List<SentenceForm> topologicalOrdering = getTopologicalOrdering(model.getSentenceForms(), dependencyGraph, usingBase, usingInput);
    if(verbose)
      System.out.println("done");

    List<Role> roles = Role.computeRoles(description);
    Map<GdlSentence, Component> components = new HashMap<GdlSentence, Component>();
    Map<GdlSentence, Component> negations = new HashMap<GdlSentence, Component>();
    Constant trueComponent = new Constant(true);
    Constant falseComponent = new Constant(false);
    Map<SentenceForm, FunctionInfo> functionInfoMap = new HashMap<SentenceForm, FunctionInfo>();
    Map<SentenceForm, Collection<GdlSentence>> completedSentenceFormValues = new HashMap<SentenceForm, Collection<GdlSentence>>();
    for(SentenceForm form : topologicalOrdering) {
      ConcurrencyUtils.checkForInterruption();

      if(verbose) {
        System.out.print("Adding sentence form " + form);
        System.out.flush();
      }
      if(constantChecker.isConstantForm(form)) {
        if(verbose)
          System.out.println(" (constant)");
        //Only add it if it's important
        if(form.getName().equals(LEGAL)
            || form.getName().equals(GOAL)
            || form.getName().equals(INIT)) {
          //Add it
          for (GdlSentence trueSentence : constantChecker.getTrueSentences(form)) {
            Proposition trueProp = new Proposition(trueSentence);
            trueProp.addInput(trueComponent);
            trueComponent.addOutput(trueProp);
            components.put(trueSentence, trueComponent);
          }
View Full Code Here

TOP

Related Classes of org.ggp.base.util.gdl.transforms.ConstantChecker

Copyright © 2018 www.massapicom. 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.