Page 1 of 1

Double Assembling Machine

Posted: Sat Nov 28, 2020 11:21 pm
by Mecejide
It’s like https://mods.factorio.com/mod/DoubleFurnace, except it’s an assembling machine. This means it assembles one type of item, such as copper cable, and then uses that type of item to assemble another, such as electronic circuits. In the example I gave, the overall recipe would be 3 copper plate+2 iron plate+2.5 seconds->2 electronic circuit.

Re: Double Assembling Machine

Posted: Tue Dec 01, 2020 10:00 pm
by darkfrei
Mecejide wrote: Sat Nov 28, 2020 11:21 pm It’s like https://mods.factorio.com/mod/DoubleFurnace, except it’s an assembling machine. This means it assembles one type of item, such as copper cable, and then uses that type of item to assemble another, such as electronic circuits. In the example I gave, the overall recipe would be 3 copper plate+2 iron plate+2.5 seconds->2 electronic circuit.
The whole mod code:

Code: Select all

data:extend({
	{
		type = "recipe",
		name = "electronic-circuit",
		energy_required = 2.5,
		ingredients =
		{
			{"copper-plate", 3},
			{"iron-plate", 2}
		},
		result = "electronic-circuit",
		result_count = 2
	}
})

Re: Double Assembling Machine

Posted: Wed Dec 02, 2020 1:03 am
by Mecejide
darkfrei wrote: Tue Dec 01, 2020 10:00 pm
Mecejide wrote: Sat Nov 28, 2020 11:21 pm It’s like https://mods.factorio.com/mod/DoubleFurnace, except it’s an assembling machine. This means it assembles one type of item, such as copper cable, and then uses that type of item to assemble another, such as electronic circuits. In the example I gave, the overall recipe would be 3 copper plate+2 iron plate+2.5 seconds->2 electronic circuit.
The whole mod code:

Code: Select all

data:extend({
	{
		type = "recipe",
		name = "electronic-circuit",
		energy_required = 2.5,
		ingredients =
		{
			{"copper-plate", 3},
			{"iron-plate", 2}
		},
		result = "electronic-circuit",
		result_count = 2
	}
})
That code looks like it only adds a single recipe.

Re: Double Assembling Machine

Posted: Wed Dec 02, 2020 8:07 am
by darkfrei
Mecejide wrote: Wed Dec 02, 2020 1:03 am That code looks like it only adds a single recipe.
Yes, you are need to define what pairs of recipes must be compound. You cannot say: "do all recipes!"
You are need defined pairs, same as by your example. No example - no recipe.

Re: Double Assembling Machine

Posted: Wed Dec 02, 2020 9:50 am
by kirazy
darkfrei wrote: Wed Dec 02, 2020 8:07 am
Mecejide wrote: Wed Dec 02, 2020 1:03 am That code looks like it only adds a single recipe.
Yes, you are need to define what pairs of recipes must be compound. You cannot say: "do all recipes!"
You are need defined pairs, same as by your example. No example - no recipe.
You could probably make a gnarly recursive algorithm to do this, but... it would be gnarly.

Take a given recipe, read the ingredients.

Search existing recipes for each ingredient.

If recipe exists, replace the ingredient in the first recipe with the ingredients in the second.

Repeat until you can't find a recipe.

Subject to unforseen obstacles, of course. Like when the ingredient is from multiple recipes.

Re: Double Assembling Machine

Posted: Wed Dec 02, 2020 10:58 am
by darkfrei
kirazy wrote: Wed Dec 02, 2020 9:50 am
Repeat until you can't find a recipe.
Now you build rocket parts from ore and crude oil.

Re: Double Assembling Machine

Posted: Wed Dec 02, 2020 11:05 am
by Deadlock989
It's the recycling/scrapping algorithm in reverse. Break all ingredients down into the ingredients from their recipes. Continue until nothing can be broken down further. Add all the constituent ingredients together. In this case you could maybe stop it after just one or two iterations so that you avoid the ore -> rockets effect, but since the original poster has a history of posting incredibly terse, vague requests and then complaining when people don't read his mind, I'm not going to try and guess what it is he wants.

Re: Double Assembling Machine

Posted: Wed Dec 02, 2020 6:26 pm
by Mecejide
What I want is an assembling machine that crafts the equivalent of two assembling machine recipes at a time. For example, it could make an engine unit from a steel plate, iron plates, and pipes or from a steel plate, iron plates, and an iron gear wheel but not iron plates, an iron gear wheel, and pipes (because steel plates aren’t made in an assembling machine); from a steel plate and iron plates (because that would be three recipes, not two); or from a steel plate, an iron gear wheel, and pipes (because that would be one recipe, also not two, and it would be a waste of resources since the double assembling machine should be pretty expensive).

Re: Double Assembling Machine

Posted: Wed Dec 02, 2020 8:33 pm
by kirazy
Mecejide wrote: Wed Dec 02, 2020 6:26 pm What I want is an assembling machine that crafts the equivalent of two assembling machine recipes at a time. For example, it could make an engine unit from a steel plate, iron plates, and pipes or from a steel plate, iron plates, and an iron gear wheel but not iron plates, an iron gear wheel, and pipes (because steel plates aren’t made in an assembling machine); from a steel plate and iron plates (because that would be three recipes, not two); or from a steel plate, an iron gear wheel, and pipes (because that would be one recipe, also not two, and it would be a waste of resources since the double assembling machine should be pretty expensive).
So you'd need an algorithm that decomposes ingredients into their constituents, subject to filtering, e.g. you don't decompose a steel plate, and you'd only apply it on the ingredients of the item you're intending to make.

I think trying to make an assembling machine that you pick a recipe and you can input the ingredients from one step removed would be much harder.

Re: Double Assembling Machine

Posted: Wed Dec 02, 2020 8:35 pm
by kirazy
darkfrei wrote: Wed Dec 02, 2020 10:58 am
kirazy wrote: Wed Dec 02, 2020 9:50 am
Repeat until you can't find a recipe.
Now you build rocket parts from ore and crude oil.
You could make a whitelist of which components should not be decomposed, everything made in furnaces for example.

Re: Double Assembling Machine

Posted: Wed Dec 02, 2020 10:31 pm
by darkfrei
kirazy wrote: Wed Dec 02, 2020 8:35 pm You could make a whitelist of which components should not be decomposed, everything made in furnaces for example.
Now you build rocket parts from iron plates and copper plates (and crude oil).

Re: Double Assembling Machine

Posted: Wed Dec 02, 2020 10:56 pm
by kirazy
darkfrei wrote: Wed Dec 02, 2020 10:31 pm
kirazy wrote: Wed Dec 02, 2020 8:35 pm You could make a whitelist of which components should not be decomposed, everything made in furnaces for example.
Now you build rocket parts from iron plates and copper plates (and crude oil).
Which is where you don't apply the algorithm generally. He's not asking to make everything from their base components, only to be able to do a two-step recipe process in one-step, so rather than an assembling machine for copper cables into an assembling machine for electronic circuits, you'd have one machine for electronic circuits taking the inputs for copper cables in addition to its normal inputs.

For something like rocket parts, you'd have intermediaries at one remove, not all the way to maximum decomposed.