Helfima / helmod

Factorio Mod
149 stars 64 forks source link

Products linked broken #516

Closed Helfima closed 2 months ago

Helfima commented 3 months ago

image rework calculation block by block ?

SerhiyShamshetdinov commented 3 months ago

Just to remember in the same topic:

1) Looks like: by-product of the block from tree level 3 never is linked to requested one at level 2 (root is 1): https://discord.com/channels/676795981437599765/676798501753192509/1220467638619209830

2) There is no way to control output by-product linking inside the block: Ctrl-click works the same as click - it opens input for overproduction amount: https://discord.com/channels/676795981437599765/676797589659713586/1218650690101182524

3) The block (contrarily to recipe) has no control on selecting primary output product ("+" marking) and on detaching by-product ("-" mark, I never used). So: no way to tell to resolver what is a primary product to use in calculations.

4) For unlinked block at root level: it's by-product is always linked to upper block requested amount. So, it is not possible to get correct amount of the primary (manually requested, green) product: https://discord.com/channels/676795981437599765/676798501753192509/1220504215617540147

5) Here, on blue output product of the level 2 block, Ctrl-Click works (also absent in help balloon) and tree is refreshed, but "+" mark is not shown (but do it should? or just should not accept click?))): image

Helfima commented 2 months ago

I found a complex solution In this example I have 3 blocks, the B bloc need item from C bloc, 3 linked products image When compute the C block, I solve the first A matrix, that take all inputs for objectives and I do same for each linked products but I use the first found product to create objectives image We can solve A matrix with all other matrix image After I report values C1, C2 and C3 in C matrix here C final = C + C1x1 + C2x0.5 + C3x0.5

Helfima commented 2 months ago

fixed v1.0.9

SerhiyShamshetdinov commented 2 months ago

It looks like there is still mistake is: It counts the required amount of the product (made in White bulb block) much more than actually required. The grey bulb uses it outside and also product is used inside the white bulb block:

Required: 0.06=0.03+0.03 inside White Bulb Block 0.06 inside Grey Bulb Block = 0.12

Actually calculated to produce = 0.33 White Bulb Block exports 0.28 instead of minimum required 0.06 = 0.21 more

Top level usage and "export":

image

White bulb block "export" and the product block:

image

Usages of the product in White Bulb Block:

image

Product block actually has 2 independent products (second one is correctly calculated but is used only inside White Bulb Block) It was cleaned and shows the the same in both Matrix and Element Mode:

image
SerhiyShamshetdinov commented 2 months ago

@Helfima but I actually tested this after copy-pasting my big tree to new one. And I saw differences. It looks like it's copied partially (loses some properties when is pasted or when is copied).

At least it looses product "locked" property and the set amount of such product.

So fun that with above product in my primary tree everything is good))) Minor overproduction in bounds of the error:

image
SerhiyShamshetdinov commented 2 months ago

Ok, another 2 products: 1st is only used by the block of the root level (Grey Bulb) 2nd is never used !!! Both products are produced in 1 block inside the White Bulb Block (so in 1 level of the consumer block)

The strange thing is that both products are calculated to the same amount (and for the 1st one it is still wrong - with overproduction). Looks like ones are linked to each other in some calculations)

White Bulb screen where this block resides:

image

Inside the block where these products produced based on other common products:

image

Root level where White block exports these products and Grey Block consumes only 1st (2 pictures):

image image

Finally, after tree copy-pasting the general picture is the same but the common calculated amount is different (0.48 instead of 0.34):

image

Hope this will help :-)

SerhiyShamshetdinov commented 2 months ago

@Helfima you know, copy-pasting gives some clean position to validate features. I'm afraid of some possible trash in my tree since it was started in the past version and we had several versions of v1.

But some new properties possibly are missed in tree copy or paste.

Hellmode is very useful for me playing 3 years. Don't know to play without it)))

Good luck!