Пример #1
0
 def test_null_heuristic(self):
     print("Null heuristic test")
     s = a_star_search(Block_Search(height_goal=20, floor_size=7))
     pp(s)
     blocks = []
     for action in s:
         blocks.extend(action)
     if SAVE:
         save_by_orientation_blocks(blocks=blocks,
                                    subfolder="null_heuristic20")
Пример #2
0
 def test_distance_from_max_heuristic20(self):
     print("max dist 20 height")
     s = a_star_search(Block_Search(height_goal=20, floor_size=7),
                       dist_heuristic)
     pp(s)
     blocks = []
     for action in s:
         blocks.extend(action)
     if SAVE:
         save_by_orientation_blocks(blocks=blocks,
                                    subfolder="search_result_20")
Пример #3
0
    def test_distance_from_max_heuristic50sym(self):
        print("max dist 50 height, symmetrical")

        s = a_star_search(
            Block_Search(use_symmetry=True, height_goal=50, floor_size=5),
            dist_heuristic)
        pp(s)

        blocks = []
        for action in s:
            blocks.extend(action)
        if SAVE:
            save_by_orientation_blocks(blocks=blocks,
                                       subfolder="search_result_50_sym")
Пример #4
0
 def test_null_heuristic_less_branch(self):
     print("Null heuristic test with smaller branching factor")
     s = a_star_search(
         Cover_Block_Search(height_goal=16,
                            floor_size=50,
                            limit_branching=5,
                            limit_sons=200))
     pp(s)
     blocks = []
     for action in s:
         blocks.extend(action)
     if SAVE:
         save_by_orientation_blocks(blocks=blocks,
                                    subfolder="null_heuristic20")
Пример #5
0
def save_process(actions,
                 subfolder="default",
                 translation=(0, 0, 0),
                 seperate_by_orientation=True):
    try:
        os.mkdir(os.path.join("saved_stls", subfolder))
    except Exception as e:
        print(e)
    if seperate_by_orientation:
        try:
            for orientation in ORIENTATIONS.keys():
                os.mkdir(os.path.join("saved_stls", subfolder, orientation))
        except Exception as e:
            print(e)
    if translation == (0, 0, 0):
        block_aggregation = []
        for i, block_list in enumerate(actions):
            block_aggregation += block_list
            if seperate_by_orientation:
                save_by_orientation_blocks(block_aggregation,
                                           subfolder=subfolder)
            else:
                m = combine([b.render() for b in block_aggregation])
                save([m], subfolder=subfolder)
Пример #6
0
 def test_distance_from_max_heuristic20(self):
     print("max dist 50 height")
     s = a_star_search(
         Cover_Block_Search(height_goal=200,
                            floor_size=60,
                            limit_branching=200000,
                            limit_sons=500,
                            limit_blocks_in_action=20,
                            random_order=True,
                            ring_width=15,
                            number_of_rings=1,
                            distance_between_rings=15), dist_heuristic)
     DISPLAY = True
     SAVE = True
     pp(s)
     blocks = []
     for action in s:
         blocks.extend(action)
     if DISPLAY:
         display([b.render() for b in blocks], scale=50)
     if SAVE:
         save_by_orientation_blocks(blocks=blocks,
                                    subfolder="last52",
                                    seperate_orientations=False)