I have spent some time over the last couple of years trying to teach the kids programming … for the most part my attempts have been unsuccessful … I was simply not able to interest them.
Recently, my youngest daughter has been (very independently of me) showing an interest in these kinds of things. She recently convinced me to help her build a 3D Printer (I will admit she did not have to bend my arm TOO hard) and she has also been asking me the best programming language for a beginner to learn. (You can see some of our progress with the 3D Printer at this link.)
While helping Helen evaluate a programming language to learn I stumbled across a pretty exciting programming development for Minecraft. If your kids are at all like two of mine you will already have heard of Minecraft. If you have not heard about it Minecraft is a real-time game server that allows multiple players to interact together in a virtual world; it is wildly popular. What I discovered is that the makers of Minecraft have written an interface that allows you to code Python (or Java) to interact with a Minecraft world with scripts that you have written. They apparently did this specifically to encourage young kids already hooked on Minecraft to learn how to code.
What is really neat is that you can set up this Minecraft/Python programming environment on a Raspberry Pi (a single-board computer) … how cool is that?! In fact, somebody has already written an introductory, free Python programming ebook that uses this Raspberry Pi/Minecraft combo (called Minecraft Pi) that teaches you how to do things like automatically create a building in minecraft from a python program.
Now, for a totally mind-blowing experience you can take all of this a step further and connect your Minecraft virtual world to the real world. The beauty of being able to program on a Raspberry Pi is that it is fairly simple to connect the Pi to interface electronics; inputs such as buttons, switches and sensors, and outputs such as LED’s and displays. Once you’ve mastered some more python programming skills you can cause an action in Minecraft (like moving to a specific location) to do something in the real world (like flash an LED or open your garage door) … or better yet toggling a switch in the real world could cause your Minecraft nemesis to be teleported over a large body of water … your imagination really is the limit.
Sadly, we do not own a Raspberry Pi so I was unable to try some of this out. However, you can (and Helen and I did on my Mac and her Windows 7 laptop):
- install Python (we already had 2.7 and I would recommend this version),
- install a Craft Bukkit server with this Python interface (called Raspberry Pi)
- pretty quickly write a python script to interact with the mine craft server you just installed (make sure the mine craft server is running first).
Our really simple first script was:
It was pretty simple and the free ebook I mentioned earlier looks like a pretty good introduction to programming in Python. The book is written on the assumption that you are going to use a Raspberry Pi but as I just described you can set this up on any computer and use the book … just ignore the Raspberry Pi stuff.
Getting slightly more complicated I then took a look at talking to an Arduino from a python script (another popular single-board computer used to make things … we are using one in our 3D printer). It turns out this is pretty straight forward too … I was able to easily blink the lights on an Arduino Uno connected to my computer with a USB cable from a Python script. This means I could pretty quickly use Python to talk to mine craft and the Arduino (think the real world) at the same time. I was a little stunned by this … it is fairly easy to put together a Minecraft/Python/single-board computer environment that lets you do a lot of neat things.
There are some amazing possibilities here:
- Being chased by an angry Minecraft monster? Run a python script to build your fortress of solitude (in microseconds),
- Flip a switch in the floor plan of your house that you modelled in Minecraft and watch the light come on in your real house,
- Press the planetary destruct button you’ve wired to your computer and watch a mine craft world turn completely to water … or disappear.
I am kind-of excited … I feel like I am relating to my kids … sort-of.
James Hornett says
This is pretty cool.
Rose says
I like minecraft so much