Presenting ACROTICS

A.C.R.O.T.I.C.S. from above

You know those times in life when a really dumb idea turns out to be both ingenious and the most beneficial? Well, for me, that's exactly what happened!

I'd like to present to you ACROTICS; the Awfully Convoluted Road Operations Traffic Integration Control System. This bad boy can handle three whole directions of road traffic in an intersection... in Minecraft.

The Story

Before I can even begin to explain what this thing is, we need to go over the story behind it.

Back in the beginning of April, the professor in my Computer Organization class gave us a project to work on, and we'd have a little under a month to work on it. The assignment was simple: based on a provided logic chain diagram, calculate the equations and design a circuit to enable and disable the traffic lights in the right order. The kicker, however, was that the wiring part was to be done in this really old piece of software called MultiMedia Logic which was legitamitely designed for Windows XP.

Now, despite my friend in this venture completely unironically daily driving a Windows XP laptop (God bless that soul), we decided to do something else; we'd build it in Minecraft using redstone! On paper, it sounded plausible, everything in the intended program was easily replicable using in-game mechanics, and people have been able to make crazy stuff with redstone, so it sounded doable. And, upon asking our professor if he would forbid this idea, we were allowed to continue.

And thus began the development of the greatest project I've ever completed.

Development

Now, the way the project was assigned, we couldn't have just jumped right into the game and began building. A major part of the assignment was getting all of the traffic light equations, then putting them into a table, then derive the nine possible outputs from that table- it was a mess, and frankly, not the point of this post. But finally, after two weeks of staring at a computer screen banging our heads, we had what we needed. Now the fun could begin.

Because we hated ourselves, we decided we to begin our journey in Minecraft version 1.8.9 for no other reason than older = better, apparently. We spun up a local server and got to work.

How it works

Here's where I want to get a little more serious because the way this thing functions is actually really cool! But if the truly nerdy technical details aren't your thing, feel free to skip ahead.

If we wanted to be technically accurate, what is constructed is referred to as a finite-state machine, meaning that there are only a finite number of preprogrammed states the machine can be in at any given point in its processing. Despite what you may expect looking at the overhead screenshot above, the states are stored here, on the right-hand side, with this three-bit state register. Specifically, we call these components D Flip-Flops, each one storing one bit of memory.

D Flip Flops

If you aren't familiar with Minecraft redstone, you might wonder how blocks can actually 'remember' a state. We did this using a mechanic called repeater locking. In Minecraft, if you power the side of a redstone repeater with another repeater, it 'locks' its current state (either on or off) and ignores any changes to its input. To change a state, we temporarily cut the power to the locking repeater so the state can be passed through.

From there, we send the signals from our register down to be split into eight different redstone lines, or 'buses.' The fourth line being split is a manual switch that we'll get back to later. Each of these buses gets split into two distinct states: off and on. While building, we labeled each state as such. For example, our manual switch has 'S off' & 'S on,' our first bit has 'Q0 off' & 'Q0 on,' our second has 'Q1 off' & 'Q1 on,' and so on and so forth.

Bus lines

Now, it was at this point we realized... this version of Minecraft was way too old. There were tons of redstone bugs that hadn't been patched yet that were causing just so many headaches. So what did we do? We upgraded a from a version made in 2015... to a version made in 2017. Yes, you heard me right: I'm talking Minecraft 1.12.2.

After spending three hours transferring everything over to the new version, we began work on our actual logic. Firstly, because we have both 'off' and 'on' states we would need to check for, on every other line in our newly-split buss lines, we inverted the signal of with the use of a redstone torch.

Gates

Because the assignment specifically required us to use discrete logic gates, we implemented our AND gates as the yellow bridges shown below.

By running our bus lines underneath these bridges and using strategically placed redstone torches, we can check for specific combinations of 'on' and 'off' states. When the exact right combination of inputs is met, the bridge activates and passes a signal forward. The diagram below shows one of these gates in action.

AND gate (Note: This screenshot shows a different bridge from the one used at this point in the circuit sequence.)

While we're looking at our gates, we also have the blue bridges here. These are simply OR gates, used to transfer a signal directly over from our busses without other signals.

OR gate

Routing the signals

Now that we have a basic understanding of our foundational logic gates, let's zoom back out. You may notice, looking at our original overhead shot, that we have two main sections of AND gates. I'd like to focus on the main bottom section first.

These are the gates that actually control our traffic lights. Earlier, I mentioned deriving those nine equations from the assignment diagram. Well, this is where they come in! Six of our equations are used for individual light controls: the red, yellow, and green lights for both the North/Southbound and the East/Westbound directions.

You can see on the overhead shot how the outputs of those AND gates run together on the ground, acting as simple OR gates, before heading off to their respective lights.

Getting the next state

Moving onto the top set of AND gates in our circuit, we have my least favorite part of this entire project: the Next-State logic. I just want to say this now, these next states caused me hours of pain and torment of which I will never get back... Let's see how they work!

You may notice that these gates are not routing into any lights, but rather back into our D Flip-Flops. This is because, in order for the circuit to transition to the next step, it needs to know what state it is currently in. Mathmatically speaking, we would say that the next state in our machine is a function of the current state.

Luckily for my fingers typing out this blog post, there isn't much more to explain about the Next-State gates themselves. They just represent the remaining three of our nine equations, and otherwise work exactly the same as our regular AND gates just being routed into another section.

This is also a good spot to bring up that switch we mentioned earlier. Its purpose is to act as an extra variable simulating if a car is waiting at the intersection. The next states are calculated so the lights will only change if the switch is on, otherwise it will wait with East/Westbound being green and North/Southbound being red.

The clock

You know how real traffic lights don't have some dude pressing a button every time the lights need to change? Well our traffic controller doesn't feature that either!

The clock we used is just a standard repeater clock. It gives out a pulse every 112 in-game redstone ticks, meaning the lights change roughly every 5.6 seconds. If you think that's fast, you've clearly never driven in downtown Boston.

Clock

And with that, the machine is fully constructed! And upon testing... it fails tremendously! :D

Troubleshooting

Yeah... so upon testing it the first time, absolutely nothing worked.

The first issue we ran into was that our states simply weren't changing. After some incredibly painful debugging, we figured out that one of the equations we had attempted to simplify was incorrect, which broke the entire state machine. Like any exhausted engineer would do, our solution was to just rebuild the gate unsimplified. Why spend hours trying to elegant-code it when brute force works?

With that fixed, our state changes finally worked! But our celebration was short-lived: while the states were changing, the actual traffic lights were still wildly incorrect. I'm no traffic engineer, but I'm pretty sure North/South is not meant to have every single light green, yellow, and red at the same time while East/West is completely dead.

At this point, we decided to tackle the problem systematically. We disconnected our D Flip-Flops from the automated clock and hooked them up to manual input levers instead. Because our state registers store three bits of binary data, we could manually toggle the levers to represent any state we wanted (for example, setting the levers to 100 for State 4, or 010 for State 2).

By stepping through the states manually one by one, we were able to reverse-engineer exactly where our physical wiring diverged from our theoretical equations... which we learned were also entirely incorrect. So what did we do? Well, we reverse-engineered the equations from the now-working machine, obviously.

While it was a slightly chaotic way to get there, working backward actually forced us to master the Boolean math. When we mapped the physical redstone paths back to the truth tables, the equations clicked in a way they never quite did on paper.

And with that, the math matched the crime, the wires matched the math, and ACROTICS was officially fully operational.

The Demonstration & The Verdict

To show off our creation, we didn't just turn in a spreadsheet of equations. We built a fully realized three-way intersection complete with concrete roads, customized traffic light assemblies, and wool-block cars waiting patiently for the sensor switches to trigger... nah, I'm just kidding, we just left the lamps out to dry.

The finished intersection

Final Thoughts

Looking back, we easily spent three times as much work debugging repeaters, updating game versions, and reverse engineering machine states than if we had just done what our professor had intended... but we made a computer in Minecraft, so.

There is an unmatched satisfaction in taking a dry, theoretical academic exercise and breathing physical life into it. It was easily the most convoluted, stressful, and absolutely ridiculous way we could have completed this class project. I would 100% trying something like this in your class projects if you can.

If you're interested, I've uploaded the world file here so you can poke around at it. Just make sure you're in Minecraft Java version 1.12.2, unzip the file, and chuck it into your saves folder.

That's all! 73.


BTC: bc1q959c5h3ndl2zmfx73ys0rftsk46uz92ynkqjuj

XMR: 82jkYgE5ZE7eAqviMmLrd5iBDqb5SUGPMMK1Qni5o88R9MBtgKKCG34HwwzssMgwrRGVsYA3e7i8MQQnQx2vDSPrAH1gHpZ