Login | Register

Nerd Paradise

Don't blink.

Minecraft Tutorial: Redstone Logic

Tags: Minecraft
Post by: aviel
Posted on: 11 Vigeo 4:3 - 19.98.17
Searching "Minecraft Computer" on Youtube will pull up some impressive videos of large, complex contraptions made in Minecraft using redstone. Looking at these videos, it would seem that the scale and intricacy of the redstone circuits should be incomprehensible to anybody. It turns out, however, that the fundamental building blocks of Minecraft computers are very simple, and their apparent complexity is largely just a result of how massive the computer is. This tutorial aims to teach the basics of boolean logic and how it applies to redstone, enabling the reader to derive more complex circuits. Using the redstone techniques presented in this tutorial, one can build any kind of logical circuit in Minecraft, from simple adders to functional computers.

Defining Terms

Before demonstrating how to assemble redstone circuits, we'll have to define some terms that you may not know, and specify the definitions of some terms you're already familiar with.

Minecraft: This game. It's fun and really challenges one's creativity: check it out.

Boolean Value: a boolean value is a value that is either true or false. I will interchange the term "true" with "1" and "on" throughout this tutorial, and "false", "0", and "off" should also be considered synonyms. As computers work in binary (and as each binary digit can only have 2 values: 0 or 1), boolean algebra is very important to understanding the mechanism behind the logic circuitry that makes up a computer. The term "boolean value" has the same meaning as the term "bit" or "binary digit."

Logic Gate: a logic gate is a circuit that takes some boolean values as input, performs a logical operation on the input, then outputs the result of that logical operation. For example: an AND logic gate receives two inputs, and only outputs "true" if both of the inputs are true. This tutorial focuses on making logic gates.

Truth Table: a truth table lists all possible inputs and their outputs for a logical equation. The truth table for an AND gate would look like this

input A | input B | output
true    | true    | true
true    | false   | false
false   | true    | false
false   | false   | false

Properties of Redstone

To understand why redstone circuits work, one has to understand how redstone works. The mechanics of redstone are fairly simple, but without an introduction, the following circuitry won't make much sense.

Redstone dust can carry power over fifteen blocks. After that, either a redstone torch or a repeater is necessary to further the signal. Redstone wire and redstone torches can be in one of two states: on or off. The convention is that glowing redstone is on, and unlit redstone is off. Here are two images of redstone wire and redstone torches in different states:


Redstone wire bordering the front of a torch will carry the signal of the torch. So if a torch is on, then the wire carrying the signal from it will also be on. However, torches invert the signal they carry: if a wire going to a torch is on, the torch will be off, and visa versa. Therefore a torch is actually a simple kind of logic gate: a NOT gate. It takes a boolean value and returns the opposite value. See here:

Screen shot 2011-10-07 at 12.21.30 AM.png

Like torches, wires coming from a redstone repeater will carry the same signal as the repeater, but unlike torches, a repeater does not invert the signal it receives: it pushes it forward. This is useful when a signal needs to travel over a distance greater than 15 blocks. Here is an image demonstrating the behaviour of repeaters:


If two segments of redstone wire meet, then the wire coming out of their intersection will be on if either or both of the inputs are on. As you can see in the following image, only one of the wires leading to the intersection is on, and the output is on as well.


Logic Gates

Now we can get to the purpose of the tutorial: logic gates. Logic gates perform boolean operations on their inputs: the output of a logic gate depends on the inputs and the circuitry of the gate itself. As computers are essentially just large collections of logic circuitry, a computer is nothing more than an ordered assembly of logic gates. If you want to make a computer, you have to know how to make a logic gate. There are seven basic kinds of logic gates that will be covered.

NOT Gate: The NOT gate only takes one bit of input, and simply returns the opposite value. As this is identical to the behaviour of a redstone torch, a NOT gate is just a redstone torch. Here's an image of a NOT gate:

Screen shot 2011-10-07 at 12.21.30 AM.png

OR Gate: The OR gate returns a value of "true" if either or both of the inputs are true. This is identical to the behaviour of a redstone wire segment coming off of an intersection of two redstone wires, so the layout of an OR gate is very simple: it's just two intersecting redstone wire segments. Here is an image of an OR gate:


NOR Gate: A NOR gate is an OR gate with its output inverted. So, while an OR gate returns true if either of the inputs are true, a NOR gate returns true only if neither of the inputs are true. As a NOR gate is just an OR gate whose output is inverted, a NOR gate is made by adding a redstone torch at the end of an OR gate, as seen here:


AND Gate: The AND gate returns a value of "true" if and only if both inputs are true. The AND gate's design is a bit odd: first each of the inputs is inverted, then the inverted inputs lead to an OR gate, then the output of the OR gate is inverted. This works because the value of the OR gate will return "true" any time one of the inputs is off, and then that value is inverted, making it so that the entire gate will only return true if both inputs are on. Here's an image:


NAND Gate: A NAND gate is an AND gate whose output is inverted. A NAND gate could be formed by adding a NOT gate to the end of an AND gate, but you'll recall from the previous section that an AND gate already has a NOT gate at the end. The simpler and more spatially conservative way to build a NAND gate is to make an AND gate without a NOT gate at the end. Here's an image:


XOR Gate: The XOR gate returns true if one, but not both, of the inputs are true. Another way to put that is to say that an XOR gate returns true only if the inputs are not equal. The layout of an XOR gate is kind of complicated, but it essentially involves four NAND gates arranged together in weird ways. So that you don't have to derive it, here's an image of the XOR gate:


XNOR Gate: An XNOR gate, as you may have guessed, is an XOR gate with a NOT gate at the end. This means that it returns true only if the inputs are equal. That is to say, an XNOR gate returns true if both the inputs are true or both the inputs are false. Although there are more spatially conservative ways to build an XNOR gate, I chose the simple route and just slapped a NOT gate and the end of an XOR gate. See here:


Exercise to the Reader

Those are pretty much all of the basic boolean operations, and their expression in redstone form. Those explanations are very abstract, and don't really give a good idea of their application in computing, which is why I am going to challenge the reader to derive an application: I want the reader to build a half adder using only the logic gates provided in this tutorial. A half adder adds two bits together. As a hint, the half adder should only require two logic gates, and its outputs should match this truth table:

Sum Bit (least significant bit)

Input A | Input B | output
true    | true    | false
true    | false   | true
false   | true    | true
false   | false   | false

Carry Bit (most significant bit)

Input A | Input B | Output
true    | true    | true
true    | false   | false
false   | true    | false
false   | false   | false

Good luck, and don't cheat by googling the answer.

Aviel Menter is a professional computer programmer, currently working towards his Bachelor's degree in computer science. You can follow him on Twitter or visit his website where he argues with the entire internet.
facebook twitter Stumbleupon Reddit del.icio.us Digg
User Comments: 3
Post by Mustache on 12 Vigeo 11:4 - 9.26.2
You should edit this and add repeater locks and the like. Just sayin'
Post by josh1 on 12 Cado 6:3 - 10.39.24
Damn, aviel, you know a lot of redstone.
Post by next525 on 16 Vigeo 12:5 - 7.84.75
Excellent post. Thank you very much!!
You must be logged in to add a comment
Current Date: 16 Vigeo 13:3Current Time: 3.36.59Join us in IRC...
Server: irc.esper.net
Channel: #nerdparadise
Your IP: UnknownBrowser Version: 0