A Digi-Comp ii Emulator and Simulation using Python

Digi-Comp ii was an amazing mechanical toy computer made in the 1960s. It worked by rolling marbles down a plastic surface filled with toggle switches. A company called Evil Mad Scientist recently released a beautiful wooden re-creation (below).


I decided to write a computer program to emulate (or simulate depending on your point of view) the Digi-Comp ii. My Python programming was a bit rusty because I’ve mostly been using C#, so I thought I’d use Python just for fun.


My demo program multiples 3 and 13. The calling code, with some minor edits to save space, is:

print "\nBegin Digi-Comp ii simulation \n"
dc = DigiComp()
dc.Initialize(35) # 35 balls in top reservoir
print "\nInitial state: "

# set up 3 * 13 problem
dc.q1 = 1; dc.q2 = 1; dc.q3 = 0
dc.m1 = 1; dc.m2 = 0; dc.m3 = 1; dc.m4 = 1
dc.multiply = 1
print "\nSettings to compute 3 * 13:"
# result in A should be 1110010

print "\nResult state (answer in A register):"

print "\nEnd Digi-Comp ii simulation \n"

The simulator is mostly a (not-shown) program-defined class named DigiComp. The program has about 250 lines of Python code. For example, here are two of the class methods:

def DoStart(self):
  if self.top == 0:
    print "No balls in top reservoir"
    self.top = self.top - 1 # launch ball

def DoMultiply(self):
  if self.multiply == 0: self.DoClear() # go right
  elif self.multiply == 1: self.DoD2() # go left

The calling code sets Q (called MQ in the Digi-Comp manual) to 110 = 3d. Then it sets M to 1011 = 13d. The DoStart method launches the first virtual ball. The result is in the A register and is 1110010 = 1 + 2 + 4 + 32 = 39d. All in all, it was a fun little exercise.

This entry was posted in Machine Learning, Miscellaneous. Bookmark the permalink.