コード例 #1
0
ファイル: tests.py プロジェクト: mohammadT77/AI-KHU-TA-98-99
 def test_state_hash(self):
     from models import NodeState
     name = 'A'
     n = NodeState(name)
     # print(n)
     # print(hash(n))
     self.assertEqual(n.id, hash(n))
コード例 #2
0
ファイル: tests.py プロジェクト: mohammadT77/AI-KHU-TA-98-99
    def test_dfs_nodeState_1_success(self):
        from search_algorithms import dfs_recursive as dfs_r
        from models import NodeState
        S = NodeState("start")
        A = NodeState("a")
        B = NodeState("b")
        C = NodeState("c")
        D = NodeState("d")
        G = NodeState("goal")

        states = {
            S: [A, B, D],
            A: [S, C],
            B: [S, D],
            C: [D, A, G],
            D: [S, A, C, G, B],
            G: [A, G],
        }

        start_state = S  # Initial state
        goal_state = G

        res = dfs_r(states=states, start=start_state, goal=goal_state)
        print([str(r) for r in res])
        # print(res)
        # print([S, A, C, G])
        # print([str(r) for r in [S, A, C, G]])
        self.assertListEqual(res, [S, A, C, D, G])
コード例 #3
0
ファイル: tests.py プロジェクト: mohammadT77/AI-KHU-TA-98-99
    def test_dfs_nodeState_1_failure(self):
        from search_algorithms import dfs_recursive
        from models import NodeState
        S = NodeState("start")
        A = NodeState("a")
        B = NodeState("b")
        C = NodeState("c")
        D = NodeState("d")
        G = NodeState("goal")
        states = {
            S.name: [A, B, D],
            A.name: [S, C],
            B.name: [S, D],
            C.name: [D, A, G],
            D.name: [B, S, A, C, G],
            G.name: [A, G],
        }
        start_state = S  # Initial state
        goal_state = G

        # res = dfs_recursive(states=states, start=start_state, goal=goal_state)
        self.assertRaises(Exception, dfs_recursive, states, start_state,
                          goal_state)
コード例 #4
0
ファイル: tests.py プロジェクト: mohammadT77/AI-KHU-TA-98-99
 def test_node_eq_failure(self):
     from models import NodeState
     self.assertFalse(NodeState("s") == NodeState('S1'))
     self.assertNotEqual(NodeState("s"), NodeState('S1'))
コード例 #5
0
ファイル: tests.py プロジェクト: mohammadT77/AI-KHU-TA-98-99
 def test_node_eq_success(self):
     from models import NodeState
     self.assertEqual(NodeState("s"), NodeState('S'))
コード例 #6
0
ファイル: tests.py プロジェクト: mohammadT77/AI-KHU-TA-98-99
 def test_create_node_failure(self):
     from models import NodeState
     name = 's'
     n = NodeState(name)
     print(n)
     self.assertNotEqual(n.name, name)
コード例 #7
0
ファイル: tests.py プロジェクト: mohammadT77/AI-KHU-TA-98-99
 def test_create3_node_success(self):
     from models import NodeState
     name = 1
     n = NodeState(name)
     print(n)
     self.assertEqual(n.name, '1')
コード例 #8
0
ファイル: tests.py プロジェクト: mohammadT77/AI-KHU-TA-98-99
 def test_create2_node_success(self):
     from models import NodeState
     name = 's'
     n = NodeState(name)
     print(n)
     self.assertEqual(n.name, name.upper())