Exemple #1
0
    def _load_mob_types(self, load_mob_types=True):
        if not load_mob_types:
            return

        mob_property_data = minecraft_specs.get_mob_property_data()
        mob_name_to_properties = mob_property_data["name_to_properties"]
        for (name, m) in SPAWN_OBJECTS.items():
            type_name = "spawn " + name

            # load single mob as schematics
            memid = SchematicNode.create(self, [((0, 0, 0), (383, 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())

            # then load properties
            memid = MobTypeNode.create(self, type_name, (383, m))
            self.add_triple(subj=memid,
                            pred_text="has_name",
                            obj_text=type_name)
            if mob_name_to_properties.get(type_name) is not None:
                for property in mob_name_to_properties[type_name]:
                    self.add_triple(subj=memid,
                                    pred_text="has_name",
                                    obj_text=property)
Exemple #2
0
def specify_object(ref_obj_dict, sl=32, flat=False):
    shape_keys = [
        "has_size",
        "has_thickness",
        "has_radius",
        "has_depth",
        "has_width",
        "has_height",
        "has_length",
        "has_slope",
        "has_orientation",
        "has_distance",
        "has_base",
        "has_colour",
    ]

    ##############################################
    # hack to deal with size ranges in size_words
    ##############################################
    fake_interpreter = Dummy()
    fake_interpreter.agent = Dummy()

    def ssti(s):
        return size_str_to_int(s, ranges=RANGES)

    fake_interpreter.agent.size_str_to_int = ssti

    name = ref_obj_dict.get("has_name")
    if name is not None:
        stemmed_name = stemmer.stemWord(name)
        shapename = SPECIAL_SHAPES_CANONICALIZE.get(name) or SPECIAL_SHAPES_CANONICALIZE.get(
            stemmed_name
        )

        if SPAWN_OBJECTS.get(name):
            return name
        elif SPAWN_OBJECTS.get(stemmed_name):
            return stemmed_name

        if shapename:
            regularize_ref_obj_dict(ref_obj_dict, flat=flat)
            blocks, _ = interpret_shape_schematic(
                fake_interpreter, None, ref_obj_dict, shapename=shapename
            )
            return blocks
        else:
            # somethings wrong, abort
            return None
    else:
        if ref_obj_dict.get("has_shape"):
            regularize_ref_obj_dict(ref_obj_dict, flat=flat)
            blocks, _ = interpret_shape_schematic(fake_interpreter, None, ref_obj_dict)
            return blocks
        elif any(k in shape_keys for k in ref_obj_dict.keys()):
            regularize_ref_obj_dict(ref_obj_dict, flat=flat)
            if flat:
                shapename = random.choice(["TRIANGLE", "CIRCLE", "DISK", "RECTANGLE"])
            else:
                shapename = random.choice(list(SPECIAL_SHAPE_FNS.keys()))
            blocks, _ = interpret_shape_schematic(
                fake_interpreter, None, ref_obj_dict, shapename=shapename
            )
            return blocks
        else:
            # somethings wrong, abort
            return None