EMI

EMI

1M Downloads

[Feature Request] Tree of production (not only crafting dependency)

AlaronFV opened this issue ยท 2 comments

commented

I have created some example python code that can generate best production tree for give requirements (resource, amount, needed time, etc.). It create tree of machines and tell that for given time requirements the best amount of instances of each machine is so. Example code is: https://github.com/AlaronFV/Production_Lines

commented

What you're asking for here is unclear, but the things I can grasp seem out of scope for the information provided to EMI. If you can better explain what you're asking for and it makes more sense, I can reopen this issue.

commented

Ok, things are so. It is the same thing as crafting tree generated by EMI. But it generate not only the amounts of resources for each node, but also if to automate this crafting tree, how many machines (methods) one need to place for each node of crafting tree for given time requirement.

To do that it firstly, from all recipes, create recursively crafting tree with every possible method to generate some resource. And for each sub-tree (input resource for machine) in each method, we creating other bunch of methods, and so on until reaching either no recipe for this input resource or loop.

Then, it, from that resulted recipes tree, generate all possible lines of machines, as to handle all possible ways (in given recipes) to craft needed resource.

Then in uses minimize from python's lib scipy module optimize, to to create best amount of instances of each machine in a production line, by adding or subtracting from initial amount (1) of machines (or at least i think it works so) and runing the simulation for given line of machines, with objective to find such Ms (list of amounts) that total amount of steps (until needed amount of needed resource in last machine is reached) will be nearest to given time requirement.

After that it make these Ms to ints as they can be floats, but we can't have 1.5 machine, thus we have to check 1 machine and 2 machines and choose the variant with nearest total amount of steps to given time requirement. And so for each line of machines.

And that is all. It get 5 lines with nearest total steps to given time requirement, and then give it in form of Obsidian canvas, but it can be do by any other way.

All is needed to make it work, is list of recipes with such structure as in given repository, but basically main things are:

  • inputs combinations (which are possible inputs combinations to for one output combination, like for crucible from exnihilo for the same N amount of lava per one operation (per time) it can eat different amount for obsidian or for cobblestone, as in my pack obsidian give 1000mb and cobblestone 250mb, but basically it can be removed if needed, just by removing one for loop in generate_production_tree which loop through them)
  • outputs: list of outputs with name, amount to generate per operation, probability (hardcoded to multiply it by 0.8 if it is not 1(can be easily changed just by ctrl+f and typing 0.8)), and type (for pipes speed restriction)
  • time: amount of steps needed for processing to complete. Can be taken from jsons with recipes (maybe); if 0 will craft within one step all possible to craft resources from inputs of machine.
  • other can be done in any way, they don't matter too much, just naming and differentiating between recipes and methods.

The exact code in repository might not even work, at least it worked and generated such trees, but i didn't test it much, and basically it just need to give an idea what to do and how to do it. There are some images of nodes in Obsidian canvas it've generated for generating cobblestone (images i've created by myself and the code is just accessing them) (i created recipes manually, so as it is too troublesome to extract recipes, parse them, and so on to make such program usable, and because i'm too lazy, I'll just give that code and ideas to someone, who can utilize it).
image
image
image
image