Long time lurker, first time poster. I've been working on this little project that I'm rather excited about, and I was hoping to get a little feedback for it. It's a machine that uses DF's fluid mechanics to add numbers. It's pretty basic, and I know that people have been doing more advanced computing around here, so I'll try to keep it short.
I don't have a prototype yet, but I can draw you a model. The actual counting process takes place on a staircase, with a single depth pit on every step, a 7/7 activated pressure plate inside the pit, and a door on the next tile activated by the lever.
W=wall, D=door, p=pressure plate. Side view.
W D WWW
WpW D W
WWWpW D
WWWpW
The pressure plates can also be hooked up to an output monitor made of doors, or whatever you choose.
Now the math. This method requires 7/7 units of water per number, plus 2/7 "wasted" units that remain behind on the level above the pit and the space of the door, which means I need 9/7 units per number (that's definitely not the right term, but I don't really know math. Basically I need 9/7x, if x is the input number). However, it's impossible to add 2/7 of water in DF directly, so we need to add a second 7/7 and subtract 1/7 at a time, by running it down a staircase.
For the number 1, then, we take 14/7 units, and run it down 5 stairs, so we get 9/7 falling down the hatch into the calculator. Simple for the lower numbers, but what if you want to calculate, say, 157+389?
For this I needed to come up with a couple of formulas. It uses modular arithmetic, which you can learn in about five minutes if you don't already know it. Go ahead, I'll wait.
Okay, here are the formulas.
x-x(mod7)
f(x)=_________ +1
7
7x+14(f(x))
if: x(mod7) < 4; y=___________ -1 ; # of stairs = 7-2(x(mod7))
7
7x+14(f(x))
if: x(mod7) >= 4; y=___________ ; # of stairs =14-2(x(mod7))
7
Basically, the way it works is this. Take your number (in our example, 157), and run x(mod7) [157(mod7)]. I think you can do this by dividing the number by 7- your remainder is x(mod7).
Now, check this number against the "if" statements, and run the numbers. "y" is the total amount of water you need to add, and "# of stairs" is the amount of stairs you need to run it down before dropping it into the calculator (subtracting 1/7 units of water per stair, to bring us down to 9/7x). It will never be more than 6.
In our example, 157(mod7)=3, so we run it through the x(mod7) < 4 formula. In this case, y = 1421/7, or 203 full squares of water. A little impractical, perhaps, but not terribly so. Especially not if you put the "# of stairs" in the filling chamber... let's see, that's 7-2(3)=1... well, in this case it may not be so practical, but it will work for smaller numbers, or any number if you're willing to build a calculator large enough to handle it.
Also, I think I misunderstood modular arithmetic and went on to 7 instead of having it loop back to 0. Oops. I'm not changing it now, so just keep it in mind when you're running numbers. It should only make a difference for the 7/0s, and the math works if you use my wrong system, so just go with it.
Anyway, pointers, commentary, or snide comments if deserved are all welcome. Most likely no one will read it, but I won't care because I'll be sleeping.