Esempio n. 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))
Esempio n. 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))
Esempio n. 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])
Esempio n. 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])