July 01, 2015
A book on mazes? Seriously?
Not because you spend your day creating mazes, or because you particularly like solving mazes.
But because it's fun. Remember when programming used to be fun? This book takes you back to those days when you were starting to program, and you wanted to make your code do things, draw things, and solve puzzles. It's fun because it lets you explore and grow your code, and reminds you how it feels to just think.
Sometimes it feels like you live your life in a maze of twisty little passages, all alike. Now you can code your way out.
Now in print and shipping from pragprog.com/book/jbmaze.
(P.S., The July issue of PragPub magazine will be out next Wednesday)
Mazes for Programmers: Code Your Own Twisty Little Passages
You'll start by learning six maze algorithms and transition from making mazes on paper to writing programs that generate and draw them. You'll be introduced to Dijkstra's algorithm and see how it can help solve, analyze, and visualize mazes. Part 2 shows you how to constrain your mazes to different shapes and outlines, such as text, circles, hex and triangle grids, and more. You'll learn techniques for culling dead-ends, and for making your passages weave over and under each other. Part 3 looks at six more algorithms, taking it all to the next level. You'll learn how to build your mazes in multiple dimensions, and even on curved surfaces.
Through it all, you'll discover yourself brimming with ideas, the best medicine for programmer's block, burn-out, and the grayest of days. By the time you're done, you'll be energized and full of maze-related possibilities!
Now in print and shipping from pragprog.com/book/jbmaze.
Q&A with Jamis Buck, author of Mazes for Programmers
It has to be asked: Why mazes?
You know, I came to programming because it fascinated me. There was something magical and wonderful about it—this idea that I could write a few commands in some cryptic syntax and make something happen. It was powerful! I don't think I'm unique that way. I think a lot of us come to programming like that.
But somewhere along the line we generally lose that sense of the magical. Maybe it gets drowned in the mundane tasks we typically use these amazing tools for, I don't know. But when the magic goes away, so does the wonder. So does the fun.
For me, mazes take me back to those days when programming was fun, when I'd sit down and start coding simply to see what might happen! Every random maze is unique, and the algorithms lend themselves well to variation and experimentation. It becomes this iterative game of "what if," for me. What if I make this condition more or less likely? What if I disallow this set of cells in the grid? What if I use color to visualize this or that aspect of the maze?
So, why mazes? Because they bring the wonder and the fun back into programming.
How did you come to write this book?
Would you believe there aren't any other books solely about maze algorithms? I couldn't. There are lots of great resources online about them, but if you want to learn how to generate a maze in more than just one or two ways, you wind up having to do a fair bit of research. You glean a bit of information here, a bit more there, you tinker and experiment until you get something working, and then you do it all over again for the next algorithm.
Some years ago I wrote a series of blog articles summarizing my own explorations in just this vein, and they were pretty well-received. Some readers suggested I write a book…and I'm embarrassed to admit that it took me a few years to take them seriously. But I did, and here I am!
Why are there so many algorithms for generating mazes?
You can't write software for very long before realizing that there are lots of different ways to solve problems in code. There are at least a dozen different ways to sort information, for instance, and each one has different strengths and weaknesses. Just so with maze algorithms, too. Depending on your need for memory efficiency, speed, and esthetics, the variety of maze algorithms let you choose one that will best fit your needs.
Besides, life would be a bit less wonderful if there were only one way to generate mazes. I like to celebrate the fact that there are that many more things to explore!
What's your favorite maze algorithm?
I don't know that I could pick just one… I love the novelty of the Recursive Division algorithm, and how it works so well to add "rooms" to the mazes. One of my favorite projects recently was implementing a variation on Recursive Division that split each space into "blobs," instead of rectangular spaces, and that gave some really nice results.
I've always loved the Recursive Backtracker algorithm, though. The esthetics of the long, winding passages that it produces really appeals to me, and the algorithm itself can be used to solve as well as create mazes!
What do you hope readers take away from the book?
More than anything, I want them to come away with a new sense of wonder for computer programming. I hope they find themselves remembering their own first steps into the world of software development, and rediscovering that joy of learning and exploring.
My favorite thing about writing this book has been the times that readers have contacted me to show me something wonderful that they've created as a result of what they've learned. One man used the masking chapter to write a program that generated mazes in the shape of his child's name, which apparently earned him "dad-of-the-year" in their house! I love that stuff so much.
What's your favorite part of the book?
Since I suppose you won't be happy if I simply answer "all of it," I'll say that I really enjoyed writing the last chapter, the one about mazes on non-planar surfaces. I got very side-tracked on that one and as part of my "research" wrote an OpenGL program that built a maze on a sphere, and then allowed the player to navigate through it!
That kind of thing happened throughout the process of writing the book, though. Every algorithm suggested curious little projects to me, and I had to stop for a bit and explore sometimes. I hope the readers find themselves similarly distracted!
Upcoming Author Appearances
Brighton Ruby Conference 2015
Uberconf, Denver, CO
Uberconf, Denver, CO
Did You Know?
We publish books across a range of technologies for folks at different levels of abilities, all the way from novice to expert. If you haven't browsed all of our titles recently, come take a look:
Agile Practices • Android, iPhone, and Mobile Programming • Career
Development • Cool Things for Smart People • DIY & Hardware •
For Beginners • Gaming • Java and JVM Languages • Mac, iPhone,
and iPad Programming • Pragmatic exPress • Ruby and Rails •
Testing, Design, and Cloud Computing • Tools, Frameworks, Languages
• Web 2.0+
Come check out all our categories at pragprog.com/categories
Don't Get Left Out
Are your friends jealous that you get these spiffy email newsletters and they don't? Clue them in that all they need to do is create an account on pragprog.com (email address and password is all it takes) and select the checkbox to receive newsletters.
Are you following us on Twitter and/or Facebook? Here's where you can find us and keep up with the latest news and commentary, and occasional discounts:
Tell your friends! Tweet this
- Secure Your Node.js Web Application: Keep Attackers Out and Users Happy in beta
- Web Development Recipes 2nd Edition in print
- Predicting the Unpredictable
- Beyond Legacy Code
- Deliver Audacious Web Apps with Ember 2
- Developing for Apple Watch
Thanks for your continued support,
Dave & Andy
The Pragmatic Programmers
Books • eBooks • PragPub Magazine • Audiobooks and Screencasts