Written by Mike James
Sunday, 11 December 2016

Even if you know it, the fact that computation can be achieved in an amazing range of different ways still comes as a surprise. Programmer lapinozz decided to prove the point by building a full adder using cardboard, marbles and hot glue.

You can see the full project on lapinozz's website, but it is worth a few words of explanation first.

A half adder takes two input bits and produces a sum and a carry. The logic table for a half adder is

`  b1 b2   Sum Carry``0  0    0   0``0  1    1   0``1  0    1   0``1  1    0   1`

You can see that the Sum is just

`b1 XOR b2`

and Carry is

`b1 AND b2`

What this means is that you can add two bits together if you can implement an AND gate and an XOR gate. This is the beauty of working in binary, it reduces arithmetic to logic.

However, a half adder isn't enough because you might have a carry from the previous bit position to add in. You can build a full adder from two half adders and this is the way most people choose to implement a full adder:

`b1 b2 C   Sum Carry``0  0  0   0   0``0  1  0   1   0``1  0  0   1   0``1  1  0   0   1`

`0  0  1   1   0``0  1  1   0   1``1  0  1   0   1``1  1  1   1   1`

The problem is that it would have needed a lot of cardboard cutting to create a machine that adds marbles together. The solution is to notice that in terms of what marbles have to do a full adder can be described more easily:

• If the input is one marble then it has to drop into the first output
• If the input is two marbles then just one of them has to drop into the second output
• If the input is three marbles then exactly two of them have to drop into both outputs.

Put like this all we need is a gate that does different things for one, two and three marbles. This can be created with a modification of a single half adder. While this is simpler it still looks complicated to me, but it sort of works and it is possible to implement the addition of four bits:

You put the marbles in at the top - a marble for a one and no marble for a zero and you put two rows of four marbles to represent the two binary numbers you want to add. You then remove a piece of cardboard and let them fall to the bottom. Some of the marbles are retained in the machine but the ones that get through are the result - a single 5-bit value. Of course, it doesn't always work as the marbles bounce and don't fall at the same rate, but if you repeat you do get the answer some of the time.

For the fine detail and some nice animated GIFs of the marbles going though the gates visit lapinozz's website.

There have been marble-based computers before, but the marbles simply changed the state of levers which represented the state of the system. This particular machine uses gates to work with the marbles representing the numbers and does it in a word-parallel, bit-serial way. That is, it is the fact that one marble follows another that makes the behavior different for one and two marbles. For example, consider the simple AND gate:

The two bits arrive one after the other. If there is only one bit then nothing comes out. You only get an output if the cup is filled by the first marble and the second marble rolls across it.

lapinozz's website

#### Related Articles

The Trick Of The Mind - Turing Complete

Introduction to Boolean Logic

Binary Arithmetic

Sliding Blocks Are Turing Complete

Stanford Engineers Build A Water Droplet Based Computer

A Water Droplet-Based Computer

A Crab-Based Computer

The Machine In The Ghost

The Working Programmer's Guide To Language Paradigms

Knitting Is Turing Complete?

What is a Turing Machine?

The Computing Universe

Non-computable numbers

What Is Computable?

The Post Production Problem

Pulleys As Logic Gates

Slime mould simulates Canadian transport system

 Take The Beginner's Series to Rust14/07/2022Microsoft has released a new self-paced and free curriculum for total beginners in Rust, taught by Microsoft's own employees. But first of all why Rust? why go for Rust as a beginner when there's [ ... ] + Full Story Google's Carbon Is Trying To Be A Better C++21/07/2022Of course, some would say that this isn't difficult as almost anything would be better! Is C++ in need of a replacement? Yes it is - but the problem is that there is a lot of it about. + Full Story More News