def expand(self, previousLevel, allProps, allActions): # you can change the params the function takes if you like previousPropositionLayer = previousLevel.getPropositionLayer() newActionLayer = ActionLayer() for action in allActions: if previousPropositionLayer.allPrecondsInLayer(action): newActionLayer.addAction(action) self.actionLayer = newActionLayer newPropositionLayer = PropositionLayer() for prop in allProps: if newActionLayer.effectExists(prop): newPropositionLayer.addProposition(prop) # set new proposition layer self.setPropositionLayer(newPropositionLayer)
def expand(self, previousLevel, allProps, allActions ): # you can change the params the function takes if you like previousPropositionLayer = previousLevel.getPropositionLayer() newActionLayer = ActionLayer() for action in allActions: if previousPropositionLayer.allPrecondsInLayer(action): newActionLayer.addAction(action) self.actionLayer = newActionLayer newPropositionLayer = PropositionLayer() for prop in allProps: if newActionLayer.effectExists(prop): newPropositionLayer.addProposition(prop) # set new proposition layer self.setPropositionLayer(newPropositionLayer)
def expand(self, previousLevel, allProps, allActions ): # you can change the params the function takes if you like previousPropositionLayer = previousLevel.getPropositionLayer() newActionLayer = ActionLayer() for action in allActions: if previousPropositionLayer.allPrecondsInLayer(action): newActionLayer.addAction(action) # add mutex actions for action1 in newActionLayer.getActions(): for action2 in newActionLayer.getActions(): actionPair = Pair(action1, action2) if action1 != action2 and self.mutexActions( action1, action2, previousPropositionLayer.getMutexProps() ) and actionPair not in newActionLayer.getMutexActions(): newActionLayer.addMutexActions(action1, action2) self.actionLayer = newActionLayer newPropositionLayer = PropositionLayer() for prop in allProps: if newActionLayer.effectExists(prop): newPropositionLayer.addProposition(prop) # add mutex propositions for prop1 in newPropositionLayer.getPropositions(): for prop2 in newPropositionLayer.getPropositions(): propPair = Pair(prop1, prop2) if prop1 != prop2 and self.mutexPropositions( prop1, prop2, newActionLayer.getMutexActions() ) and propPair not in newPropositionLayer.getMutexProps(): newPropositionLayer.addMutexProp(prop1, prop2) # set new proposition layer self.setPropositionLayer(newPropositionLayer)