Refactoring Challenge – The Amazing Maze

“Amazing” is a maze generation program from the book BASIC Computer Games, by David Ahl. (The maze program was created by Jack Hauber). The code is used with permission of David Ahl, www.SwapMeetDave.com.

Alan Hensel mentioned using this program as inspiration for a refactoring exercise; I remembered it fondly from my BASIC days, so I thought I’d convert it to Java.

I found the original code pretty much incomprehensible: most lines consisted of an assignment and a two-way branch.

Your mission is to refactor this to a program that can be understood. You can’t do everything with automated steps, but to do it properly you have to take tiny, safe steps. Here’s the code: Amazing.zip.