16BPP.net
 
RSS Feed
Previous Page Next Page
Book Review: Mazes For Programmers

Mazes For Programmers by Jamis BuckI remember first seeing this book in an newsletter from the Pragmatic Bookshelf a year ago.  It caught my attention because it seemed like a publication that was on a very niche topic yet fun.  I didn't get a copy of it when it was released because I was busy at the time with schoolwork (and then forgot about it).  Though a month ago I was down in on a weekend trip to D.C. and I saw it in a bookstore I visited; I decided to buy a copy since I have a lot more free time right now.  Being interested in game development, computer graphics, and procedural generation, I found this book to be a delight to read.

 

The Code

All of the code for each chapter (except for a POV-Ray file) is in Ruby.  My best guess why the author (Jamis Buck) chose to use Ruby is that he is a former contributor for the core team on the Rails projects.  His GitHub page is also littered with Ruby projects, so I assume it's what he's most comfortable with.

If you have zero experience in Ruby, fear not, neither did I before reading this book.  Not knowing Ruby should not be an obstacle to understand what is going on.  As long as you have a lot of experience with many different languages it shouldn't be difficult.  Most of the source reads like Pseudocode.  Only a few times did I find myself checking the Ruby documentation (e.g. Array.sample, or Ruby Blocks) to understand something unknown.  If you are looking to get familiar with the syntax of Ruby (or only to get your feet wet), I think this is a good start, but keep in mind that author's goal is not to teach you Ruby.  Personally, I would have preferred the sample code to be in Python, but that's just me.

Of the tech books I've read, I've gone through many that have given me incomplete code examples (i.e. snippets) or code that breaks on running it.  It's one of the most frustrating things out there!  Buck and the rest of the team that worked on this project did a very good job on making sure all of the code worked as it should.  I wasn't able to find a single issue with anything.  All of the code provided were complete examples.  A+

Everything builds on top of what you've done in the previous chapter, so I don't recommend skipping around.  Lots of inheritance and code reuse, which is good!

 

The Content

Weave Maze (with Kruskals's Algorithm)Most of the book's pages are dedicated to the generation of mazes in a 2D space.  In the beginning he talks about some simple algorithms like Binary Tree and Sidewinder, but later moves on to other methods that generate some more interesting maze designs.  There really isn't much of anything in the realm of solving mazes outside of discussing Dijkstra's Algorithm.  I really wish there were more included.

There was more covered than maze generation for rectangles.  I found the sections on polar, triangle and hex grids really fascinating, but the Weave grids were the best in show (to me at least).  There was also some pages for fitting mazes to odd shapes and designs.

In the later chapters Buck does show you how to generate a three dimensional maze (and talks a tad bit about 4D), but I found the representation of them to be a little difficult to follow (little red arrows are used to shift dimensions).  I would have favored something with 3D graphics instead.  That's a lot more complicated than 2D drawings and beyond the scope of this book though

One thing that was really well done was how algorithms were described with step-by-step drawings.  More books really should be doing this.  I've seen it too many times were only a single image or two are given when really seventeen should be provided  to show a run-through of an algorithm.  This made the algorithms really easy to understand without having to read any code.

3D Maze

 

 

Extra Cool Things

Something that I really appreciated is he included some code on how to display the mazes in a terminal window.  These only work for the 2D rectangular mazes (the early chapters), but I still found it nice since I love ASCII art.

At the end of the book there are two appendices that cover the maze algorithms explained.  The first one is an overview of what each algorithm does along with a picture of it.  The second one goes over some benchmarking/statistics of the various algorithms; very useful.

 

Final Thoughts

This book was worth the money I paid for it.  I don't think I'll be using anything I've learned in it immediately, but I know I will sometime down the road in my video game endeavors.  It's not a definitive source on mazes but a really good starting point.  I really would have loved some more chapters on maze solving.  One on interacting with the puzzles we generate would be cool too, but that falls more into game programming.  It has also done something for me that I've never expected; opening me up to Ruby.

It's been a while since I've read a programming book that wasn't overly dry.  Everything flowed nicely and kept me interested in learning what was coming next.  I really recommend reading this book if the subject matter sounds interesting to you.  It will be enjoyable.

 


Tags: Computer Graphics, Book Review, Ruby

Previous Page Next Page
This site uses cookies.