Beispiel #1
0
    print('=' * 50)
    print('=' * 50)
    print("A MAP")
    print('=' * 50)
    print('=' * 50)

    # Roads are
    # Between A and B, cost 2
    # One-way from A to C, cost 4
    # Between A and D, cost 10
    # Between B and D, cost 3
    # Betweeb C and D, cost 6

    # Start A, goal D

    city_map = CityMap()

    city_map.add_road('A', 'B', 2)
    city_map.add_one_way_road('A', 'C', 4)
    city_map.add_road('A', 'D', 10)
    city_map.add_road('B', 'D', 3)
    city_map.add_road('C', 'D', 6)

    # Heuristic


    def city_h(node):
        if node.state == 'A':
            return 5
        elif node.state == 'B':
            return 2
Beispiel #2
0
 print '-' * 50
 print "Running A*-TREE-SEARCH USING # MISPLACED TILES HEURISTIC"
 print '-' * 50
 
 asts = astar_search(ep, misplaced_tiles_heuristic, search_type=best_first_tree_search)
 
 print "Solution", asts.solution()
 
 print
 print '=' * 50
 print '=' * 50
 print "HW1 MAP"
 print '=' * 50
 print '=' * 50
 
 city_map = CityMap()
 
 city_map.add_road('F', 'S', 5)
 
 city_map.add_road('S', 'C', 6)
 city_map.add_one_way_road('S', 'A', 2)
 
 city_map.add_one_way_road('A', 'D', 3)
 city_map.add_road('A', 'B', 5)
 
 city_map.add_road('B', 'G', 7)
 
 city_map.add_one_way_road('C', 'D', 3)
 city_map.add_road('C', 'E', 4)
 
 city_map.add_road('D', 'E', 4)
Beispiel #3
0
    print('-' * 50)
    print("DEPTH-FIRST-TREE-SEARCH")
    print('-' * 50)

    dfts = depth_first_search(fq, search_type=uninformed_tree_search)

    print("Solution", dfts.solution())

    print()
    print('=' * 50)
    print('=' * 50)
    print("Q2-5: TRAVEL")
    print('=' * 50)
    print('=' * 50)

    city_map = CityMap()

    city_map.add_road('F', 'S', 5)
    city_map.add_one_way_road('S', 'A', 2)
    city_map.add_road('S', 'C', 6)
    city_map.add_one_way_road('A', 'D', 3)
    city_map.add_road('A', 'B', 5)
    city_map.add_one_way_road('C', 'D', 3)
    city_map.add_road('C', 'E', 4)
    city_map.add_road('D', 'E', 4)
    city_map.add_road('B', 'G', 7)
    city_map.add_road('E', 'G', 3)

    def city_h(node):
        if node.state == 'A':
            return 5
Beispiel #4
0
    print '-' * 50
    	
    bfts = breadth_first_search(nq, search_type=uninformed_tree_search)
    
    print "Solution", bfts.solution()
    
		
    print
    print '=' * 50
    print '=' * 50
    print "HW1 MAP Question 3,4,5"
    print '=' * 50
    print '=' * 50

	
    city_map = CityMap()
    
    city_map.add_road('F', 'S', 5)
    
    city_map.add_road('S', 'C', 6)
    city_map.add_one_way_road('S', 'A', 2)
    
    city_map.add_one_way_road('A', 'D', 3)
    city_map.add_road('A', 'B', 5)
    
    city_map.add_road('B', 'G', 7)
    
    city_map.add_one_way_road('C', 'D', 3)
    city_map.add_road('C', 'E', 4)
    
    city_map.add_road('D', 'E', 4)