estimated reading time: 2 min
As the best-selling video game of all time (sorry, Mario!), there is no question that Minecraft is a big deal. When gamers put down their controllers to take a break from playing virtual LEGOs in the Overworld, they even flock to the movie theater to watch a Minecraft adventure play out on the big screen. But YouTuber PortalRunner wanted to take this hugely successful video game franchise and stuff it into a really small package, because as we all know, things that are either really large or really small are objectively better than normal-sized items.
In particular, PortalRunner set out to shrink the size of a Minecraft server. These servers facilitate multiplayer experiences in a single, shared world. Just how small was PortalRunner thinking? Maybe a Raspberry Pi comes to mind for you? Oh no, that would be way too easy, think again! Believe it or not, PortalRunner shrunk a minimalist Minecraft server all the way down to ESP32 size.
Actual gameplay (: PortalRunner)
That is a very tall order, so some compromises had to be made. By necessity, memory usage and performance were prioritized over features, so you may run into the occasional issue. But hey, the server is running on an ESP32, so what did you expect? The chip has only 400KB of SRAM and a processor that runs at 160MHz, so getting it working at all is quite a feat.
No need for you to check, Mojang Studios does not officially support the ESP32 (obviously). So PortalRunner wrote a custom Minecraft server, from the ground up, in C. Since every last drop of performance must be squeezed out of the chip, PortalRunner had to work very close to the bare metal. This fact gave the project its name — bareiron.
One of the major areas where features were dialed back in favor of performance was in terrain generation. The game uses procedural generation to create random-ish worlds each time a new game is started. But that process takes a lot of compute power and memory on the server side. Those resources are in short supply on the ESP32, so PortalRunner devised an alternative method that achieved the same basic goals with far less computational resources.
Many other such optimizations were built into the custom server, which enabled it to load game chunks within 200ms. That is fast enough to be smoothly playable, even if some corners had to be cut to make it possible.
All of this leaves one question remaining: Why? Why would anyone want to host a Minecraft server on a tiny microcontroller? I suppose one could argue that it saves energy, or something along those lines, but for the most part, it really doesn’t make sense for any reason other than being able to say that you did it. And if you do want to do it, the bareiron source code is available on GitHub under a permissive GPL-3.0 license.
from wallabag — all feed https://ift.tt/DOcWgue