19 December 2013
My author copies of the book Raspberry Pi Projects arrived yesterday, and it looks great! The book is written by Andrew Robinson and Mike Cook, and includes contributions by Jonathan Evans and me. With 16 practical hardware and software projects, it shows readers how to start building Pi-controlled gadgets, games and devices that integrate with Facebook and Twitter.
I was invited to write a chapter about programming Minecraft on the Raspberry Pi. Once I'd got to grips with the API, I knew I wanted to do something that was computationally interesting, rather than just positioning some blocks to make a house. The idea I hit upon was to make a maze out of blocks that you could walk through, so I wrote a Python program to do that. I've written many games over the years that include mazes, but they were all hand-designed, so it was interesting to write a program that creates something fresh to explore each time you run it, and that can change the size and style of the maze each time too.
Minecraft was an interesting platform for a maze maker program. Often programs like this require a lot of data to be stored representing the walls, but in Minecraft the world itself stored the blocks and spaces that made up a wall or a path. That simplified the program greatly, because I could just test whether a block was there rather than looking up walls in an abstract data structure.
Below is a video of the program in action. You can fly above the maze and look down on it (as I have here) to watch it being made.
The maze doesn't have entrances or exits, and doesn't have goals (although I left a gold block in there to find - it's there so you can see the path the maze maker algorithm takes while the maze is built). I'm sure Minecraft fans can add goals and challenges to this structure!
At the time of writing, the book is heavily discounted at Amazon, and represents fantastic value given its size (470 pages) and scope. I've had a look through it, and I'm very much looking forward to reading the rest properly.