예제 #1
0
파일: GameFlow.py 프로젝트: hobson/ggpy
 def solveTurns(self, model):
     """ generated source for method solveTurns """
     # Before we can do anything else, we need a topological ordering on our forms
     ordering = getTopologicalOrdering(model.getIndependentSentenceForms(), model.getDependencyGraph())
     ordering.retainAll(self.formsControlledByFlow)
     # Let's add function info to the consideration...
     functionInfoMap = HashMap()
     for form in constantForms:
         functionInfoMap.put(form, FunctionInfoImpl.create(form, self.constantChecker))
     # First we set the "true" values, then we get the forms controlled by the flow...
     # Use "init" values
     trueFlowSentences = HashSet()
     for form in constantForms:
         if form.__name__ == self.INIT:
             for initSentence in constantChecker.getTrueSentences(form):
                 trueFlowSentences.add(trueSentence)
     # Go through ordering, adding to trueFlowSentences
     addSentenceForms(ordering, trueFlowSentences, model, functionInfoMap)
     self.sentencesTrueByTurn.add(trueFlowSentences)
     while True:
         # Now we use the "next" values from the previous turn
         trueFlowSentences = HashSet()
         for sentence in sentencesPreviouslyTrue:
             if sentence.__name__ == self.NEXT:
                 trueFlowSentences.add(trueSentence)
         addSentenceForms(ordering, trueFlowSentences, model, functionInfoMap)
         # Test if this turn's flow is the same as an earlier one
         while i < len(self.sentencesTrueByTurn):
             if prevSet == trueFlowSentences:
                 # Complete the loop
                 self.turnAfterLast = i
                 break
             i += 1
         self.sentencesTrueByTurn.add(trueFlowSentences)
예제 #2
0
 def addConstantsToFunctionInfo(cls, form, constantChecker, functionInfoMap):
     """ generated source for method addConstantsToFunctionInfo """
     functionInfoMap.put(form, FunctionInfoImpl.create(form, constantChecker))