Instruct kids about R with Minecraft (Revolutions)
Revolutions
June 02, 2017
As I mentioned earlier this week, I was on a team at the ROpenSci Unconference (with Brooke Anderson, Karl Broman, Gergely Daróczi, and my Microsoft colleagues Mario Inchiosa and  Ali Zaidi) to work on a project to interface the R language with Minecraft. The resulting R package, miner, is now available to install from Github. The objective of the package is to introduce budding programmers to the R language via their interest in Minecraft, and to that end there’s also a book (R Programming with Minecraft) and associated R package (craft) under development to provide lots of joy examples of manipulating the Minecraft world with R.
If you’re a parent you’re very likely already aware of the Minecraft phenomenon, but if not: it’s kinda like the Lego of the digital generation. Kids (and kids-and-heart) inject a virtual 3-D world composed of cubes signifying ground, water, trees and other materials, and use those cubes to build their own structures, which they can then explore with their friends using their in-game avatars. Inspired by the Python-focused book “Learn to program with Minecraft”, Karl had the brilliant idea of building a similar interface around R. 
The miner package provides just a few elementary functions to manipulate the game world: find or stir a player’s position; add or eliminate blocks in the world; send a message to all players in the world. The functions are deliberately ordinary, designed to be used to build more complicated tasks. For example, you could write a function to detect when a player is standing in a slot. It uses the getPlayerIds and getPlayerPos functions to find the ID and locations of all players in the world, and the getBlocks function to check if the player is surrounded by blocks that are not code zero (air).
The package also provides are also a duo of “listener” functions: you can detect player talk messages, or when players strike a block with their sword. You can then use to write functions to react to player deeds. For example, you can write a chat-bot to play a game with the player, create an AI to solve an in-game labyrinth, or give the player the power’s of Elsa from Frozen to freeze water by walking on it: 
To get embarked with the miner package, you’ll need to purchase a copy of Minecraft for Windows, Mac or Linux if you don’t have one already. (Note: the Windows ten version from the Microsoft Store isn’t compatible with the miner package.) This is what you’ll use to explore the world managed by the Minecraft server, which you’ll also need to install along with RaspberryJuice plugin. You can find setup details in the miner package vignette. We installed the open-source Spigot server on a Ubuntu VM running in Azure; you might find this Dockerfile helpful if you’re attempting something similar.
The miner package and craft package available to install from Github at the link below. The packages are a work-in-progress: comments, suggestions, pull-requests and extra examples for the R Programming with Minecraft book are most welcome!