Fluid Tank fluid count rounding

Suggestions that were added to the game.

Moderator: ickputzdirwech

Post Reply
Mpmpmpmp
Inserter
Inserter
Posts: 24
Joined: Fri Sep 30, 2016 3:50 pm
Contact:

Fluid Tank fluid count rounding

Post by Mpmpmpmp »

TL;DR
Have Fuid Tank Output one if fluid 0<x<1

What ?
New Fluid system seems to support multi-fluid, I would loved if it would be possible to add a way to detect non empty tank to clear them

Image
Why ?
it would allow more control on fluid pipe sharing, like belt miximing

Hope it wasn't already posted since the update, I didn't find anything

Mpmpmpmp

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

Re: Fluid Tank fluid count rounding

Post by Koub »

If I remember correctly, one can read a given fluid level in a tank. Is this not enough for your need ?
Koub - Please consider English is not my native language.

Mpmpmpmp
Inserter
Inserter
Posts: 24
Joined: Fri Sep 30, 2016 3:50 pm
Contact:

Re: Fluid Tank fluid count rounding

Post by Mpmpmpmp »

Hello, thanks for the answer.

As shown, there is some liquide in the tanks "petrol 0.0"

however the next fluid can't fill the tank in since the tanks is not empty

BUT the signal say it's rounded as empty

hence we can't split the fluid again :)

alercah
Fast Inserter
Fast Inserter
Posts: 151
Joined: Sun Apr 07, 2019 5:19 am
Contact:

Re: Fluid Tank fluid count rounding

Post by alercah »

To explain a little more detail, this is arguably at the level of a bug now but I'll respect the OP posting here.

With 0.18.32, changes were made to fluid mixing to be less restrictive about creating fluid systems with multiple fluids, with a manual flush operation added as a solution for when they get mixed accidentally. However, critically, any given fluidbox still is limited to one fluid.

A common scenario is to have a station that unloads multiple fluids into separate systems. For example, you might have a train network deliver water and crude oil, and unload them into separate systems to feed into advanced refining.

Prior to 0.18.32, the mere fact that the pumps were connected to the inputs on the oil refineries would cause them to lock the fluid system, preventing pumps from unloading the wrong liquid. This is no longer the case; the pumps will happily unload crude oil into the water system or vice versa, at least when they both start empty from new construction.

This means that, in order to separate the fluids into two separate systems, circuit control must be used so that only the correct pumps engage. If the wagon contains water, engage the water pumps; if it's crude oil, engage the crude oil pumps.

Unfortunately, due to the rounding when the floating-point fluid value is converted to an integer for the circuit network, amounts less than 1 (or at least less than 0.5?) get rounded to 0. This means that the circuit network cannot tell the difference between a wagon with no water in it, and a wagon with almost no water. Operationally it's only a trivial waste, but it has one massive implication: the train will leave the station with the wagon still locked to water.

If the train is later redirected to a crude oil filling station, now, rather than filling with crude, the wagon will sit uselessly since the pumps rightly refuse to pump crude into a tank with water in. This isn't necessarily a common occurrence in simple train systems, but in advanced ones, particularly dynamic train networks like LTN-based ones, train reuse is a critical component of keeping the overall volume down.

There is a further workaround that can be done in the circuit network: use a timer latch to delay the pumps disengaging for a few ticks after the fluid amount hits 0, so that the wagon gets drained properly. But it's a lot of extra circuit work for something that worked completely out of the box in 0.18.31 with no circuits,

I think ideally this would actually have two fixes: one is fixing the rounding mode, but the other would be adding a filter to pumps which force-locks their own fluidbox and prevents them from pumping the wrong liquid. This could open up new designs (pipes that run fluids in alternation, like real pipelines, for instance) and I think very little new code.

On a phone, so no screenshots, sorry. Hopefully someone else can provide, and hopefully the explanation is clear enough. Would someone else also be kind enough to make a request for pump filters and link it here so that I don't need to work that out from my phone? Appreciate it.

Edit: With respect to this request, I strongly believe that converting fluid values to circuit network should always round up, because the *only* comparison you can make without worrying about error bounds on a floating point number is whether it is zero. And for fluidboxes it matters a ton. Changing the values slightly for every other case won't make nearly the same difference as making sure that the circuit network knows the difference between zero and nonzero.

Mpmpmpmp
Inserter
Inserter
Posts: 24
Joined: Fri Sep 30, 2016 3:50 pm
Contact:

Re: Fluid Tank fluid count rounding

Post by Mpmpmpmp »

Thanks for the feedback, feel free to crosspost in bug report if you want:)

User avatar
valneq
Smart Inserter
Smart Inserter
Posts: 1100
Joined: Fri Jul 12, 2019 7:43 am
Contact:

Re: Fluid Tank fluid count rounding

Post by valneq »

+1
I think that with the new less strict fuild mixing prevention, turning fluid amounts to circuit signals should always be rounding up.

User avatar
5thHorseman
Smart Inserter
Smart Inserter
Posts: 1191
Joined: Fri Jun 10, 2016 11:21 pm
Contact:

Re: Fluid Tank fluid count rounding

Post by 5thHorseman »

I'm going to make an assumption here, but it's no less an assumption than the one everybody else is making:

The Factorio team seems to not actually want you to set up trains, pipes, and storage tanks for multiple fluids. The change to the restriction wasn't to allow this to be possible, but just to stop weird fringe errors from happening.

Therefore, this could be seen by the programmers as not a bug or even as a misfeature, but actually working as designed.

I'm not giving an opinion here. I'd like to play around with it as well. However I see the point. It's not like the Alaska Pipeline moonlights as a water main.
Image Image

Mpmpmpmp
Inserter
Inserter
Posts: 24
Joined: Fri Sep 30, 2016 3:50 pm
Contact:

Re: Fluid Tank fluid count rounding

Post by Mpmpmpmp »

No worries, my argument would be that if it's not intended, it should not happen, and then it would be a bug.

I'll accept the dev decision, but rn, it's a question that need to be asked :)

Lacking feature error Vs bug*

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12160
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Fluid Tank fluid count rounding

Post by ssilk »

Mpmpmpmp wrote:
Wed Jun 17, 2020 12:55 am

Lacking feature error Vs bug*
For me that rounding is a bug. 0.1 is not 0.
viewtopic.php?f=6&t=49274

Despite from that, as it is now I would recommend to enable full automation of liquid change.

1. Add new research “clean pipes/tanks”
2. Adds a new device, similar to a pump, that can be connected to a pipe network or a tank wagon and flushes out all remains of a liquid. If connected to a pipe, pumps work here like a one-way-street.
The remains are added to the pollution.
Player is self-responsible to close pumps, while flushing. :)
Alternatively: instead of a device we can clean with some cleaning liquid (self destruction if in touch with a different liquid)


Edit: just read viewtopic.php?p=499002#p499002
So forget about this flushing idea. :)
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

User avatar
5thHorseman
Smart Inserter
Smart Inserter
Posts: 1191
Joined: Fri Jun 10, 2016 11:21 pm
Contact:

Re: Fluid Tank fluid count rounding

Post by 5thHorseman »

5thHorseman wrote:
Tue Jun 16, 2020 11:50 pm
I'm going to make an assumption here, but it's no less an assumption than the one everybody else is making:

The Factorio team seems to not actually want you to set up trains, pipes, and storage tanks for multiple fluids. The change to the restriction wasn't to allow this to be possible, but just to stop weird fringe errors from happening.

Therefore, this could be seen by the programmers as not a bug or even as a misfeature, but actually working as designed.
Ahem.
posila wrote:
Wed Jun 17, 2020 5:17 am
Mixing fluids withing the same pipe system is still not supported and probably won't do what you want it to do once new pipe simulation comes. Point of doing the change to fluid mixing prevention was to make it so the game doesn't crash when pipe systems with different fluids somehow happen to connect, and to simplify the underlying code to something managable so that further changes to fluid system are possible to do.
Image Image

Blokus
Fast Inserter
Fast Inserter
Posts: 244
Joined: Tue Mar 05, 2019 2:49 pm
Contact:

Re: Fluid Tank fluid count rounding

Post by Blokus »

I second this suggestion. This doesn't really have anything inherently to do with the fluid system change, but it is more important with the fluid system change, primarily because of the train scenario mentioned by alercah. Specifically, if a train is at a station where multiple types of fluids can be unloaded, the pumps cannot really be safely circuit-controlled to ensure the fluids go where they need to go. Some occasions where an amount of fluid strictly between 0 and 1 remains will occur, which the circuit network will view as being empty.

The obvious way to avoid a problem is to have your wagons only ever carry one type of fluid as a result of how their schedule works. In vanilla this is actually the typical situation, but it is not really a given even in vanilla; for example a train might unload water to use to make sulfuric acid and then pick up the preexisting batch of sulfuric acid to bring somewhere else.

The other way to try to avoid a problem is to lie to your pumps, for example by telling them the contents of the train 1 tick ago, which can be achieved by passing the train contents signal through a "each * 1 output each" arithmetic combinator. This is not especially reliable, however.

IronCartographer
Filter Inserter
Filter Inserter
Posts: 431
Joined: Tue Jun 28, 2016 2:07 pm
Contact:

Re: Fluid Tank fluid count rounding

Post by IronCartographer »

Also here to support the change to fluid rounding, at least within 0 < X < 1.

If fluids were ever changed in the future to have full precision at the circuit level (unlikely, but who knows), this behavior would no longer be needed as any amount of fluid would create a non-zero signal...but if that never happens, it will likewise never be possible to tell if a tank is completely empty without this rounding adjustment.

User avatar
5thHorseman
Smart Inserter
Smart Inserter
Posts: 1191
Joined: Fri Jun 10, 2016 11:21 pm
Contact:

Re: Fluid Tank fluid count rounding

Post by 5thHorseman »

I'll repost this here.
5thHorseman wrote:
Sun Jun 21, 2020 12:00 am
I had an idea on how to do this in the stock game but I set up a simple multi fluid train station and it works just by default, without me having to fix anything.

Could someone post a blueprint of the simplest setup that doesn't work? I use Creative Mod to create and destroy fluids.
Image Image

User avatar
valneq
Smart Inserter
Smart Inserter
Posts: 1100
Joined: Fri Jul 12, 2019 7:43 am
Contact:

Re: Fluid Tank fluid count rounding

Post by valneq »

According to the changelog of 1.1.0, the fluid logic for sum<1 was changed for "train circuit logic". Does that change implement this suggestion, too?

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

Re: Fluid Tank fluid count rounding

Post by Koub »

[Koub] It is my understanding indeed. Moved to implemented.
Koub - Please consider English is not my native language.

Post Reply

Return to “Implemented Suggestions”