November 2020

Minecraft

Background

My friends introduced me to Minecraft in 6th grade. We played factions together on and off throughout middle school. But my enjoyment of Minecraft didn't come from playing PvP or survival with my friends—rather, it came from redstone.

For the unaware, redstone is a game mechanic like electricity: to oversimplify, redstone lines can be either on or off, they can be "powered" (and turned on) by levers, buttons, or redstone torches, and they can power (and turn on) lamps. It's a tad bit more complicated than that but not much more. (There are other devices that I haven't mentioned, but those are unnecessary for the purposes of this post.)

Most importantly, redstone can be used to make logic gates. Redstone signals can invert torches (i.e. if a redstone torch is placed on a block which is powered by a redstone line running into it, the torch turns off), and they can be combined by running two lines into each other. Thus, an OR gate is two lines combined, and AND gate is two inverted lines running into an OR gate with the output also inverted. XOR gates combine the outputs of an OR gate and a NAND gate into an AND gate (this sounds more complicated than it is—if you're confused, consider firing up Minecraft and playing around).

Uses

This is when it gets interesting. Consider the addition of binary 8 and 7:
1000 #8
0111 #7
1111 #15

That looks like an OR to me! Of course, there were no carries. What would that look like?
0011 #3
0001 #1
0100 #4

Then this is an XOR, and if AND there's a carry. Using just the basics of Minecraft redstone, it's quite easy to implement that yourself. Adder/Subtracters aren't that much more difficult.

How far can this go?

The realization that I could make these logic circuits in Minecraft sent me down a several month rabbit hole, where I started with 4 bits, then 8, then 16 and 32. But of course adder/subtracters aren't the end. No, once I could build an adder/subtracter I moved on... eventually, to a rudimentary CPU.

Building a CPU in Minecraft wasn't particularly new—indeed, others had done it since even before there was a creative mode in Minecraft. But doing it myself taught me a lot about the inner workings of a computer.

I recently rediscovered the old save file, backed up on an external hard drive. I had wiped my middle school computer to give to my sister, so I thought that I had lost it. Here's a bird's-eye view of the whole system.

Photo of computer. It's 90% bus.

It's a 16 bit computer with 2 registers based on the "Hack Computer" specification. Working from that course allows me to add extensions one by one, while still keeping a cohesive unit. The whole computer should have 32k 16 bit words of memory, which interfaces to the screen and keyboard; however 32k is far out of reach of the limits of Minecraft. The clock runs at a speed of 0.28 Hertz, or 72 in-game "ticks." This is mostly due to delays incurred in the busses, as the redstone signal must be periodically refreshed by a device that takes one tick to pass on the signal.

So what?

Playing around in Minecraft allowed me to experiment without fears of breaking things, and it allowed me to build things that I wouldn't have been able to create otherwise. I learned a lot about low-level computing and, I imagine, was able to achieve a similar sense of accomplishment as those who built kit computers and trainers at the dawn of the computing age.