please do not use floating point value in Factorio

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
rakou1986
Burner Inserter
Burner Inserter
Posts: 7
Joined: Fri Oct 04, 2019 1:05 pm
Contact:

please do not use floating point value in Factorio

Post by rakou1986 »

hello developper team.
thanks for publishing beautiful great interesting game to the world, and daily fix.
you gave funny days for me :)

am... i'm in trouble on Factorio 1.1.19. it causes Factorio using floating point value to fluid items, i guess.

attachment file(blueprint.txt) is my 'advanced-oil-processing' oil-refineries.
it works by trains like below:

input train is arriving FULL
input train departing condition is EMPTY

output train arriving EMPTY
output train departing condition is FULL

when
odd oil-refineries crafts 63048 times,
even oil-refineries crafts 63028 times,
then
(1)all fluid-wagon to output a heavy-oil has look like 25k units of a heavy-oil, but train departing condition 'FULL' does not match so this train do not departing. I guess from (2), odd fluid-wagon has actually 24999.9 units.
(2)odd oil-refineries has 99.9 crude-oil
(3)fluid network(pipes, pumps) for input to (2) oil-refineries are empty.

i expect FULL means each fluid-wagon has 25000 fluid units.
and 'advanced-oil-processing' use a crude-oil just 100 units each time.
so it's strange that oil-refineries has 99.9 crude-oil.
oh where are you from 99.9 crude-oils? where are you gone 0.1 crude-oils?
i feel it is not intuitively.

in genellary, i think floating point value makes trouble in any software sometimes, so in the future, how about do not use floating point value in Factorio?
if you want to give a detail or accuracy by floating value, then use a some scaling value which scaled by '10^N, 10 to the power of N' instead floating point value for all fluid recipes, fluid-wagons, storage-tanks, and barrels.

i think fluid unit value scaling flushes away like an avobe trouble and we can play as usual and happy:)
thank you.
Attachments
blueprint.txt
(39.24 KiB) Downloaded 123 times

Rseding91
Factorio Staff
Factorio Staff
Posts: 13202
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: please do not use floating point value in Factorio

Post by Rseding91 »

Thanks for the report however that's already how fluid wagons work. If you use "full" they will have 100% capacity. Additionally we aren't going to be changing how fluids or any other logic works to remove floating point values.
If you want to get ahold of me I'm almost always on Discord.

rakou1986
Burner Inserter
Burner Inserter
Posts: 7
Joined: Fri Oct 04, 2019 1:05 pm
Contact:

Re: please do not use floating point value in Factorio

Post by rakou1986 »

thanks for quick reply.
now i have only one question about (2).

why oil-refinery has a fluid which amount are 99.9 units, when i send a fluids from "full" wagon to oil-refinery until wagon is empty.
at this time, fluid network that between wagon and oil-refinery are also empty.

i heard on local community, a little fluid which less than 0.1 units are stretched inside fluid network, then such a little fluid are disappear, like a water in "Terraria".

is it correct?

Zanthra
Fast Inserter
Fast Inserter
Posts: 207
Joined: Fri Mar 25, 2016 8:18 am
Contact:

Re: please do not use floating point value in Factorio

Post by Zanthra »

That’s more or less correct. Small amounts of liquid can basically evaporate and be lost. Often it’s more a case that pipes are separated and deleted with small amounts left in them, but I think it can happen on it’s own on rare occasions.

You might try a departure condition for your trains of item quantity heavy oil > 24k AND Idle 5 seconds OR Cargo Full.

rakou1986
Burner Inserter
Burner Inserter
Posts: 7
Joined: Fri Oct 04, 2019 1:05 pm
Contact:

Re: please do not use floating point value in Factorio

Post by rakou1986 »

thanks for quick reaction.

oh it's right.
it's not your guide but i try how to lost a fluid at Map Editor.
simple case below: (fluid-lost-try.txt)

(a) full tank -> pump -> oil-refinery
no fluid lost.

(b) full tank -> pump -> pipes -> oil-refinery
0.1 fluid lost.

(c) full tank -> pump -> pipes -> pump -> oil-refinery
0.1 fluid lost.

(d) full tank -> 8 pumps -> oil-refinery
no fluid lost.

now i understand a situation when a little fluid lost.
that is, pipes can lost a little fluid.

by the way, this lost is expected or bug?
Attachments
fluid-lost-try.txt
(2.26 KiB) Downloaded 104 times

rakou1986
Burner Inserter
Burner Inserter
Posts: 7
Joined: Fri Oct 04, 2019 1:05 pm
Contact:

Re: please do not use floating point value in Factorio

Post by rakou1986 »

supplement:
fluids not remains in pipes at final state in avobe cases (a) to (d).

Zanthra
Fast Inserter
Fast Inserter
Posts: 207
Joined: Fri Mar 25, 2016 8:18 am
Contact:

Re: please do not use floating point value in Factorio

Post by Zanthra »

rakou1986 wrote:
Tue Feb 16, 2021 11:34 am
0.1 fluid lost.
...
You don't actually lose 0.1, it's much much less than that, but the display rounds to the floor of the tenth's place. It would take a very long time for the error to accumulate to where you lose more than one production cycle. It's a bug in that it is never intended for fluids to be lost, but it's known and won't be fixed.

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2241
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: please do not use floating point value in Factorio

Post by boskid »

Fluid may be lost or created in a really tiny amounts because of floating point math. Worst enemy is when a fluid system becomes empty: if all fluidboxes in a fluidsystem have less than 0.05 of fluid, then the whole fluid system is automatically flushed.

-- edit (27 march 2021): 97338

Zanthra
Fast Inserter
Fast Inserter
Posts: 207
Joined: Fri Mar 25, 2016 8:18 am
Contact:

Re: please do not use floating point value in Factorio

Post by Zanthra »

boskid wrote:
Tue Feb 16, 2021 8:17 pm
Fluid may be lost or created in a really tiny amounts because of floating point math. Worst enemy is when a fluid system becomes empty: if all fluidboxes in a fluidsystem have less than 0.05 of fluid, then the whole fluid system is automatically flushed.
Is that an explicit deletion of fluid in pipes like that? As in not just an issue of floating point math?

If that is case am I wrong about how the fluid values are rounded? Or are fluids on the building recipe display rounded by the floor and other fluid piping and tanks rounded to nearest?

Rseding91
Factorio Staff
Factorio Staff
Posts: 13202
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: please do not use floating point value in Factorio

Post by Rseding91 »

Zanthra wrote:
Tue Feb 16, 2021 9:30 pm
boskid wrote:
Tue Feb 16, 2021 8:17 pm
Fluid may be lost or created in a really tiny amounts because of floating point math. Worst enemy is when a fluid system becomes empty: if all fluidboxes in a fluidsystem have less than 0.05 of fluid, then the whole fluid system is automatically flushed.
Is that an explicit deletion of fluid in pipes like that? As in not just an issue of floating point math?

If that is case am I wrong about how the fluid values are rounded? Or are fluids on the building recipe display rounded by the floor and other fluid piping and tanks rounded to nearest?
We don't round fluids anywhere for recipes or flow logic. The only 2 sources of fluids getting removed is floating point inaccuracy (incredibly tiny amounts) or when the systems fluids are explicitly flushed as boskid mentions.
If you want to get ahold of me I'm almost always on Discord.

Zanthra
Fast Inserter
Fast Inserter
Posts: 207
Joined: Fri Mar 25, 2016 8:18 am
Contact:

Re: please do not use floating point value in Factorio

Post by Zanthra »

Ah yeah, I meant for display. Rounding or truncating has to happen there at some point. I was just thinking at the moment why 0.05, and thought maybe to avoid numbers in pipes being rounded to 0.0 for display while actually having fluid in them to avoid confusion, but that would still happen if the fluid was above 0.05 and the display value was truncated, or the fluid was kept alive by another connected fluid box with more than 0.05.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13202
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: please do not use floating point value in Factorio

Post by Rseding91 »

As far as I know the reason why pipes flush when below 0.05 fluid is to prevent an incredibly tiny amount just sitting there clogging up the pipe(s).

Since all fluids in the game are infinite it's a non-issue; more will come in and the cycle continues.
If you want to get ahold of me I'm almost always on Discord.

Zanthra
Fast Inserter
Fast Inserter
Posts: 207
Joined: Fri Mar 25, 2016 8:18 am
Contact:

Re: please do not use floating point value in Factorio

Post by Zanthra »

With fluid mixing being prevented when possible, and the ability to manually flush all connected fluid boxes, is that still a beneficial feature? Small amounts in the pipes can't clog up the movement of the same fluid type. I don't feel it's harmful, but if it no longer serves it's purpose due to other changes should it still be there?

Of course if you were to remove it you would of course hear from at least one person who's entire factory bypasses all the protection against fluid mixing and relies on it flush pipes to change fluids and who's factory has grinded to a halt due to the change. :)

Koub
Global Moderator
Global Moderator
Posts: 7199
Joined: Fri May 30, 2014 8:54 am
Contact:

Re: please do not use floating point value in Factorio

Post by Koub »

Zanthra wrote:
Wed Feb 17, 2021 1:13 am
With fluid mixing being prevented when possible, and the ability to manually flush all connected fluid boxes, is that still a beneficial feature?
It still is. automated flushing vs manual flushing is an obvious choice in a game about automation. The incomplete emptying of pipes when almost empty has been often requested for years before the current solution was implemented. Maanual flushing means that people can't rely on the system to work in its own (but are useful when a design mistake was made). When in operation mode, people won't want to manually flush every time a fluid changes in a pipe where several fluids are supposed to flow depending on the conditions.
Koub - Please consider English is not my native language.

Zanthra
Fast Inserter
Fast Inserter
Posts: 207
Joined: Fri Mar 25, 2016 8:18 am
Contact:

Re: please do not use floating point value in Factorio

Post by Zanthra »

Koub wrote:
Wed Feb 17, 2021 7:27 am
Zanthra wrote:
Wed Feb 17, 2021 1:13 am
With fluid mixing being prevented when possible, and the ability to manually flush all connected fluid boxes, is that still a beneficial feature?
It still is. automated flushing vs manual flushing is an obvious choice in a game about automation. The incomplete emptying of pipes when almost empty has been often requested for years before the current solution was implemented. Maanual flushing means that people can't rely on the system to work in its own (but are useful when a design mistake was made). When in operation mode, people won't want to manually flush every time a fluid changes in a pipe where several fluids are supposed to flow depending on the conditions.
Given that mixing fluids has largely been considered a mistake, it stands to reason that the reason it was an often requested feature had to do more with accidentally getting a fluid into a pipe meant for something else, and being able to attach a pump to get it all out without picking up all the pipes and rebuilding them. That use case is superseded by manual flushing.

Koub
Global Moderator
Global Moderator
Posts: 7199
Joined: Fri May 30, 2014 8:54 am
Contact:

Re: please do not use floating point value in Factorio

Post by Koub »

Actually, the use cases I remember seeing it requested for were :
- Fluid wagons that couldn't be emptied of the last fraction of fluid unit, which prevented the trains to leave with "on empty" condition (not even trying to enter into the train reusable for different fluids).
- Generic fluid loading/unloading stations, with pumps sending the fluid to a place or another depending on the fluid
Koub - Please consider English is not my native language.

Zanthra
Fast Inserter
Fast Inserter
Posts: 207
Joined: Fri Mar 25, 2016 8:18 am
Contact:

Re: please do not use floating point value in Factorio

Post by Zanthra »

Koub wrote:
Wed Feb 17, 2021 4:35 pm
Actually, the use cases I remember seeing it requested for were :
- Fluid wagons that couldn't be emptied of the last fraction of fluid unit, which prevented the trains to leave with "on empty" condition (not even trying to enter into the train reusable for different fluids).
- Generic fluid loading/unloading stations, with pumps sending the fluid to a place or another depending on the fluid
Do fluid wagons currently have actual fluid boxes? The prototype does not, it only has a capacity property of 25000. They don't interact with other fluid boxes the way that other entities do, only though pumps. The debug option for fluid box info also shows no information on fluid wagons.

As for the second one, it's not really possible to build such stations anymore. I get this when I try using pumps to control the flow of the fluid.
differentfluids.jpg
differentfluids.jpg (103.33 KiB) Viewed 5592 times

rakou1986
Burner Inserter
Burner Inserter
Posts: 7
Joined: Fri Oct 04, 2019 1:05 pm
Contact:

Re: please do not use floating point value in Factorio

Post by rakou1986 »

thanks for many discussion.
(i learning English so i maybe writing based on misreading...)

now i want to change subject to "now we need an auto-flusing in fluid network?"
that's what i really wanted to see.

Zanthra seems to be thinking what i want to know :)

i understand tiny fluids that less than 0.05 are flusing automatically, it is expected on Factorio.
there is a historical reason why auto-flusing needed.
auto-flusing was helpful for mistake, and it is useful for change the usage of existing pipes.
Rseding91 wrote:
Wed Feb 17, 2021 12:19 am
As far as I know the reason why pipes flush when below 0.05 fluid is to prevent an incredibly tiny amount just sitting there clogging up the pipe(s).

Since all fluids in the game are infinite it's a non-issue; more will come in and the cycle continues.
surely, pumpjack or offshore-pump is infinite source of fluid, it's a non-issue.
but wagon or tank is not infinite source in some cases, some time-scale, it's maybe a issue.
actually, i had trouble like a first post.
---

now, we got a manual-flusing, and mistake is protected in advance.
don't you think a manual-flusing and this protection can replace an auto-flusing?

when we really need an auto-flusing?
i think for example, we can't make a time shareing fluid network without an auto-flushing.
it shared different fluids by circuit or something in different time.
(i have'nt seen so much, such a shareing network, because it's popular, that is mistake...)

surely, auto-flusing is expected. i understand.
from the Factorio's point of view, it is explicit.
but from the player's point of view, it is implicit.

some people maybe still needs an auto-flusing, but can't it be chooseable toggle in options?

rakou1986
Burner Inserter
Burner Inserter
Posts: 7
Joined: Fri Oct 04, 2019 1:05 pm
Contact:

Re: please do not use floating point value in Factorio

Post by rakou1986 »

Koub wrote:
Wed Feb 17, 2021 4:35 pm
Actually, the use cases I remember seeing it requested for were :
- Fluid wagons that couldn't be emptied of the last fraction of fluid unit, which prevented the trains to leave with "on empty" condition (not even trying to enter into the train reusable for different fluids).
- Generic fluid loading/unloading stations, with pumps sending the fluid to a place or another depending on the fluid
oh fluid wagons can't departure with "empty" condition due to tiny fluids.

it's difficult to stand each side.
if i had to choose one, other condition for departure without auto-flusing is better than lost a tiny fluid.
because there are fixed fluids 25000 per wagons in cycle of train at always.
with an auto-flusing, fluids decrease with cycle.

very complex...
my trouble is simple, it's due to different pipe length makes different decrease, so how to solve is align of pipe length,
or "idle time" condition with circuit that related other train stop's state.....

going the first time,
why fluid wagons can't be empty by pumps?
it's a limit of fluid network specifications?
if make can be, specifications be collapse?
so we need auto-flusing?

if fluid wagons can be empty by pumps, we don't worry.....

MiniHerc
Fast Inserter
Fast Inserter
Posts: 171
Joined: Fri Jun 26, 2015 11:37 pm

Re: please do not use floating point value in Factorio

Post by MiniHerc »

Rseding91 wrote:
Wed Feb 17, 2021 12:19 am
As far as I know the reason why pipes flush when below 0.05 fluid is to prevent an incredibly tiny amount just sitting there clogging up the pipe(s).

Since all fluids in the game are infinite it's a non-issue; more will come in and the cycle continues.
Would it be possible to override that for modded games? Specifically, Pyanodons, and the seablock mod for it? Early game, I'm slowly producing liquid glass from quartz at a rate of 10 fluid units per 10 seconds or so, and with the underground pipe length I was using, I was experiencing 75% fluid loss thanks to that 'feature'.

Even with short range transport from a producer to a consumer, I was losing liquid glass over time at a rate of 0.1 units every minute or so. I could tell since the amount in the destination went from a whole number to .9, .8, etc.

Also, since pipes can only have one fluid type now without exploits, there is zero reason for any automatic flush to ever occur. If a manual flush is desired, it's easy enough to connect a pump to one end of the pipe system.

Post Reply

Return to “Gameplay Help”