Professional Documents
Culture Documents
about it’s computation engine, and whether you could do some traditional programming
I co-founded Grey Thumb, an artifi-
tasks on it, like computing Pi. After all, it’s Turing complete. So I started thinking about
cial life interest group
how I would do it. You have registers, which hold (I later found out) 3 decimal digits, and a
sign. But, the only operations you have are add a constant, subtract a constant, multiply by How to communicate with an alien
race
a constant, divide by a constant, assign from a constant, and compare to a constant. The
constants must be in the range 1 to 100 (inclusive), and there are no operations that I (might have) met Roger Waters
involve two registers.
I was a programmer on Star Trek:
Armada
Now, there’s a really simple formula for Pi:
Calculating Pi in a video game
A couple things crossed my mind. First, I only had 5 registers, so I could only I sang in the band “Booty Resonant
Frequency.”
compute a few digits of Pi. But wait! I have 3 mechs! And they can communicate! There
are 5 different channels (1-5), each of which can send or recieve 5 messages (named after 5 email: martin at martincmartin dot
colours). It wouldn’t be hard to use a single channel and transmit a number in base 5. So, com
bar: C = C + 1
Advertisements
D = D + 1
B = B - 1
if B > 0 then goto bar
Now that you can add (or subtract) two numbers, you can compare them by subtracting
the two and seeing if the result is positive, negative or zero. Or, equivalently, you can
subtract 1 from each, and whichever gets to zero first is the smallest.
If you expand everything out, you can combine many steps. For example, the copy and
subtract can be combined like this:
[A = A - B; C = B; B = 0]
C = 0
phat: A = A - 1
PRIVACY REPORT THIS AD
B = B - 1
C = C + 1
if B > 0 then goto phat
There are some other speedups you can do too. Instead of subtracting 1 all the time, you
can do:
[A = A - B; B = 0]
phat1: if B < 100 then goto phat2
A = A - 100
B = B - 100
goto phat1
phat2: if B < 10 then goto phat3
A = A - 10
B = B - 10
goto phat2
phat3: if B < 1 then end
A = A - 1
B = B - 1
goto phat3
Advertisements
The ultimate in this vain would be a binary thing: compare to 512, 256, 128, 64, …, 1. You
don’t even need the loop, since you only need to subtract each number at most once.
(Actually, it’s hard to compare to numbers bigger than 100, since it can’t be done directly.
Probably best to have a loop to get it under 100, then do the binary thing.)
Also, for division, you could do "if A > 10*B then A = A - 10*B, C = C + 10".
Multiplying by 10 is built in, and you need to make a copy of B anyways.
Well, I wrote the program out on paper. It’s only for a single mech, and while I combined
as many steps as I could, it doesn’t have any of the other optimizations. It should compute
the first 2 or 3 decimal places of Pi (that is, 3.141 or pretty close). Who would have thought
those theory of computation constructions could actually be used?? I haven’t implemented
it yet, I’m waiting until I get the “best” CPU (fastest and largest program storage). Then I’ll
try it. I’ll be curious to see how far it gets in the 150 second time limit. (Too bad I can’t let
it run all night!) That series converges really slowly, especially if your variables only ever
go up or down by 1 at each timestep!
Martin.
P.S. I eventually did implement it, and it didn’t even get a single digit, because the time for
the match ran out.
P.P.S. The next step would be a multi precision, parallel communicating version. The
above formula converges so slow, so it would have to be based on the Taylor series for
arctan…
Sponsored Content
Share this:
Twitter Facebook
Loading...
Leave a Reply
Martin C. Martin
Create a free website or blog at WordPress.com.