コード例 #1
0
 def generate_description(self, arg_index=0, index=0, templ_index=0):
     description = self.node.args[arg_index].generate_description()
     word = description["name"]
     node_template = get_template_names(self, templ_index)
     if node_template[index - 1] == "Copy":
         word = random.choice([word, prepend_a_an(word)])
     if "AskIs" in node_template and index == len(node_template) - 1:
         word = prepend_a_an(word)
     return word
コード例 #2
0
 def generate_description(self, arg_index=0, index=0, templ_index=0):
     template_names = get_template_names(self, templ_index)
     if "RepeatCount" in template_names:
         return self._size_description
     phrase = random.choice(
         [self._size_description,
          prepend_a_an(self._size_description)])
     return phrase
コード例 #3
0
    def generate_description(self, arg_index=0, index=0, templ_index=0):
        description = self.node.args[arg_index].generate_description()
        block_type = description["block_type"]
        template_name = get_template_names(self, templ_index)

        previous_template_name = template_name[index - 1]
        if previous_template_name == "Build":
            return prepend_a_an(block_type)
        return block_type
コード例 #4
0
 def generate_description(self, arg_index=0, index=0, templ_index=0):
     description = self.node.args[arg_index].generate_description()
     word = description["word"]
     template_names = get_template_names(self, templ_index)
     previous_template_name = template_names[index - 1]
     # with a 0.5 probability, return with a/an
     if previous_template_name == "Build":
         if pick_random():
             return prepend_a_an(word)
     return word
コード例 #5
0
    def generate_description(self, arg_index, index, templ_index=0):
        description = self.node.args[arg_index].generate_description()
        colour = description["colour"]

        template = get_template_names(self, templ_index)
        previous_template_name = template[index - 1]
        # For Build: Build a red archway / Build red archway
        if previous_template_name == "Build":
            if pick_random():
                return prepend_a_an(colour)
        return colour
コード例 #6
0
    def generate_description(self, arg_index, index, templ_index=0):
        description = self.node.args[arg_index].generate_description()
        size = description["size"]

        template = get_template_names(self, templ_index)
        previous_template_name = template[index - 1]
        # For Build: Build a huge archway / Build huge archway
        if previous_template_name == "Build":
            if pick_random():
                return prepend_a_an(size)
        return size
コード例 #7
0
 def handle_task_refobj_string(self, task, refobj_attr):
     if refobj_attr == "name":
         for pred, val in task.task.target:
             if pred == "has_name":
                 return "I am going to the " + prepend_a_an(val), None
     elif refobj_attr == "location":
         target = tuple(task.task.target)
         return "I am going to {}".format(target), None
     else:
         raise ErrorWithResponse(
             "trying get attribute {} from action".format(refobj_attr))
コード例 #8
0
ファイル: mob.py プロジェクト: Mario-Kart-Felix/droidlet
    def generate_description(self, arg_index=0, index=0, templ_index=0):
        template_name = get_template_names(self, templ_index)
        description = self.node.args[arg_index].generate_description()

        if any(x in ["RepeatAll", "RepeatCount"]
               for x in template_name) and ("mob_prefix" in description):
            return " ".join([description["mob_prefix"], description["mob"]])
        elif "Spawn" in template_name:
            mob_name = description["mob"]
            # append a/an randomly: "Spawn pig" / "Spawn a pig"
            return random.choice([mob_name, prepend_a_an(mob_name)])
        return description["mob"]
コード例 #9
0
 def handle_task_refobj_string(self, task, refobj_attr):
     if refobj_attr == "name":
         assert isinstance(task.task, Build), task.task
         for pred, val in task.task.schematic_tags:
             if pred == "has_name":
                 return "I am building " + prepend_a_an(val), None
             return "I am building something that is {}".format(val), None
     elif refobj_attr == "location":
         assert task.action_name == "Move", task.action_name
         target = tuple(task.task.target)
         return "I am going to {}".format(target), None
     else:
         raise ErrorWithResponse(
             "trying get attribute {} from action".format(refobj_attr))
     return None, None
コード例 #10
0
def build_random_shape(agent,
                       shape_util_dict,
                       rand_range=(10, 0, 10),
                       no_chat=False):
    """Pick a random shape from shapes.py and build that"""
    target_loc = agent.pos
    for i in range(3):
        target_loc[i] += np.random.randint(-rand_range[i], rand_range[i] + 1)
    shape = random.choice(shape_util_dict["shape_names"])
    opts = shape_util_dict["shape_option_fn_map"][shape]()
    opts["bid"] = shape_util_dict["bid"]
    schematic = shape_util_dict["shape_fns"][shape](**opts)
    relations = [
        {
            "pred": "has_name",
            "obj": shape.lower()
        },
        {
            "pred": "has_tag",
            "obj": shape.lower()
        },
    ]
    task_data = {
        "blocks_list": schematic,
        "origin": target_loc,
        "verbose": False,
        "schematic_tags": relations,
        "default_behavior":
        "build_random_shape",  # must == function name. Hacky and I hate it.
    }
    logging.debug("Default behavior: building {}".format(shape))
    TaskNode(agent.memory, tasks.Build(agent, task_data).memid)

    if not no_chat:
        shape_name = prepend_a_an(shape.lower())
        # FIXME agent , also don't push directly to stack, ask the manager?
        Say(
            agent,
            task_data={
                "response_options":
                "I am building {} while you decide what you want me to do!".
                format(shape_name)
            },
        )
    return schematic
コード例 #11
0
    def add_generate_args(self, index=0, templ_index=0):
        self._phrase = None
        this_phrase = None

        template_name = get_template_names(self, templ_index)
        plural = False
        phrase = random.choice(dig_shapes)
        this_phrase = phrase
        if "RepeatCount" in template_name:
            phrase = make_plural(random.choice(dig_shapes))
            this_phrase = phrase
            plural = True
        if not plural and (template_name[index - 1]
                           not in ["DigDimensions", "DigAbstractSize"]):
            this_phrase = phrase
            phrase = random.choice([phrase, prepend_a_an(phrase)])
        self.node.schematic["has_name"] = this_phrase
        self._phrase = phrase
コード例 #12
0
ファイル: tag.py プロジェクト: Mario-Kart-Felix/droidlet
 def generate_description(self, arg_index=0, index=0, templ_index=0):
     return prepend_a_an(self._tag)