BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Rube Goldberg Code

Seen Here

Creating two boolean scalars of

0,1,0,1,0,1,0,1... and 0,0,1,1,0,0,1,1...requires a For loop inside a While loop, a bunch of orange wires and  select 1 duplications (Because maybe the first if True select 1 was ignored?) and dynamic data conversion

 

NOTE: only the first element out of the DDT conversions is actually used!

Capture.png

 

 

Or, we could use

 

a.png

There are a few other problems with the code provided.


"Should be" isn't "Is" -Jay
Message 2361 of 2,565
(3,058 Views)

@altenbach wrote:

 

 

Also, the division&multiplication could be done with one multiplication and a better constant. :D.

 

 

altenbach_0-1649441482044.png

 

 


I have been known to be guilty of this (though I do use a compound arithmetic node when I do) because it can make the code more self-documenting. This would be for cases where, for instance, I have a constant which would be recognizable to me or future programmers along with a scaling factor which might obscure the constant.

0 Kudos
Message 2362 of 2,565
(3,049 Views)

@johntrich1971 wrote:

@altenbach wrote:

 

 

Also, the division&multiplication could be done with one multiplication and a better constant. :D.

 

 

altenbach_0-1649441482044.png

 

5.6


I have been known to be guilty of this (though I do use a compound arithmetic node when I do) because it can make the code more self-documenting. This would be for cases where, for instance, I have a constant which would be recognizable to me or future programmers along with a scaling factor which might obscure the constant.


I commonly will pull as much as possible out of the "data" line and let the Constant Folding handle the actual constant.  As you said, it helps document what is happening.  So in this example, I would have 1000/5.6 and multiply that result by the measured value.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2363 of 2,565
(3,039 Views)

@johntrich1971 wrote:
This would be for cases where, for instance, I have a constant which would be recognizable to me or future programmers along with a scaling factor which might obscure the constant.

Yes, with constant, I meant a "constant", i.e. explicit 1000/5.6 constant folded and even pulled out of the loop.

 

Still, I suspect that the compiler will actually figure out the sequence of multiplicative operations with constants and reduce it to one operation. In this case it is more about readability.

Message 2364 of 2,565
(3,034 Views)

@altenbach wrote:

@johntrich1971 wrote:
This would be for cases where, for instance, I have a constant which would be recognizable to me or future programmers along with a scaling factor which might obscure the constant.

Yes, with constant, I meant a "constant", i.e. explicit 1000/5.6 constant folded and even pulled out of the loop.

 

Still, I suspect that the compiler will actually figure out the sequence of multiplicative operations with constants and reduce it to one operation. In this case it is more about readability.


At witch point, working back, the constant 5.6 should have been labled Ohms and the wire (or terminal) labled mVolts . 

OR, drumroll~~~~~~~~~~~~ show Units and the 1000mAmps/Amp constant disappears. 🙄


"Should be" isn't "Is" -Jay
0 Kudos
Message 2365 of 2,565
(3,017 Views)

So we need to simulate a system with a water tank, two pressure sensors, two faucets, and two booster pumps, all interacting with each other simultaneously. (see here)

 

Apparently we need a mile long sequence structure where each frame contains a loop (100ms per iteration) to deal with exactly one component until some conditions are satisfied. Most values shuffled around with a liberal helping of local variables and value property nodes.

 

(scaled to 50%)

altenbach_0-1649624829233.png

 

Message 2366 of 2,565
(2,998 Views)

Holy code duplication batman! (Yes, the picture only shows the tip of the iceberg. The FOR loop is actually about 3x higher. 😄 )

 

(seen here)

 

I want to see the code once he has to deal with failures numbered from 1..1024!

 

jesusglzFELE_0-1650407644948.png

Message 2367 of 2,565
(2,799 Views)

Somebody revived an ancient thread, so let's look at some of the 20+ year old code :

 

(For example the code posted here)

 

Wile the entire code is quite horrible, here's the section that tests if elements at index 1, 2, 3, 4 are all empty strings.

(below I show a possible alternative)

 

altenbach_0-1650554108427.png

 

0 Kudos
Message 2368 of 2,565
(2,731 Views)

I keep wandering if there is a reason to put those constants outside the loop.

 

I don't think it's faster (anymore)? Is this just habit? Or preference?

 

wiebeCARYA_0-1650615685835.png

 

I personally prefer the constants inside the loop... Not looking for a flame war, just curious.

 

0 Kudos
Message 2369 of 2,565
(2,674 Views)

Makes no difference. I prefer constant outside because there is typically more diagram space there. In this particular case, the subset operation can be closer to the edge, allowing a shorter loop. 😄

 

Many times I add labels (left) to the constants, making them even wider. Once we have all labeled constant near each other, it is easer to make changes than to look for them all over the diagram. Often, the same constant is used in several places, so I just follow the wire. 😄

Message 2370 of 2,565
(2,627 Views)