コード例 #1
0
    def __init__(self, problem, agent, clear_visits_on_init=True):
        PddlState.__init__(self)

        self.problem = problem
        self.agent = agent
        self.clear_visits_on_init = clear_visits_on_init
        self.dynamic_predicates = dynamic_predicates(problem.domain)

        self.__reinit_event_id = agent.GetKernel().RegisterForAgentEvent(
            sml.smlEVENT_AFTER_AGENT_REINITIALIZED, init_event_handler, self)

        # A dict from predicate names to dicts, where each value dict is a map
        # from tuples of object refs (representing the parameters of a
        # particular instance of the predicate) to	SmlPredicate references
        self.pred_map = {}

        # dict from object ID strings to their SmlObject references
        self.obj_map = {}

        self.num_updates = 0

        self.state_visits = {}

        ilink = self.agent.GetInputLink()
        self.state_wme = self.agent.CreateIdWME(ilink, 'state')
        self.entity_count_wme = self.agent.CreateIntWME(
            ilink, 'entity-count', 0)
        self.num_updates_wme = self.agent.CreateIntWME(ilink, 'num-updates', 0)
        self.num_visits_wme = self.agent.CreateIntWME(ilink, 'num-visits', 0)
        self.agent.Commit()