Member-only story
Build Mazes With SwiftUI
Use the power of Combine and SwiftUI grids to create a maze in your SwiftUI app
I was looking through The Pragmatic Programmers’ bookshelf for weekend reading and stumbled across Mazes for Programmers by Jamis Buck. As I read the description (“Remember when programming used to fun?”), something clicked inside me. Yes, I recalled it is fun, but then I realised the code illustrating the algorithms was using Ruby, a Python-like language I don’t know very well.
As I looked through the book, all the algorithms are described as well illustrated in code. I decided to try to rewrite them in Swift.
Just before I jumped in with both feet, I made a backup plan and did some quick research. You can seemingly embed Ruby within Swift (the technique outlined in this article “Swift & Ruby Interoperability” by Marcio Klepacz). I contemplated using such wizardry for a moment, but being a purist at heart, I decided to take the long road. The fun one.
Before I start, I want to give a quick nod to Jamis, who helped out a little with this article.
Programming Mazes
To the book then. It tells you how to build mazes and describes the algorithms required to do so. Jamis covers a half-dozen ways to build ever more complex mazes and more…