Beispiel #1
0
    def test_successful_search(self):
        dls = DepthLimitedSearch(10)
        problem = Problem(1, TestActionsFunction(), TestResultFunction(),
                          TestGoalTest(4))

        result = dls.search(problem)
        self.assertEquals(3, len(result))
    def test_search_failure(self):
        dls = DepthLimitedSearch(10)
        # 5 - is a goal state but it's unreachable
        problem = Problem(1, TestActionsFunction(2), TestResultFunction(), TestGoalTest(5))

        result = dls.search(problem)
        self.assertFalse(dls.is_cutoff(result))
        self.assertTrue(dls.is_failure(result))
    def test_search_cutoff(self):
        # Here we set depth limit 3...
        dls = DepthLimitedSearch(3)
        # But result can be found only with limit 4 or more
        problem = Problem(1, TestActionsFunction(), TestResultFunction(), TestGoalTest(5))

        result = dls.search(problem)
        self.assertTrue(dls.is_cutoff(result))
        self.assertFalse(dls.is_failure(result))
Beispiel #4
0
    def test_search_failure(self):
        dls = DepthLimitedSearch(10)
        # 5 - is a goal state but it's unreachable
        problem = Problem(1, TestActionsFunction(2), TestResultFunction(),
                          TestGoalTest(5))

        result = dls.search(problem)
        self.assertFalse(dls.is_cutoff(result))
        self.assertTrue(dls.is_failure(result))
Beispiel #5
0
    def test_search_cutoff(self):
        # Here we set depth limit 3...
        dls = DepthLimitedSearch(3)
        # But result can be found only with limit 4 or more
        problem = Problem(1, TestActionsFunction(), TestResultFunction(),
                          TestGoalTest(5))

        result = dls.search(problem)
        self.assertTrue(dls.is_cutoff(result))
        self.assertFalse(dls.is_failure(result))
    def test_successful_search(self):
        dls = DepthLimitedSearch(10)
        problem = Problem(1, TestActionsFunction(), TestResultFunction(), TestGoalTest(4))

        result = dls.search(problem)
        self.assertEquals(3, len(result))