Talks
Twisty Little Passages

Twisty Little Passages

by Jamis Buck

In the presentation "Twisty Little Passages," Jamis Buck explores the joy of programming through the lens of maze generation algorithms. He discusses his journey to rediscover the excitement in coding, focusing on the elements that make coding enjoyable and engaging. The session highlights a variety of maze algorithms, visualizations, and the creative potential in programming. Buck seeks to inspire others to find fun in coding by experimenting with different algorithms and visual approaches, especially in the context of generating unique mazes.

Key Points Discussed:
- Rediscovering Enjoyment in Programming: Buck shares his experience with programming burnout and emphasizes the importance of finding joy in coding as a remedy.
- Intellectual Challenge: He notes that coding should be intellectually stimulating without being intimidating, using the example of ray tracing and its complexity to demonstrate this.
- Rapid Feedback Cycle: He stresses the value of quick results that come from small code changes, particularly through examples involving fractals and mazes.
- Visual Appeal of Projects: Buck highlights how sharing visually appealing projects, such as fractals and mazes, can enhance enjoyment and engagement.
- Focus on Mazes: He identifies mazes as a fun project due to their balance of challenge and accessibility, showcasing how simple algorithms can produce varied and interesting results.
- Demonstration of Algorithms: He presents several maze generation techniques, including the binary tree algorithm and the growing tree method, illustrating each with live coding demonstrations.
- Varying Cell Structures: Buck explores the creative potential of using different cell shapes, such as hexagons and polar grids, to produce unconventional mazes.
- Spherical Mazes: He introduces generating mazes on spherical surfaces, showcasing the complexity and artistic possibilities in programming.
- Real-time Visualization: The immersive experience of flying through the generated mazes highlights the creativity and beauty of algorithmic design.

Conclusion and Takeaways: Buck concludes by emphasizing that while programming may pose challenges, it can still be a source of fun and exploration. The essence of programming lies in the joy of creating something new, and by sustaining the playful spirit, coders can rejuvenate their passion for engineering and exploration through coding. In this session, Buck ultimately reminds viewers to embrace their creativity through the imaginative world of mazes and algorithms.

00:00:08.960 I'm going to talk about "Twisty Little Passages" and rediscovering the joy in programming. How many of you have had fun programming in the last week?
00:00:13.000 Awesome! I love it! How many of you had fun writing code yesterday? A few more hands. Not everyone? Okay, that’s okay; you can’t enjoy it all the time.
00:00:24.000 For me, it's been a journey. Actually, before I go any further, I need to do a shameless plug. As Mike mentioned, I am writing a book called "Mazes for Programmers," and I have a free electronic copy to give away.
00:00:36.000 It’s not going to grace your bookshelves or anything, but if you're interested in this book—and you should be, because it’s awesome—let me continue.
00:00:45.000 Over the past year or so, I've really started feeling burned out on writing code. How many of you have ever felt burned out on coding? Yeah, it’s not a good place to be, and it’s really kind of scary, especially if coding is your livelihood.
00:01:01.000 It's a tough spot to be in, and I struggled with it for a long time. I discovered that in order to conquer that burnout, one of the things I had to do was rediscover what made programming fun and enjoyable for me. That's been my journey over the past year.
00:01:15.000 What makes coding fun for you? I don’t know what’s going to be fun for everyone, but here are some things I particularly enjoy.
00:01:32.000 First, it has to be intellectually challenging but not intimidating. For example, I went through a period about ten years ago where I wrote a ray tracer. How many of you have ever used a ray tracer? A few hands. How many of you have written a ray tracer? A few more hands. You’ll know what I mean when I say that it can be intellectually challenging but also a little intimidating.
00:01:53.000 Especially when you start moving beyond spheres and want to do things like parametric surfaces. After you've ray traced a dozen spheres, the joy does start to wear a little thin. But fractals are where the excitement lies. How many of you have played with fractals, like iterated function systems? Those are always refreshing to experiment with.
00:02:16.000 Another important factor is a rapid feedback cycle. You can't spend days getting to where you have something to show; you need something quick and easy to experiment with. Fractals fit this perfectly—one little change can yield a totally different result.
00:02:30.000 Also, if the project is visually interesting, that helps a lot. If I can share it with others, that counts too. I enjoy showing my family different projects like my ray tracing work. It’s exciting to get a sphere reflecting a checkered plane, but my kids often don’t grasp the nuances, whereas they might appreciate something colorful like a fractal.
00:02:57.000 I've worked on various projects like ray tracers, fractals, generators, Celtic knots, and programming languages. Today, I'm going to focus on mazes because they tick every box on my list for enjoyment.
00:03:07.000 Mazes are challenging but not intimidating. You can accomplish a lot with very simple algorithms that scale up to more complexity. The best part is that every time you run the maze logic, you get a different result and can adjust it easily.
00:03:36.000 What’s intriguing is how randomly generated mazes can be visually interesting and immensely shareable. For example, I created a maze on a Möbius strip the other day, and my seven-year-old spent hours tracing the path.
00:03:48.000 So now I'm going to dive into some code while holding this mic, which presents an interesting challenge.
00:04:02.000 What we have here is a binary tree algorithm. It works by creating a 10 by 10 grid of cells, and then, for each cell, it randomly links to its north or east neighbor.
00:04:29.000 If you run this, you will get a maze—the simplicity and effectiveness of this approach is part of what makes it enjoyable and accessible.
00:04:49.000 One thing I absolutely love about these projects is the ability to adjust various parameters. Let’s change the maze size from 10 by 10 to 40 by 80. Then when we run it, we get another maze seamlessly.
00:05:12.000 I can also modify the algorithm and change the directions we choose from north and east to south and east, modifying the texture of the maze drastically.
00:05:38.000 Another interesting method of altering our maze could be to prefer one direction over another and see how that changes the overall feel.
00:06:07.000 For instance, what if we prioritize south more heavily by adding it multiple times to an array? We can then visualize how that changes the dynamics of the whole maze.
00:06:30.000 This creativity builds a game of possibilities, prompting questions like 'What if I change this?' or 'How can I make the maze behave differently?'. This is the beauty of the algorithm.
00:06:42.000 There are other ways to vary the maze, too; we can change the way it’s displayed. Instead of just rendering walls as lines, what if we showed them as blocks? It gives a completely new perspective.
00:07:02.000 We can even change the thickness of these walls or highlight them in different colors to play with aesthetics and algorithm outputs.
00:07:29.000 Let’s consider another algorithm called the growing tree, which establishes a list of inactive cells and starts linking cells in a random manner until all have been visited.
00:08:00.000 What's exciting about this method is the ability to experiment with the pathways by selecting seeds randomly.
00:08:08.000 For instance, if we mix random selection and last chosen cells, we can visualize two mazes side by side and see how their structures differ.
00:08:40.000 As we move forward, let’s iterate on the results and change the seed selection strategy further. With these modifications, we explore how varying the algorithms affects the overall maze structure.
00:09:05.000 The two methodologies yield different mazes, demonstrating the artistic nature of coding through algorithmic exploration.
00:09:30.000 Now, why restrict ourselves to square cells? Let’s use hexagons or octagons, even polar grids, and see how these alternative patterns affect maze generation.
00:09:54.000 With a polar grid of nested circles, if we apply our algorithms, we can create unconventional mazes that intrigue the mind.
00:10:12.000 Now let’s return to spheres. The ability to take the flat polar grid and wrap it creates opportunities for generating spherical mazes.
00:10:40.000 Using the same growth method, we can generate a maze on the surface of the sphere. This presents an exciting challenge.
00:10:58.000 We can visualize these mazes with Dijkstra's algorithm to observe the paths on this newly created surface.
00:11:24.000 Next, let’s increase the maze's complexity and scale, increasing resolution and reflecting on how altering parameters can give rise to art.
00:11:40.000 With a larger grid, the mazes reveal their intricacies more vibrantly as we explore render options and how they change the maze presentations.
00:12:00.000 We can even experiment with colors or manipulating how the viewer perceives the maze, creating an immersive experience.
00:12:26.000 As we animate these processes, we get to see how the maze evolves in real-time, adding excitement to our exploration.
00:12:53.000 This fluidity keeps me enthralled—seeing how these algorithms develop and transform our understanding of programming.
00:13:11.000 As we fly through the surface of the sphere, we come face to face with the fruition of our coding, allowing everyone to visualize the outcomes of their creativity.
00:13:38.000 As we walk through the maze we’ve created, the immersive experience becomes apparent. I appreciate the simplicity with which we can navigate and get lost in our own creations.
00:14:00.000 The idea of swooping in allows us to emphasize the potential of our digital mazes and where they can lead us. The frantic excitement has a touch of chaos.
00:14:28.000 If we can engage our algorithms, every pathway opens up a new journey, which feels reminiscent of the programming we once did for fun.
00:15:00.000 While this may not solve all problems or cure all burnout, it serves as a reminder of why we started coding—to explore fun and creativity.
00:15:30.000 By keeping the playful spirit alive, we can infuse our daily work with the joy of exploration.
00:15:55.000 Remember, the thrill of programming often originates from the joy of creating something new. So, in the spirit of these mazes, don’t be afraid to explore.