Пример #1
0
    def test_failed_search(self):
        ts = TreeSearch()
        bfs = BreadthFirstSearch(ts)
        problem = Problem(1, TestActionsFunction(3), TestResultFunction(), TestGoalTest(5))

        result = bfs.search(problem)
        self.assertTrue(bfs.is_failure(result))
Пример #2
0
    def test_failed_search(self):
        ts = TreeSearch()
        bfs = BreadthFirstSearch(ts)
        problem = Problem(1, TestActionsFunction(3), TestResultFunction(),
                          TestGoalTest(5))

        result = bfs.search(problem)
        self.assertTrue(bfs.is_failure(result))
Пример #3
0
    def test_successful_search_with_graph_search(self):
        gs = GraphSearch()
        bfs = BreadthFirstSearch(gs)
        problem = Problem(1, TestActionsFunction(), TestResultFunction(), TestGoalTest(5))

        result = bfs.search(problem)
        self.assertEqual(4, len(result))

        metrics = bfs.get_metrics();
        self.assertEqual(4, metrics[gs.METRIC_NODES_EXPANDED])
        self.assertEqual(4, metrics[gs.METRIC_PATH_COST])
Пример #4
0
    def test_successful_search_with_graph_search(self):
        gs = GraphSearch()
        bfs = BreadthFirstSearch(gs)
        problem = Problem(1, TestActionsFunction(), TestResultFunction(),
                          TestGoalTest(5))

        result = bfs.search(problem)
        self.assertEqual(4, len(result))

        metrics = bfs.get_metrics()
        self.assertEqual(4, metrics[gs.METRIC_NODES_EXPANDED])
        self.assertEqual(4, metrics[gs.METRIC_PATH_COST])