Пример #1
0
    def goal_test(self, state: str) -> bool:
        """ Test the state to see if goal is reached

        :param state: str representing state
        :return: bool
        """
        kb = PropKB()
        kb.tell(decode_state(state, self.state_map).pos_sentence())
        return all(kb.ask(clause) is not False for clause in self.goal)
Пример #2
0
 def h_ignore_preconditions(self, node: Node):
     """This heuristic estimates the minimum number of actions that must be
     carried out from the current state in order to satisfy all of the goal
     conditions by ignoring the preconditions required for an action to be
     executed.
     """
     # implement (see Russell-Norvig Ed-3 10.2.3  or Russell-Norvig Ed-2 11.2)
     kb = PropKB()
     kb.tell(decode_state(node.state, self.state_map).pos_sentence())
     return sum(
         [1 if kb.ask(clause) is False else 0 for clause in self.goal])