def create_recipe(end_product, material_names, quantity_types, tool_types, tool_type_default, ending_tools):
    """if not tools.has_word_type(end_product, [tools.WORD_TYPE_NOUN]):
        end_product_nounified = tools.nounify_first_result(end_product, "")
        if len(end_product_nounified) > 0 and end_product_nounified != end_product and end_product_nounified not in material_names:
            print("Nounified end product " + end_product + " => " + end_product_nounified)
            end_product = end_product_nounified
    """

    r = Recipe(end_product, ending_tools)

    for material_name in random.sample(material_names, min(4, len(material_names))):
        material_word_type = tools.find_most_common_word_type(material_name)

        # Unknown and length 12? Probably truncated, let's skip it.
        if material_word_type == tools.WORD_TYPE_UNKNOWN and len(material_name) == 12:
            continue

        if not tools.DEBUG_SKIP_WORD_ANALYSIS and material_word_type != tools.WORD_TYPE_NOUN and not tools.has_word_type(material_name, [tools.WORD_TYPE_NOUN]):
            material_name_nounified = tools.nounify_first_result(material_name, "")
            if len(material_name_nounified) > 0 and material_name_nounified != end_product and material_name_nounified not in material_names:
                print("Nounified material " + material_name + " => " + material_name_nounified)
                material_name = material_name_nounified
                material_word_type = tools.find_most_common_word_type(material_name)

        if material_word_type == tools.WORD_TYPE_ADJECTIVE:
            material_name = "being " + material_name

        if material_word_type in quantity_types:
            quantity_type = random.choice(quantity_types[material_word_type])
            amount = quantity_type.random_amount()

            r.add_material(Material(material_name, amount, quantity_type))

    tool_types = tool_types.copy()

    tool_count = random.randint(2, len(tool_types))

    # for tool_type in random.sample(tool_types, min(2, len(tool_types))):
    while len(r.tools) < tool_count:
        tool_type = tools.random_weighted_choice(tool_types, lambda t: t.chance_value)
        tool_types.remove(tool_type)

        tool = Tool(tool_type)
        # if not any(tool.equals(other_tool) for other_tool in r.tools):
        r.add_tool(tool)

    r.add_tool(Tool(tool_type_default))

    r.finish()

    print("=======================")
    print()
    r.print()

    return r
    def execute_random_action(self, recipe):
        tries_left = 20

        while tries_left > 0:
            action = tools.random_weighted_choice(self.actions, lambda a: a.current_chance())
            if action.execute(self, recipe):
                self.used = True
                return True

            tries_left -= 1

        return False
    def finish(self):
        self.available_materials = list(map(lambda material: material.copy(), self.materials))

        instruction_count_target = random.randint(random.randint(2, 5), 10)
        tries_left = 100
        while (len(self.instructions) < instruction_count_target) and (tries_left > 0):
            chosen_tool = tools.random_weighted_choice(self.tools, lambda t: t.current_chance_sum())
            if chosen_tool.execute_random_action(self):
                for tool in self.tools:
                    tool.advance_cooldowns()
            else:
                tries_left -= 1

        for tool in self.tools:
            if tool.is_filled():
                tool.execute_random_generating_filled_action(self)

        """
        if self.has_materials_available():
            instruction = "Drop " + \
                          tools.concat_list(self.available_materials, lambda material: material.get_label_full()) + \
                          " into a pile on the floor"
            self.add_instruction(instruction)
            self.add_instruction("Wait until they magically transform into " + self.end_product_with_indefinite_article)
        else:
            self.add_instruction("Wait a bit until " + self.end_product_with_indefinite_article + " suddenly appears")
        """

        self.tools = [tool for tool in self.tools if tool.used]

        has_materials_available = self.has_materials_available()
        while True:
            ending_tool = random.choice(self.ending_tools)
            if ending_tool.uses_materials == has_materials_available:
                self.ending_tool_tools = ending_tool.get_concrete_tools()
                ending_tool.execute(self, self.ending_tool_tools)
                break