Send units from "container" A to B? (math question)

I want to send units from container A to B
The capacity of both containers is 6
So if A sends 1, I want B to receive 1
Unless A has less than 1 remaining, in which case I want to send whatever is left in A
Unless B has less than 1 left of remaining capacity (which is 6)

Basically, like moving water from one bucket to the other.

I’ve trying this for a couple days, but I keep hitting roadblocks
This is my closest attempt in blueprint:
Bucket A:

Bucket B:

The current issue is that Bucket A keeps sending 1 instead of empyting, because the way I substract it, so I’m not sure the way I’m going about this is the correct one. I’ve tried a few other approaches but keep encountering other roadblocks.

Please do post. The only question I have is the context in which the two actors interact.

posted, not sure how helpful it may be as I’m probably going about it in the wrong way and I’m ready to change my approach

Here is a working prototype:
bucket01

Main graph

PourWater function

Remainder pure function

ModifyCurrentWater function


Hope it helps.

1 Like

I feel like you’re overthinking this. In pseudocode this this just:

UnitsFreeInB = ContainerSize - UnitsInB
UnitsToSend = min(min(1, UnitsInA), UnitsFreeInB)
UnitstInA = max(0, UnitsInA - UnitsToSend)
2 Likes

Perhaps I did! TY.

1 Like