Page 1 of 1

[0.7.4] Extra products

Posted: Sun Oct 27, 2013 4:30 pm
by jannee
I have problem with Assembling mashine 3. I put 4 Productivity modules 3 and craft 5x one item and Mashine give me only 2 additional products and end after 5th item on 99% next one. Is it a bug? I calculate it 5p. / 100% = 0,05% * 60% = 3 pieces I want all my bonuses :)
Image

Re: [0.7.4] Extra products

Posted: Sun Oct 27, 2013 4:53 pm
by kovarex
Hello, thank you for the report.
The reason of this behavior is, that computer floating point numbers aren't precise.
This isn't issue in the long run, and I would personally tend to not mark it as a bug, but as a balancing feature :)

Re: [0.7.4] Extra products

Posted: Sun Oct 27, 2013 4:56 pm
by Nova
In my opinion it is a bug. Maybe not important, but a bug.

Re: [0.7.4] Extra products

Posted: Sun Oct 27, 2013 5:00 pm
by Nirahiel
Instead of having each crafted item fill a percent of the bar, count how much crafts are required for an extra item, and decrement this value at each craft or something ?

Re: [0.7.4] Extra products

Posted: Sun Oct 27, 2013 5:04 pm
by kovarex
The simple yet not elegant solution would be to multiply the bonus production by number like 1.0001 ....

Re: [0.7.4] Extra products

Posted: Sun Oct 27, 2013 6:28 pm
by Coolthulhu
I've got a bit less hacky solution: when the regular production bar hits 100, force the productivity item creation event to happen if the productivity bar is within some epsilon of 100% and reset it.

Example: 125% productivity, ingredients for 4 items - 4th item is produced, productivity bar is at 99.98%, so we treat it as 100%, produce 2 new items (one regular, one from productivity) and set productivity bar to 0%.

It could also work both ways - starting production (the same procedure that consumes ingredients) could clear the productivity bar if it's below 0.01%.

Re: [0.7.4] Extra products

Posted: Wed Oct 30, 2013 10:45 pm
by Math3vv
Coolthulhu wrote: It could also work both ways - starting production (the same procedure that consumes ingredients) could clear the productivity bar if it's below 0.01%.
i think this would create a bug were it clears the bar every time it starts a new craft, not sure tough i don't know the code for it...

this is an good idea tough
I've got a bit less hacky solution: when the regular production bar hits 100, force the productivity item creation event to happen if the productivity bar is within some epsilon of 100% and reset it.
or just multiply by 1.0001 after each craft is done

Re: [0.7.4] Extra products

Posted: Mon Dec 09, 2013 3:33 pm
by kovarex
It is now solved for 0.8.1.

When I compare the bonus production with the needed production, I add 0.0001.

Re: [0.7.4] Extra products

Posted: Mon Dec 09, 2013 4:16 pm
by FrozenOne
Such hacks. Wouldn't it be more reasonable to use some precise number format instead of float? Like Java has BigDecimal.

Re: [0.7.4] Extra products

Posted: Mon Dec 09, 2013 4:37 pm
by kovarex
FrozenOne wrote:Such hacks. Wouldn't it be more reasonable to use some precise number format instead of float? Like Java has BigDecimal.
From what I understood about the implementation, you still can't do 1/3 with unlimited precision, to do things like this, the value would have to be stored as symbolic expression, and it would definitely be slower.