示例#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 test_distance_from_max_heuristic100(self):
     print("max dist 100 height")
     lapses = []
     for h in range(15, 60, 6):
         print("#" * 100)
         print(h)
         start = time.time()
         s = a_star_search(
             Cover_Block_Search(height_goal=h,
                                floor_size=30,
                                limit_branching=200000,
                                limit_sons=500,
                                limit_blocks_in_action=4,
                                random_order=False,
                                ring_width=3,
                                number_of_rings=1,
                                distance_between_rings=12), dist_heuristic)
         lapse = time.time() - start
         blocks = []
         for action in s:
             blocks.extend(action)
         print(len(blocks))
         lapses.append((h, lapse, len(s), len(blocks)))
         pp(lapses)
         pp(s)
     for h, lapse, steps, nblocks in lapses:
         print("no_heuristic\t{}\t{}\t{}\t{}\t".format(
             h, lapse, steps, nblocks))
     # blocks = []
     # for action in s:
     #     blocks.extend(action)
     # print(len(blocks))
     SAVE = False
     if SAVE:
         save_process(actions=s,
                      subfolder="2rings_small_steps",
                      seperate_by_orientation=True)
示例#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)