Minecraft and Forge: Try This Amazing Way to Visualize Logic


I’ve got virtual circuits on the mind lately. There are a myriad of tools out there that I could pick up to satisfy this compulsion. But the one I’m reaching for is Minecraft. I know what you’re thinking… a lot of people think Minecraft is getting long in the tooth. But chances are you never tried some of the really incredible things Minecraft can do when it comes to understanding logic structures. This goes way beyond simple circuits and easily hops back and forth over the divide between hardware logic and software logic.

Traditional Circuit Simulation

Circuit simulation is a very cool idea — arrange virtual electronic components on the screen and test the circuit prior to assembly. Of course major EE programs do in fact have circuit simulation built right in. They’re not a substitute for practical testing, but are crucial to helping the engineer understand the abstract concepts that pop up in electron theory.

On the lower end, some online layout programs have rudimentary connectivity indicators — in Fritzing the contact point turns green once it’s connected, or red if contact is broken. Circuit123 claims to offer the ability to visualize electrical activity in a circuit but it’s almost a joke — there’s an LED that appears to light up, and a motor with a turning shaft, and that’s pretty much it. It also, notably, lacks the measurements that make it more than a novelty.

There are more serious tools that do a good job of helping engineers design circuits. SPICE programs allow engineers to prototype circuits on the schematic level. And of course we here at Hackaday have been in love with Falstad since discovering it a few years ago. Al Williams did a great dive into understanding logic circuits with it not long after that.

These all help the human mind visualize what’s going on with all of those electrons. What they don’t do is help you wrap your noggin around programmable components. Where do you look if you want to better visualize what’s happening in a program? You can’t drop a RPi icon with a Python script on it into one of these simulators, and it’s a damned shame. Put bluntly, they do not address software’s logical structure at all — you can’t see an if/else or while work on the screen.

Ironically, it took a game to really do a good job at immersing people in an engineering-rich environment. I am of course talking about Minecraft.

Indulge Me While I Go Down the Cubiform Rabbit Hole for a Moment

Since its debut, Minecraft has become known as an engineer’s game — complicated structures can be built with a variety of materials, and different elements work together following very readily understood rules. It appeals to all age levels and it can be played with or without monsters and fighting, making it a favorite among kids of all nerdiness levels.

Minecraft’s analog for electronics is Redstone, a magical ore filled with uh… magical power that somewhat resembles electricity. There are switches, lamps, comparators, repeaters, and other elements also found in the EE world. Wiring takes the form of “redstone dust” that is sprinkled in trails above and next to the blocks to be powered.

Very early on it was realized that you can use Minecraft’s Redstone elements to make simple circuits and logic gates. For instance, the image to the right shows an OR gate. Flick the switch and the piston actuates, pushing or pulling the Redstone Block (the red cube) so that it contacts one or the other lamp. The switch is the piston’s power supply, so you can substitute a Redstone signal for the switch to get the same effect.

You can see how you can use different combinations of those elements to create other logic gates. Furthermore, you can create more complicated structures the same way. A quartet of Redstone Repeaters in a loop makes a timing circuit, for instance, releasing pulses of Redstone energy at regular intervals.

As game development progressed, Command Blocks were introduced, serving as primitive computers meant to operate in the background — they do not appear on any menus, and can only be created with console commands. They are also powerful, able to affect any element in the game. However, very quickly they got hijacked by engineers as well. For instance, this guy created a BASIC interpreter using Command Blocks. Working with world-controlling software WorldEdit, you can do a lot of crazy things.

Another exciting element in the game, Minecraft also released a Raspberry Pi version of the game, allowing you to not only create portable versions of the game but far more importantly, it can run Minecraft in conjunction with world-interacting Python scripts. Not only can you control the game world with this rig, the game can also control the RPi — this in-game light switch is a great example. You can also control an Arduino that is plugged into a PC running the game. MCreator is custom software that allows serial control of an Arduino through Minecraft and presents a drag-and-drop, no-code interface.

But It’s Not Really Electronics!

It is true that Minecraft’s approach carries with it a distinct fantasy element. It’s not trying to show off resistors and capacitors. Redstone Dust traces don’t behave like wires, and Redstone Comparators work in unexpected ways. Power supplies come from surprising places — torches, really? — and work in unrealistic ways.

Okay, so it doesn’t teach electronics in the literal sense. But it does teach engineering — it teaches you logic, to make the best of a limited palette of components, to research the capabilities of each component, and to approach a project from a perspective of planning it out from start to finish with a clear idea of what is supposed to happen and how it will happen.

It helps hone an engineer’s sensibilities — it’s not good enough to make it simply work. How do you create the most elegant solution? When you max out your RAM with dodgy code, you can’t visualize how bloated it is. But when your Minecraft circuit consists of a factory-sized labyrinth of tangled elements, you can pretty much see it. You can see the loop, you can stand on it. You can see the Redstone traces light up with power. It gives you a new perspective on how the elements come together.

Sometimes you can even create cool things that simply work — the image above shows a 20-channel NOT Gate with a power supply in the center (visible as a tiny yellow dot) triggering 20 Redstone Torches. While normally on, this rig turns off the torches as long as the power supply is positive. How cool is that?

Minecraft Computing Levels Up

The number one problem of creating circuits in Minecraft is that they really don’t look or act like the real deal. The classic windmill-jousting project of enterprising Minecraft hackers is the clock. Can it be done? Never mind accuracy, can you create the thing in less than castle-sized enclosure? Something that would be relatively simple in the real world doesn’t work, or barely works, in the game.

Part of the problem is the wiring. Redstone dust automatically connects to every adjacent conductive surface, so you have to insulate by raising one strand or insulating with an empty block. This creates two problems. First, you have really huge labyrinths of wiring that stretch on for what seem like football fields in of game terrain. Plus, Redstone Dust wiring all looks the same, and when you get into complicated structures it’s easy to follow the wrong trace.

Now, if only someone could create a mod that would make Minecraft’s Redstone parts act more like electronics! Fortunately, there is a modding community to which to turn.

Mods for Electronics-Like Minecraft

Minecraft’s creators have been very cool about casual users writing mods for the game, and in 2012 released their Forge API to facilitate this creativity — just another of the game’s nod to engineers. Many casual modders have used Forge to make cosmetic changes only; for instance, giving people’s Minecraft projects a Halloween theme. Forge goes way beyond that, however, by allowing users to overwrite the Java building blocks (ha) of the game. You can literally change Minecraft into a different game.

As with any open-source project, many different modders worked on different parts. For instance, ForgeMultipart changes one of the core tenets of the game, which is that each block has only one thing going on with it. Among other advantages, it allows faux-electronic components to get much more compact. Another cool mod was the Forge Relocation API used to transport blocks around the game world.

Those two mods, along with a few others, have come together as Project: Red, the most ambitious attempt yet to introduce (more) realistic electronic elements into the game. Some of its features include insulated wires with 16 different colors, as well as bundled wires so multiple signals can cross over the same block. This is where that MultiPart API comes in, allowing multiple signals to enter the same block at the same time.

Insulated wires only connect to other wires of the same color and do not power any support blocks the way Redstone Dust would, and vice versa — if a support block becomes powered by another source, it doesn’t affect the power level of the wire. Wiring in Project: Red also can be placed on the undersides of blocks, unlike dust. There are multicolor LEDs, even though there isn’t colored light in Minecraft.

Where Project: Red gets really sick is when you get into the ICs. They’re the same ones you’d expect: timing circuits, logic gates, sensors. In essence, Project: Red takes those room-sized circuits and shrinks them down to a single block, kind of like the real world! For those of you pining for a Minecraft clock, there are double 7-segment displays, each controlled by 16 signals. Powering a wire lights up a matching segment, with the 8th and 16th lighting up the decimal points. Your Steve can change the settings of any IC with a screwdriver.

One of the new elements that most excites me, and where the true computing power of the game will become evident with this mod is that network pipes transport not packets of data, but game blocks. Employing ICs that detect block type, it becomes easy to see how such a mod could be used to make a fairly sophisticated CPU.

Project: Red was created by college student [MrTJP] with contributions from other mod creators, and you can help support his efforts on Patreon. The following video does a good job of describing the project.

Simulating Electronic Circuits, For Realsies

While Project: Red intrigues, there are still many artifacts from the game that interfere with it being an actual simulator of electronic circuits. Does a simulated circuit that works oddly from an electronics standpoint, but realistically from a logic standpoint, offer enough? Does the VR angle offer any advantages? Is being able to walk around and literally inspect every connection and component better than looking at a schematic on-screen?

I’m not sure, but I feel like a programming and design environment — like Minecraft but realistic — that teaches about components and logic at the same time, would be a great tool for development and education. Let’s get on it!



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *