Example #1
0
    def test_search_goal_sequence_1(self):
        # given
        gs = GoalSequenceSearcher()
        start = Perception("11111111")
        goal = Perception("11111110")

        empty_list = ClassifiersList()

        # when
        result = gs.search_goal_sequence(empty_list, start=start, goal=goal)

        # then
        assert result == []
Example #2
0
    def test_search_goal_sequence_4(self, cfg):
        # given
        gs = GoalSequenceSearcher()
        start = "01111111"
        goal = "00111111"

        reliable_classifiers = ClassifiersList(
            Classifier(condition="#1######",
                       action=1,
                       effect="#0######",
                       cfg=cfg))

        # when
        result = gs.search_goal_sequence(reliable_classifiers,
                                         start=start,
                                         goal=goal)
        # then
        assert result == [1]
Example #3
0
def search_goal_sequence(classifiers: ClassifiersList, p0: Perception,
                         p1: Perception) -> List:
    """
    Searches a path from start to goal using a bidirectional method in the
    environmental model (i.e. the list of reliable classifiers).

    Parameters
    ----------
    classifiers: ClassifiersList
    p0: Perception
        start state
    p1: Perception
        destination state

    Returns
    -------
    list
        sequence of actions
    """
    reliable = [cl for cl in classifiers if cl.is_reliable()]
    gs = GoalSequenceSearcher()

    return gs.search_goal_sequence(ClassifiersList(*reliable), p0, p1)