Building Computers in Minecraft 1: introducing logic in Redstone


Foreword

Minecraft is 15 years old! I can think of no other phenomenon that belongs to the children of the 2010s at such an emotional level. We grew up playing it, though some of us were too poor or too strictly raised to be able to buy the original version. I myself played it for many years in trial mode: playing in one world, in survival, for only 90 minutes until Mojang demanded that I pay, at which point I would be forced to delete everything I had made. I was elated once when a bug in Minecraft: Windows 10 Edition allowed me to use cheats in a world and extend my play time, and also enter creative mode. To me, this game has two disciplines: the crude and bitter realities of survival mode, and the godlike powers of creative mode.

This month, I bought Minecraft with the winnings from a quiz (another pastime of mine). Both family and friends have come forward to condemn this as a poor financial decision. But I do not regret what I have done, even a little. Minecraft is worth much more than its face value, around $50, to me. It is an indelible part of my childhood, as it is for millions of young men (and some women) around the world. Can we ever forget the antics of DanTDM, ExplodingTNT and the late Technoblade?

Minecraft's children are growing old. DanTDM is in his thirties and has a child. ExplodingTNT came out of the closet, revealing himself to be Armenian. I am myself 20 and just stepping outside the cradle of a carefree adolescence. While a fifteenth anniversary may be nothing in the grand scheme of anniversaries (it doesn't even have a special name), Minecraft's fifteenth is a remarkable event for our generation. In tribute, I have decided to write a series of posts tackling one of the least lucidly discussed attributes of Minecraft, which is Redstone engineering.

Redstone, for the non-miners, is Minecraft's equivalent of electricity. Different in many ways and similar in many to current, Redstone has been used by our elders before us to do amazing things, such as creating an x86 computer in the game. Microsoft even codenamed the Windows 10 OS 'Redstone' in honour of this wonderful mineral, that one can find deep in the tunnels that run under Minecraft worlds. In this series of posts, I will be discussing at a layman's level, how a rudimentary computer can be built with Redstone. I hope that I can interest at least a few people in the nuances of logic system and computer architecture design at a high level.

In order to accommodate the community of newbies, I have deviated from technical language and strictness in many places.

Let's get straight to it.

Features of Redstone

Redstone, by itself, refers to an underground mineral. Mineable by an iron or higher pickaxe, Redstone drops itself as a dust that can be placed by the player on top of any solid block. This dust immediately joins any similarly placed dust on the four blocks that share a side with its block to form a 'wire'.

If you place Redstone dust in the slot above a stick in crafting, you get a Redstone torch. This is one of many devices in the game that generate Redstone signal. Signal (non-standard word) is what simulates electricity in Minecraft, and it is transmitted by Redstone wires. Just as some things produce signal (think power source), some things can be activated by signal (think an appliance). An example of a Redstone-activated block is the simple light block, or 'Redstone lamp'. It turns on and glows when there is a signal on top of or laterally to it and is otherwise dark.

Redstone only joins vertically and horizontally. Diagonal wires are not possible. On the left, a Redstone torch's signal is transmitted by laid Redstone.

Redstone signal, when produced by most sources including torches, has a strength of 15. The strength of a signal decreases by 1 with each block that it is transmitted in any direction by a wire. Naturally, after 15 blocks, the signal disappears completely (= 0) and has to be reinvigorated by a special device called a redstone repeater.

If you ask me, this aspect of Redstone will infuriate you and me in the articles to come. Infinite strength Redstone would have made our job so much easier. I have not been able to think of a single application for this dissipation property in the context of logic design. For most of the applications in these articles, signal strength has no consequence: its value can be happily ignored as long as we avoid signal death using repeaters. 

The two light blocks are the same distance from the torch: 17 redstone wire. The signal dies out in the top wire, but is repeated in the lower wire and can power the light.

A Redstone torch can be placed not only on the ground, but also on the sides of blocks. This is of immense application as in this position, the redstone torch can be switched on and off by a signal. Look at the figure below. A Redstone signal approaching a block from the sides will turn off any torches on the other sides of the block (but not any on top).

A signal comes in, and turns off both torches.

No signal in. Both torches work as usual, transmitting through the wire on the ground.


Logic gates

Computers think and work in binary: 1s and 0s, on and off, redstone signal and no redstone signal. They do all of their computation with three basic operations, basically.

1. NOT - the 'NOT' of a signal is simply its opposite. NOT 0 = 1. NOT 1 = 0.

2. AND - this is, as the name suggests, an 'AND' gate that is 1 if both of the inputs are 1. A AND B = 1 if both A and B are 1. 1 AND 1 = 1, all other = 0.

3. OR - this is 1 if at least one input is 1. A OR B = 1 if A or B is 1. 0 OR 0 = 0, all else = 1.

These three things, implemented in hardware as 'gates', underly all computers. Every operation you can think of is achieved through some combination of these, some highly complex.

Does that first gate, NOT, sound familiar? Recall that a signal turns a torch on a block off, whereas no signal means a lit torch. This is a NOT gate! It gives out a signal if there is no input signal (0' = 1) and gives off no signal if an input signal is present (1' = 0).

The OR gate in Redstone is perhaps even simpler. If we join two Redstone wires, and both of them have an independent signal running in them, the joining will give an OR of the two: it will be high if at least one of the input wires is high.

From left to right: 0 OR 0, 0 OR 1, 1 OR 0, 1 OR 1. If either input is 1, the output is also 1.

The AND gate requires some thought. If you do not know much of Boolean algebra, skip the next few lines. We use de Morgan's law

(AB)' = A' + B' 

to construct a NAND gate. We then NOT the output of this with the earlier block-torch arrangement to get the NAND. All in all, there are three NOT gates at work here: not A, not B and the not of their OR combination.

In case you have skipped that on account of having enough direction in life so as to not blindly take STEM, here's another explanation. The "AND" gate is supposed to produce a signal if both its inputs have a high signal. To do this, we use the block-torch arrangement discussed a few paragraphs ago to get the inverted forms of both inputs. If both of those signals were originally 1, their inverses will both be 0. In any other case, at least one of their inverses will be 1: (0, 1), (1, 0), or (1, 1). Just combine the two signals with redstone wire. This is the inverse of an AND: it is 0 when both are 1, and 1 in any other case. It is called a NAND in technical language. Take the NOT of this using another block-torch arrangement to get the AND gate. 

An AND gate

Adding a single block-torch thingy to the output of the OR gate will give you the NOR gate, the inverse of the OR. Removing it from the tip of the AND will give us the NAND, of course. These gates in combination create all of computer science. They are all you need to understand the workings of a computer.

Some things:

1. Redstone can transmit vertically in many cases. Redstone wire can climb up one block at a time, in steps. This opens up opportunities to make our gates smaller. Smaller gates = smaller, more powerful Redstone computers. If you're feeling brave, figure out how to do this. Otherwise, leave it to my abstraction: I'll gloss over it in the coming articles.
2. There is an item known as a Redstone comparator. When it was designed, Notch (creator of the game) knew what it did and God also knew what its purpose was. As of today, God has forgotten and only the Swede knows. I don't quite understand what it does, either.

Next

In the next article, we will discuss the binary number system for dummies and create two basic elements of a computer in Redstone: an encoder and a decoder. These two components show up all over the computer system.

Comments

Popular posts from this blog

Intercity Diaries, Pt 1

On my Hiatus

RIP Ustad Rashid Khan