コード例 #1
0
    def _load_block_types(
        self, load_block_types=True, load_color=True, simple_color=False, load_material=True
    ):
        if not load_block_types:
            return
        bid_to_name = minecraft_specs.get_block_data()["bid_to_name"]
        color_data = minecraft_specs.get_colour_data()
        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(memid, "has_name", type_name)
            if "block" in type_name:
                self.add_triple(memid, "has_name", type_name.strip("block").strip())

            if load_color:
                if simple_color:
                    name_to_colors = color_data["name_to_simple_colors"]
                else:
                    name_to_colors = color_data["name_to_colors"]

                if name_to_colors.get(type_name) is None:
                    continue
                for color in name_to_colors[type_name]:
                    self.add_triple(memid, "has_color", color)
コード例 #2
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)
コード例 #3
0
import numpy as np
from scipy.ndimage.filters import median_filter
from scipy.optimize import linprog

import logging
import minecraft_specs
import util

from block_data import BORING_BLOCKS, PASSABLE_BLOCKS
from entities import MOBS_BY_ID
from search import depth_first_search

GROUND_BLOCKS = [1, 2, 3, 7, 8, 9, 12, 79, 80]
MAX_RADIUS = 20
BLOCK_DATA = minecraft_specs.get_block_data()
COLOUR = minecraft_specs.get_colour_data()
BID_COLOR_DATA = minecraft_specs.get_bid_to_colours()


# 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