Finally, you can set your artificial intelligence creations free in Minecraft. Microsoft has announced a public release for Project Malmo, the company’s system for testing AI software in Minecraft — and for the first time, anyone can join in.
Microsoft first made the system available to researchers in March under the name AIX, but this release marks the first time the code has been freely available to the public. The code is all available under an open-source license on Github, including a full tutorial on how to deploy your script on the platform, which is embedded below.
The result isn’t that different from typical AI test, in which code is deployed and observed in a test environment. But researchers hope that using Minecraft as that environment will provide new insight into the capabilities and limitations of various AI scripts. Since a typical Minecraft instance is far richer than most AI test environments, Microsoft hopes the integration can speed up the development of various problem-solving and navigation tasks .
“This is going to have an impact in education, at least at the university level,” said Malmo’s project lead, Matthew Johnson, in a provided statement. “If I come across some YouTube video showing off some exciting new functionality enabled by our mod, that would make my day.”
Do you like videogames within videogames? Are you waiting for a companion game for Inception? It doesn’t look like we’ll be getting that any time soon, but what you can do is download a mod for Minecraft that lets you play the Pokémon GBA games inside the world of Minecraft. Norwegian Twitter user @Reqaug tweeted a screenshot of his progress in this mad endeavour all the way back in January 2015, and only a few days ago (June 24) he shared a video of what it looks like now. Here’s what it looked like back then:
We have no idea how he has done this. How did he have the time? Where did he get the idea? What compelled him to spend what’s probably thousands of hours building a game he could just play on his GBA? It doesn’t even look like you can catch Pokémon in it – but then again, it doesn’t matter: what really matters is that this guy is immensely skilled and has done something that the majority of people probably don’t even understand. With the imminent arrival of augmented-reality game Pokémon Go it’s unlikely that people will be heading in their droves to Reqaug’s Minecraft version, but still – it’s pretty impressive to see what he’s made. Take a look below:
It’s IoT Week at SitePoint! All week we’re publishing articles focused on the intersection of the internet and the physical world, so keep checking the IoT tag for the latest updates.
Some of the most interesting programming I’ve done has been in Minecraft. It’s an open-world, sandbox game developed by Mojang, (recently acquired by Microsoft). Minecraft began as a canvas for creative expression, and while I do very different things in it these days, it still is that for me.
I’m going to take you on a journey, as we build a Minecraft mansion, and then secure it with a real-world alarm system. There’s quite a bit of ground to cover, and though I plan for this to be a two-part series, I’m going to have to leave some of the tangential details for you to discover!
Minecraft began as the combination of two simple ideas. The first is that players can harvest resources from the map in which they find themselves. Some of these resources, like food and wood, are common above ground. Others, like gold and stone, require a bit of virtual elbow-grease.
This is where the “mine” (in Minecraft) comes from. One of these resources is called Redstone. It’s found deep underground, and it’s a conductor of sorts. When harvested and placed on the ground, it resembles the silvery lines on the flip side of circuit boards. There are also power emitters, similar to batteries or mains power, which take many forms in the game.
Using these harvested resources, players can build dwellings, cook food and even wire up virtual circuitry. This is where the “craft” comes from.
I talk about all of this, as well as basic circuitry and programming, in my conference talk Zombies and Binary. I presented it most recently at php[tek] 2016, but the recording was lost. Here’s a JavaScript-themed version, from FluentConf 2016: https://youtu.be/APJRBZUxADQ.
Imagine we’ve created a sprawling Minecraft mansion…
Now, imagine we want to secure the front door of said mansion…We need a way to check whether the front-door has been opened. To do this, we need to use Redstone, something called a Comparator, and another thing called a Command block:
You may notice the switch I’ve connected to the Command block. Switches are one kind of power source, and this one will provide some power to the Command block so that it can perform the open door check. We’ll automate this power source in a bit…
Command blocks are placeholders which can contain a single server command. Server commands are anything you as a player can do (provided you are a server admin or in single-player mode). They’re like Amazon Dash buttons, in that they can be given a single command to run, at the push of a button.
We’re going to make the Command block test for an open door. Minecraft maps are coordinate-based, which means the test needs to include coordinates for where the door will be placed. For argument’s sake, let’s say the door is at 191 67 -194. The command for the test (of an open wooden door) will then be:
/testforblock 191 67 -194 wooden_door 3
You can find your current map coordinates with fn + alt + F3 (for Mac) and F3 (for Windows). Walk to the block where you’ll place the door, and enter those coordinates in the command.
Different Minecraft blocks (whether crafted or naturally occurring) have unique block names. wooden_door is the unique block name for an Oak door. 3 is a reference to the orientation of the door, so it might be different in your maps if you place your door in a different orientation. If so, try 0 through 3 until you get the desired result.
We’ll make the second Command block whisper a message back to us to indicate when the test has found a matching block. When we flick the switch, and the door is still closed, we should see nothing. But when we open the door (and the test matches the open door’s orientation), we should see confirmation of this!
Now we have a way to check for an open door. We don’t want to be standing around, to manually run this check though. Let’s set up the programming equivalent of an infinite loop, or the electronic equivalent of a crystal clock.
For this we need two Command blocks, arranged like this:
Notice I’ve attached a button to each Command block, so that I can run their commands. These buttons also act as a power source, giving a brief power spike to the blocks they’re connected to.
Map coordinates can also be relatively defined. That is, if you need to reference coordinates nearby the Command block, you can use ~-1 ~ ~+1 to mean the Command block’s x coordinate minus 1, the same y coordinate, and it’s z coordinate plus 1.
In this arrangement, we want the top Command block to place a Redstone block just below it:
/setblock ~ ~-1 ~ redstone_block
…And we want the bottom Command block to place a block of air above it:
/setblock ~ ~+1 ~ air
Redstone blocks also act as a power source. This arrangement has an interesting side-effect. When the top block places a Redstone block below itself, the Redstone block gives power first to the bottom Command block. It then gives power to the top Command block.
In the meantime the bottom Command block has removed the Redstone block. Since the top Command block got a new power signal (from the Redstone block it placed) and the block was then removed by the bottom Command block, it starts the cycle over again.
This leads to the infinite loop I spoke about. The loop will persist through server restarts, and if you’re in creative mode you’ll be able to break the Redstone block and see new ones created instantly.
By default, these Command block actions will be logged and will trigger messages on the server. You can disable these with a couple commands (which you only have to enter once per map): /gamerule logAdminCommands false and /gamerule commandBlockOutput false.
If we take power from the clock, and direct it into the testing Command block, the test will run many times a second, giving immediate feedback when the door is opened!
Newer versions of Minecraft allow Command blocks to power themselves and even repeat themselves. With that, it’s possible for the door check to repeat without the clock. If you’re using an older version of Minecraft, especially when using mod packs, you may still need to make the clock yourself…
It’s also useful to know when the door has been closed, so we can turn the real-world alarm off. For that we can use an inverter (think of it as turning the closed door (false value) to a true value, in much the same way as we would in programming: while (true) if (!$doorOpen) print....
Watching Log Files with PHP
All of this is pretty and useless without the ability to see these changes in PHP. We need a way to “hear” when the door has been opened, and react in PHP.
Fortunately, the whispered messages are all logged. If we can figure out how to watch and interpret the log files, we should have all the information we need…
A quick Packagist search provides a file watcher library which looks like it’s up to the task. We can install it with:
composer require yosymfony/resource-watcher
After that’s done, let’s make a script to watch the log files. We begin by creating a Symfony Finder instance, and pointing it at the directory in which the Minecraft logs are stored:
The path to Application Support will be different for you – it’s usually in the Library folder associated with your account. You could also be using a portable version of Minecraft, so you’ll just have to search around a bit, until you find the logs folder.
This Finder instance narrows the file watch list to *.log files in the same directory as the one we’ve specified. The methods are clearly named, so you can expand the criteria for other applications.
Next we need to define a cache file, and a watcher instance:
useYosymfony\ResourceWatcher\ResourceCacheFile;useYosymfony\ResourceWatcher\ResourceWatcher;$cache=newResourceCacheFile(__DIR__."/cache.php");$watcher=newResourceWatcher($cache);$watcher->setFinder($finder);while(true){sleep(1);$watcher->findChanges();// ...respond to changes}
This script acts as a long-running process. That is, we want to watch for changes to files, for an indeterminate amount of time. So we create an infinite loop, and use it to constantly probe for file changes.
You can sleep for more or less time. I found 1 second was good enough for me…
The watcher library provides methods for three kinds of file changes: creation, deletion and updates. We only care about the updates:
while(true){sleep(1);$watcher->findChanges();// ...respond to changes$changes=$watcher->getUpdatedResources();if(count($changes)>0){$first=$changes[0];$lines=file($first);for($i=count($lines)-1;$i>-1;$i--){if(stristr($lines[$i],"CHAT")){if(stristr($lines[$i],"closed")){print"closed!";}if(stristr($lines[$i],"open")){print"open!";}break;}}}}
New chat messages are appended to the bottom of the log file, so we need to check if any log files have been modified (we expect only one log file), split the log file into lines and check each line from the bottom of the file to the top.
If we see a log line containing CHAT, we can assume it is a chat message. If it also contains open or closed, we can assume it is caused by the circuit we created.
You’re welcome to use more “unique” message formats for open/close events. The approach I’ve chosen is simple but open to abuse and ambiguity (like if someone else whispers “open” to me). The underlying principles are the same though.
This is only half of the experiment. In the followup post we’ll look at how to build an Arduino-based alarm circuit, and connect it to this script. The end result will be an automated, real-world alarm for our Minecraft mansion.
You can create a lot of things in Minecraft – including, it seems, other games. One canny crafter has gone above and beyond though, using the sandbox title to build a working Game Boy Advance, and a version of Pokémon Fire Red to play in it.
Unlike Nintendo’s official partnership with Minecraft that sees Mario and friends joining the Wii U edition of the game, this is an entirely fan-made project. Minecrafter ‘Reqaug’ created the ambitious project over the course of three weeks, using the third-party tool Spritecraft to translate Pokémon’s pixel art into Minecraft’s signature blocks.
While the game looks like a regular 2D game viewed front-on, Reqaug’s video shows it is actually an incredibly complex series of 3D arrangements. The construction explains why each move the player makes requires the entire game to be ‘redrawn’ with each frame.
The virtual GBA is very much a work-in-progress, as is the version of Pokémon Fire Red. At present, it’s mainly the overworld players typically explore, and a Pokémart store that can be entered. There are no battles or, crucially, any actual Pokémon to be seen yet.
However, there is a level editor, allowing other Minecraft builders to experiment with the tool, and Reqaug said: “This project will always be in progress as it can always get better.” It’s also unclear whether the GBA can be used to ‘play’ other games – certainly a labour of love for other creators to take on.
Anyone wanting to test Reqaug’s build out for themselves only needs to be running Minecraft version 1.10 or above, and download the save file – no modding required. It may barely be playable in real terms, but it’s a phenomenal achievement just as a feat of digital engineering. There is, of course, a very real chance Nintendo or The Pokémon Company International may crack down on the build as it’s totally unofficial.
Technobubble covers games, gadgets, technology and all things geek. Follow Technobubble poobah Jason Hidalgo’s shenanigans on Twitter @jasonhidalgo
Hey, it’s-a Minecraft!
Mario meets Mojang’s blocky, uh, blockbuster as Minecraft finally makes its way to the Wii U. Given its family-friendly gameplay and popularity with young’uns, I find it surprising that it actually took the game this long to arrive on Nintendo’s nearly four-year-old console. Is the arrival of “Minecraft: Wii U Edition” worth the wait?
For folks who have never played the game and have no plans to go the PC route, the answer will be “yes.” As far as Minecraft’s console versions go, the Wii U Edition compares favorably and even has features that might entice those who have played on PlayStation and Xbox.
To help it stand out from the rest of the Minecraft family, the Wii U Edition throws in a touch of Nintendo’s popular mascot. This comes in the form of the Super Mario Edition’s Mash-Up Pack, which features textures based on Nintendo’s mascot that allows you to create your own Mario-themed area or even re-create famous structures from past games. Loading the Mario-inspired portion of the game, for example, unveils a themed sandbox that includes gigantic recreations of characters such as Mario, Chomp Chomp and Bob-omb. It also comes with a recreation of the castle from Super Mario 64 as well as Mario 64 music, which should bring a smile to folks who recognize it.
In addition to a plethora of textures, the game comes with a variety of Mario-themed skins. You get familiar items such as mushrooms as well as skins that turn chickens into goombas and sheep into koopas to keep things more in line with the Mario theme.
Another thing that sets this version apart is the use of the Wii U tablet, particularly for off-TV play. Otherwise, the Wii U edition should be familiar to folks who have played other console versions of Minecraft. You continue to have options such as Creation Mode for folks who want a more free-ranging crafting experience. For folks who want an extra challenge or a more game-like atmosphere, there’s Survival Mode as well to keep them occupied. You can also have up to four-player split screen for players who want to share in the fun.
Just like other versions of Minecraft, the best part of playing the Wii U Edition is freely going about as you explore, build and craft to your heart’s desire as day turns to night and back. There’s just something about the basic Minecraft experience that tickles a creative spot in your brain and feels wonderfully satisfying.
One thing I wish that the game fleshed out more is use of the Wii U tablet. For folks who prefer the controls on PC, the tablet’s touchscreen could have been an awesome interface but sadly wasn’t used to its full potential. Also, while the off-TV option is great, it does make some of the text harder to read.
For folks not interested in the Mario components, the game likely won’t provide enough incentive to jump off from the PC or other console version. And if you’ve burnt out on Minecraft after playing the game a long time, this edition likely won’t change your mind. If you’re a Minecraft fans with a soft spot for Mario or a new player itching to see what Minecraft is all about, however, this is one warp pipe you’ll want to jump into.
FINAL THOUGHTS
Minecraft: Wii U Edition adds a touch of Mario to the popular crafting franchise while bringing it to Nintendo’s console. Outside of the Mario-themed additions, folks who have invested lots of time with other console or vanilla PC versions likely won’t have incentive to make the switch. For those who have yet to play Minecraft, however, the Wii U Edition could be a good jump-in point to get their toes wet and find out what the fuss is all about.
In a clever bit of miniaturization, [JediJeremy] has nearly completed a gyro-mouse controller for a Raspberry Pi Zero! Ultimately this will be a wearable Linux-watch but along the way he had some fun with the interface.
Using the MPU6040 gyroscope/accelerometer card from a quadcopter, [JediJeremy] spent a week writing the driver to allow it to function as a mouse. Strapping an Adafruit 1.5″ PAL/NTSC LCD screen and its driver board to the Zero with rubber bands makes this one of the smallest functional computer and screen combos we’ve seen. Simply tilt the whole thing about to direct the cursor.
It presently lacks any keyboard input, and [JediJeremy] has only added a single button for clicking, but look at this thing! It’s so tiny! In his own words: “I think this is the first computer that I can accidentally spill into my coffee, rather than vice versa.”
There have been a few issues along the way. He was originally planning to detect taps on the screen using the accelerometer and use that as the clicking input, but it disrupts the cursor position. The screen’s driver board also likes to overheat, and it tends to kill the battery life since the screen doesn’t shut off completely — but it is still a functional proof of concept.
Stripping away the need for clumsy mouse is in perfect thematic keeping with this efficient powerhouse of a computer. The best part is the extremely low price point of all the components so building your own is a cost-effective project as well! If that’s not to your taste, why not a button that plays a random episode of The Simpsons?