예제 #1
0
    def init(self):
        PddlState.init(self)

        self.num_updates = 0
        self.update_input_stats()
        if self.clear_visits_on_init:
            self.state_visits.clear()
예제 #2
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()
예제 #3
0
    def add_predicate(self, pred_name, *params):
        PddlState.add_predicate(self, pred_name, *params)

        param_refs = [self.obj_map[p] for p in params]
        p = SmlPredicate(
            self.agent, pred_name,
            **dict(zip(self.problem.pred_param_names[pred_name], param_refs)))
        self.pred_map.setdefault(pred_name, {})[tuple(params)] = p
    def __init__(self, agent):
        if agent:
            self.state = PddlStateSmlAdapter(self, agent)
        else:
            self.state = PddlState()

        self.state.predicates['on__table'] = set()
        self.state.predicates['on'] = set()
        self.state.predicates['clear'] = set()
        self.pred_param_names = {}

        self.pred_param_names['on__table'] = ('x', )

        self.pred_param_names['on'] = (
            'x',
            'y',
        )

        self.pred_param_names['clear'] = ('x', )
예제 #5
0
    def add_object(self, obj_id, obj_type):
        PddlState.add_object(self, obj_id, obj_type)

        o = SmlObject(self.agent, obj_type, obj_id)
        self.obj_map[obj_id] = o
예제 #6
0
    def from_static(self, static_rep):
        self.destroy_objs_preds()

        PddlState.from_static(self, static_rep)
예제 #7
0
    def del_predicate(self, pred_name, *params):
        PddlState.del_predicate(self, pred_name, *params)

        pred = self.pred_map[pred_name].pop(params, None)
        if pred: pred.destroy()