It was only about twenty meters to the first branching. Basil strode into the hedge maze purposefully, humming gleefully to himself the entire way. Fabian followed reluctantly, glancing furtively about as he dragged his feet along the gravel path. The tall, green hedges seemed to swallow all sound, leaving them cocooned in a still, nearly-silent world where all they could hear was the crunch of their feet on the gravel and a bare whispering of the wind as it writhed through the tops of the hedges.
Basil reached the branching first and spun smartly on his heel, military-style, to face his manservant. His white lab coat billowed around him.
“All right, Fabian,” he said, clapping his hands together sharply. “Your first lesson in wizardry! Which way should we go?” He gestured with both hands, indicating the passages to left and right.
Fabian looked up dolefully. “What’s that, sir?”
“Which way? Choose a path. Let’s see how quickly you can get us out of this maze.”
“You want me to choose?” His narrow, pinched-looking face expressed surprise. “Very well, sir. I choose that way.” He pointed behind him, back up the path they’d come, toward the large cast-iron gate at the entrance. “That would seem to be the fastest way out.”
Basil rolled his eyes. “Oh, very droll, Fabian. Very droll, indeed. Now, will you please be serious for a moment and work with me, here?”
“Oh, believe me, sir, I’m in all earnestness.” Fabian sighed resignedly. “But as you wish.” He looked along the two branching paths, both running at right angles to the path they’d been on. Each seemed to run another twenty meters or so before turning out of sight. “I confess, I’m not sure which to choose, sir. I’ve, um, never been particularly lucky with mazes.”
“Ah, here now! We need to stamp out that misconception right away,” Basil said, waggling his bushy caterpillar eyebrows. “Luck doesn’t play into it at all. Never has. Luck is merely the lazy man’s excuse for another’s success.”
Fabian seemed skeptical. “How lucky for me that you’re here to set me straight, then, sir.”
“Yes, quite.” Basil said, and then looked suspiciously at his manservant, eyes narrowed. After a moment, he shook his head dubiously and took a deep breath, blowing out his great, white mustaches. “Let’s just see how this unfolds. Go on, then, choose a direction. No more silliness.”
Fabian sighed, but nodded. “Very well, then. No more—ahem—silliness. In that case, I choose…hmmm. Left.” He pointed toward the named passage.
Basil nodded wisely. “Ah, left! Lovely!” He stared a moment down the passage to the left and stroked his mustaches, still nodding. “I’m curious why you chose that one.”
“Because you forbade my first choice, sir.”
“No, no, no. I mean, why left instead of right?”
Fabian paused, glancing down the path to the right. It still looked identical to the other. “Just feeling sinister, I guess, sir.”
Basil raised an eyebrow. “You are droll today. But I must insist. Why left?”
Fabian shrugged. “I just chose at random, sir. Both directions seemed equally…ah…tempting.”
Basil nodded again. “At random, then. And when we arrive at the next branch in the path? What then?”
Fabian frowned, surprised by the question. “I’ll admit hadn’t thought that far ahead, sir. I suppose I’ll just look and see which path seems most tantalizing.” He waggled his fingers expressively.
Basil tsked and shook his head, setting his voluminous mustaches waving like foliage in a stiff wind. He pointed a finger dangerously at Fabian. “No, no, no! You’ve got to have a plan! Without a plan, you’re nothing better than a mouse. Worse than a mouse! Here, now. Your first lesson. It’s time to introduce you to algorithms.”
Fabian raised an eyebrow. “‘All-go rhythms’?” He looked suddenly apprehensive. “That’s not a dance of some kind, is it, sir?”
Basil stopped mid-breath, mouth open. After a moment he closed his mouth and considered, stroking his mustaches. “Actually, hmm. Yes! That’s as good a place to start as any.”
Fabian looked alarmed, but Basil ploughed on, oblivious. “Tell me, Fabian. How would you describe dancing?”
Fabian blushed. “In my experience, sir, it’s an activity that happens to be particularly effective at making one look an utter fool.”
A look of bafflement settled upon Basil’s bushy brow. It seemed entirely too comfortable there, so after a moment a look of dawning comprehension shooed it away.
“There was a girl, wasn’t there?” he said.
Fabian’s pointed goatee quivered in a flash of panic, but he mastered it quickly and shrugged. “I’m sure I don’t know what you mean, sir.”
Basil paused, considering. “Never mind. Let’s just say that a dance is a series of steps.”
“If you say so, sir.”
“These steps are performed in a particular order.”
“In order. Yes, sir.”
Basil paused, eyebrow raised expressively. When Fabian failed to react, Basil sighed. “Do you see what I’m saying?”
Fabian glanced up and down the passage and casually scratched an itch on the back of his hand. “A dance is a series of steps, performed in a particular order. Thank you, sir. I feel particularly illuminated.” He coughed. “But pardon me for wondering: how does this relate to finding our way out of this maze?” His brow furrowed in consternation. “I do hope you aren’t going to suggest that dancing is the solution, sir.”
Basil laughed. “Dancing is always a solution, old boy!” He clapped Fabian on the shoulder. “But perhaps not always the best solution, no. My point was not to suggest dancing our way to the exit, but to give you an example of an algorithm. Consider another example. Hmmm.” Basil thought a moment. “Perhaps my library, back home. You’re in there cleaning it up at least weekly, yes?”
“At least weekly, sir. Yes.”
“Very well. And when you clean the library, do you simply ‘make it clean’?”
“… I’m not sure I follow you, sir.”
Basil thought a moment. “All right, put another way: how do you clean the library?”
“Well, sir, it’s a lot of things.”
“Oh, dusting, shelving books, cleaning the rug, mopping.” Fabian stopped a moment, looking thoughtful. “Oh! And removing dirty dishes. And then there was that time I had to wash the food stains out of—”
“Yes, yes, very good. You’ve made your point. But you’ve also made mine. Those different tasks form an algorithm. When you undertake to clean the library, you break that higher-level task down into smaller tasks which, when combined, have the effect of making the library clean. Divide and conquer! Yes?”
“Yes, sir. And I think I begin to see your point. I suspect you’re going to suggest that solving a maze can also be broken down into a series of steps? That there is an ‘algorithm’ of some sort involved?”
“Very good, Fabian! You’re catching on.”
“Incredible.” Fabian said to himself. “This would have saved me so much trouble…”
“Ah, nothing, sir. Just, ah, remarking that mazes seem like so much trouble.”
“Well, yes, but that’s the joy of them, isn’t it? They’d hardly be worth the bother if they were easy. But when you know the trick, suddenly it’s no longer mysterious. In fact, I’m going to tell you the First Great Secret of Wizardry. Are you ready?”
Fabian looked dubiously at Basil, as if he could hear the Capital Letters and feared their significance. “I have no idea, sir. How should I be bracing myself?”
“Pay attention, now. This is important.”
“The First Great Secret of Wizardry, Fabian, is just this: There is no magic.”
“That hardly sounds…wizardly.”
“Precisely! That’s the point, Fabian. Magic is only magic from the outside. Once you know how it works, the mystery fades, and all that’s left is sweet, sweet comprehension. Understanding! Insight! Discovery. You collect the obscure, and from it, distill the obvious.”
“I see. And how does one do that, sir? Distill the obvious?”
“Algorithms, my boy!” Basil beamed at his manservant. “Always algorithms! At the most fundamental, you start with a larger task, and then proceed to break it down into smaller tasks. Give it a try. You’re in a maze, Fabian. What’s the first step to take? What’s your plan? What’s your algorithm?”
Fabian’s mind was whirling from all he’d heard. He hardly felt up to tackling this problem at the moment, but his master was not always a patient man. “Well, sir, I’m guessing ‘choose a passage at random’ isn’t one—”
“On the contrary,” Basil said, smiling eagerly. “That is perhaps the simplest one of them all. Some call it the ‘random mouse’ algorithm. Any time you have to make a decision, just choose one at random! Simple. But not very effective. In fact, you can’t even be sure that such a strategy will ever get you to the exit, since if you’re choosing truly at random, you might wind up going back and forth forever!”
“It sounds like choosing wisely would be a better option, then, sir.” Fabian said as he eyed the two passages again. “What if… Hmm. What if you always choose a path that takes you closer to the exit?”
Basil nodded, pleased. “Better, yes,” he said. “That would improve the algorithm, for sure. This kind of improvement—when we add some reasoning to the process—is called a heuristic. But it requires some knowledge about the maze, doesn’t it? For example, how would you apply that heuristic here?”
Fabian paused, looking left and right, and finally shrugged. “I’m…not sure, sir. Moving away from the entrance would seem to be a good first step, but in this case…neither choice clearly moves us further from the entrance than the other.” He paused again. “If I may be so bold, sir, perhaps you should just tell me what you suggest. Speaking from experience, we could be here for days if you leave it all to me.”
Basil was silent a moment, stroking his mustache as he eyed Fabian thoughtfully. “No,” he said at last. “Not yet. I’m confident that you can figure this out. You’ve surprised me before.”
“Right,” Fabian said drily. “Like the time you told me exactly what to say and do, and I still managed to turn myself into a newt?”
Basil smiled. “That did surprise me, yes. But actually, I was thinking of what came after. When you figured out how to undo the transformation. By yourself.”
Fabian was silent.
“You’re stuck on that ‘random mouse’ algorithm,” Basil explained. “Your heuristic is merely an incremental improvement to it, and it’s not clear how to apply it in every situation. Maybe it’s time to try another algorithm entirely.”
Fabian remained silent, but cocked his head as if thinking.
“Here, let’s try helping you visualize things a bit.” Basil reached into his lab coat and withdrew an old, battered pencil. It looked vaguely gnawed-on, with a once shiny-blue finish now marred by various tooth marks. It was scuffed and scratched, dented and defaced.
And it thoroughly terrified Fabian. He immediately paled and stepped back.
“Oh, man up, Fabian,” Basil said, rolling his eyes. “You’ve seen this before.”
“Precisely,” Fabian said, eyeing the implement warily. “You’ll recall that the last time I saw it, I wound up a newt.”
Basil huffed through his mustaches, setting them fluttering. “You’re going to have to get over this eventually. Sooner or later you’ll need to choose a wand of your own, you know.” He tsked. “Anyway, I’m not asking you to use it. Just to watch. It’ll be a good spell for you to learn, actually. Pay attention.”
Fabian nodded, but didn’t get any closer.
Shaking his head, Basil drew a circle in the air with the pencil, and immediately a loop of sturdy brown twine appeared.
“There,” Basil said. “A circle, right? More or less?”
Fabian nodded cautiously.
“Now, I’m going to suggest this is exactly the same thing as a maze.”
“Rather an empty maze, if I may say so, sir.”
“Indeed. But you’ll see it in a moment. First, let’s add some ribbons to indicate the entrance, and the exit of our trivial little maze.”
Basil rapidly sketched a couple of ribbons, one green, and one red.
“All right. First, then, I want you to imagine that you’re inside that circle, standing by the green ribbon, and it is completely dark. Assuming you didn’t know where on the circumference the other ribbon was, how would you find it?”
Fabian looked at the loop of twine hanging in the air before him. “I suppose I’d just follow the loop until I got to it, sir.” He pointed along an arc of the circle, indicating the path he proposed to take.
“Very good! Exactly. Now, what if I were to make a bight in one side of the loop, like this?” He caught the bottom of the loop on his pencil and dragged it up, forming an inverted U. “Now you’ve got a wall between you and the other ribbon.”
Fabian shrugged. “It doesn’t matter, sir. I can still follow the twine, same as before, and get to the ribbon.” He traced the path again with his finger, following the bend in the loop.
“All right. What if I add a kink in the bend, tipping it over a bit? Any problems now?” Basil tapped the top of the bight with the pencil and gently bent it to one side.
Fabian shook his head. “It still doesn’t matter, sir. It doesn’t prevent me from following the twine to get to the other ribbon.”
“One more try, then. What if I were to add some more bends to the top of the loop, pulling them down to distract you?” Basil waggled his bushy eyebrows as he again tapped the loop with the pencil, this time dragging the twine down from the top and forming two more U bends.
Fabian laughed. “It still doesn’t matter! I think I see it, sir. A maze is just a circle that has been all bent out of shape, yes? All the walls and twists and turns are just kinks in the loop?”
Basil said nothing, but waited, smiling.
“If that’s true,” Fabian said hesitantly, almost to himself, “then it should hold for this maze.” He gestured at the hedges around them, and laughed again. “Which means… We just need to follow a wall, don’t we, sir?”
“Yes!” Basil said triumphantly, eyes twinkling. “You’ve got it, exactly!” He tapped the loop again and it disappeared, breaking into tiny motes of light before fading away. “Now, I’ll warn you: there are some kinds of mazes where that’s not the case, but I won’t bother you with those just yet. Assuming we’re in the kind of maze that you just described, though: what would you suggest we do now?” He paused expectantly.
Fabian got up and looked at the passages again. “It really doesn’t matter which path we choose, does it?” he asked. “All that matters is that we consistently follow the same wall, whichever way it goes.” He laughed suddenly. “Oh, I’m such a fool! Very well, sir. I choose left. Again.”
Basil laughed, too. “Left, again! This time, I’ll agree with you, because I can see you’ve got a plan. Let’s see if it gets us through!”
Fabian tentatively set his left hand to the hedge and glanced back at Basil. “Yes, sir! If I’ve understood this correctly, following this wall ought to do it.” He took a deep breath. “Here we go!”
They began walking, then. And walking, and walking, and walking. They followed paths. They retraced their steps. And then they walked some more. Fabian seemed invigorated, laughing at each dead-end, moving faster and faster with each bend in the path, until Basil was nearly jogging to keep up. So it was that, winded and exuberant, the two finally reached another large cast-iron gate, much like the first, but this time labelled “EXIT” in curly black letters.
“Well done, Fabian!” Basil said, puffing slightly. “You did it, old boy!”
“I did, didn’t I?” Fabian said, seeming slightly dazed. “I had no idea it could be so simple.”
They paused by the exit, sitting with their backs to the hedge, and rested a moment. Basil gestured at the path they’d taken. “That algorithm you used,” he said. “It’s called ‘wall-following’.”
“That’s…an unexpectedly obvious name, sir.”
“See? You’re already learning that wizardry isn’t all misdirection and obfuscation. Wall-following is a great example of how straightforward it can be.”
“That was wizardry?” Fabian looked perplexed. “I can see how making a bit of twine dance in the air would qualify, but following a wall hardly seems like magic…”
“I already told you, Fabian. There is no magic.”
“Says the man who drew twine in the air with his lucky pencil.”
“See? That’s exactly what I mean.” Basil wiped his face with his hand and puffed out his mustaches. “To you, that was magic. You can’t imagine any other explanation. But what if I were to tell you that you only saw it because you believed it was there?”
Fabian started to say something, changed his mind, and then looked thoughtful. “Why would I want to believe it was there?”
“It’s not about whether you want to believe or not. It’s about believing. I made a suggestion and started drawing with the pencil, and you believed.”
“So, you didn’t see the twine?”
“Oh, I saw it, too. But only because I chose to see it. Do you understand what I’m saying? There is no magic.”
Fabian shook his head and sighed. “Yes, sir. No magic. Distilling the obvious, and all that.” He paused, and then said, “Still, one does not become a newt by cleverly following a wall…”
“You might be surprised, Fabian,” Basil said, smiling. “Not all walls are simply hedges. You can find yourself in surprising places, if you only follow the right walls.”
“Please don’t tell me you feel a song coming on, sir.”
Basil rolled his eyes. “No songs, Fabian.”
“But now you’re going to tell me that this ‘wall-following’ thing is a metaphor for all of wizardry, or something?”
“In some ways, perhaps. It’s not necessarily the most efficient algorithm, but if nothing else, you can trust it to get you out of a maze. Guaranteed! Well, most of the time.”
“Guaranteed, ‘most of the time’?” Fabian raised an eyebrow.
“Right. Remember I said that the ‘mazes-are-deformed-circles’ assumption only holds for certain kinds of mazes? For those mazes it’ll work every time, because there is only a single path—or solution—between any two points. But if a maze has more than one solution—if there are any ‘cycles’ in the maze—it can fail you.”
Fabian looked confused. “Who would ride their bikes in here?”
“Not bicycles, Fabian. Cycles. Loops. Paths that intersect themselves. Look here.” Basil traced a rough maze in the dirt by the side of the path.
“This is what is called a ‘perfect’ maze, which just means that there is only a single path that goes between any two points. No loops, in other words. But now let’s erase one of the walls, like this.” He rubbed one of the lines out, joining two adjacent paths.
“Now you get a loop. It’s no longer a perfect maze. And wall-following a path through such a maze could take you in circles, if you follow the wrong wall.”
“Ah, I see. So…” Fabian gestured to the hedges around them. “How did you know there were no loops here, in this maze?”
“I didn’t!” Basil said, and then laughed at the look of consternation on Fabian’s face. “If there had been, we would eventually have noticed we were going in circles, and then I would have gotten to teach you the algorithm of the great wizard Tremaux.”
Fabian shook his head. “I’ve got a lot to learn, haven’t I?”
Basil laughed. “We all do, my boy! We all do. Now, let’s see to the Castle.” The wizard stood up, dusted himself off, and walked to the gate.
Fabian was dusting himself off as well when he heard a mutter. “What was that, sir?” Fabian asked, walking up to him.
“I said, ‘oh, bother.’ Look.” Basil gestured out the gate.
Fabian turned to look. The gate opened onto a couple dozen steps leading downward, and from thence into another hedge maze even larger than the one they had just traversed. From where they stood they could see over the tops of the hedges, all the way to a small castle about a half mile distant. The passages of the second maze were laid out like a map before them.
Fabian shrugged. “Maybe you’ll get to teach me Tremaux’s algorithm after all?”
Basil clapped him on the shoulder and sighed. “Normally, I’d leap at the chance, but I’m in a hurry now. My old bones are calling for a bit of rest after all this walking. I think…” He furrowed his brow and stroked his mustaches thoughtfully. “I think it might be time to show you some more powerful tricks.”
Fabian thought of newts, and groaned.