Example #1
0
    def _load_block_types(
        self,
        load_block_types=True,
        load_color=True,
        load_block_property=True,
        simple_color=False,
        load_material=True,
    ):
        """Load all block types into agent memory"""
        if not load_block_types:
            return
        bid_to_name = minecraft_specs.get_block_data()["bid_to_name"]

        color_data = minecraft_specs.get_colour_data()
        if simple_color:
            name_to_colors = color_data["name_to_simple_colors"]
        else:
            name_to_colors = color_data["name_to_colors"]

        block_property_data = minecraft_specs.get_block_property_data()
        block_name_to_properties = block_property_data["name_to_properties"]

        for (b, m), type_name in bid_to_name.items():
            if b >= 256:
                continue
            memid = BlockTypeNode.create(self, type_name, (b, m))
            self.add_triple(subj=memid,
                            pred_text="has_name",
                            obj_text=type_name)
            if "block" in type_name:
                self.add_triple(subj=memid,
                                pred_text="has_name",
                                obj_text=type_name.strip("block").strip())

            if load_color:
                if name_to_colors.get(type_name) is not None:
                    for color in name_to_colors[type_name]:
                        self.add_triple(subj=memid,
                                        pred_text="has_colour",
                                        obj_text=color)

            if load_block_property:
                if block_name_to_properties.get(type_name) is not None:
                    for property in block_name_to_properties[type_name]:
                        self.add_triple(subj_text=memid,
                                        pred_text="has_name",
                                        obj_text=property)
Example #2
0
    manhat_dist,
    get_locs_from_entity,
    build_safe_diag_adjacent,
    euclid_dist,
    to_block_pos,
    fill_idmeta,
)
from block_data import BORING_BLOCKS, PASSABLE_BLOCKS, COLOR_BID_MAP
from search import depth_first_search
from mc_memory_nodes import InstSegNode, BlockObjectNode

GROUND_BLOCKS = [1, 2, 3, 7, 8, 9, 12, 79, 80]
MAX_RADIUS = 20
BLOCK_DATA = minecraft_specs.get_block_data()
COLOUR_DATA = minecraft_specs.get_colour_data()
BLOCK_PROPERTY_DATA = minecraft_specs.get_block_property_data()
MOB_PROPERTY_DATA = minecraft_specs.get_mob_property_data()
BID_COLOR_DATA = minecraft_specs.get_bid_to_colours()
COLOUR_LIST = list(COLOR_BID_MAP.keys())


# Taken from : stackoverflow.com/questions/16750618/
# whats-an-efficient-way-to-find-if-a-point-lies-in-the-convex-hull-of-a-point-cl
def in_hull(points, x):
    """Check if x is in the convex hull of points"""
    n_points = len(points)
    c = np.zeros(n_points)
    A = np.r_[points.T, np.ones((1, n_points))]
    b = np.r_[x, np.ones(1)]
    lp = linprog(c, A_eq=A, b_eq=b)
    return lp.success