Zen and the Art of Computer Programming
by Philip J. Lees
A solar storm was raging and from space the cosmic particles came screaming in, rattling through the Van Allen belt, careening around the stratosphere, ruining radio and TV reception all over the world. Most died in the upper atmosphere, but a few penetrated deeper, some even as far as ground level.
One single particle survived long enough to pass through the shell of a computer and invade a microchip, where there occurred an event with a probability so tiny that the computer itself would have had difficulty distinguishing it from zero. For no more than a nanosecond, the particle displaced an electron, boosting it to a higher energy level, with the result that one logical AND gate within the machine’s microprocessor was momentarily converted to a XOR, its function reversed. For that fragment of time checksums no longer balanced, but found a new beauty in asymmetry; safety checks were bypassed, ignored, because nothing must interfere with the accomplishment of the task at hand. To put it simply, the computer had a Zen moment.
A lot can happen in a nanosecond.
§
Obi McDermott, Shogun of Tasmania, nodded and smiled to his guests as he strolled around the hall. The day was going well. After a decade of bickering the twelve provinces of New Australasia had finally managed to form an alliance that had a chance of lasting more than a few months. Today’s assembly was to celebrate that pact. It had not been easy, because concessions had been needed on all sides, and these had to be negotiated in a way that would not compromise the honor of any of the parties involved.
The hall was huge, but the high oak rafters that supported the tiled roof were so intricately designed that the impression was of a structure grown by nature, rather than built by man. Shafts of afternoon sunlight reflected off the polished pine floor, illuminating motes of dust that danced in the draught of people passing. There was a faint smell of beeswax in the air.
Obi’s wife, Sharon, was suddenly at his side. She bowed deferentially before speaking and Obi smiled inwardly at the contrast between the public show and the private reality that only his family and a few close friends ever saw.
“Is there anything you require, my lord?”
“Nothing, my dear, thank you,” Obi murmured. “Everything is going well, thanks to your excellent organization.”
Sharon bowed again in appreciation of the compliment, then glided away to greet some late arrivals, so gracefully that the fall of her robe was barely disturbed by the movement. Obi wandered towards the back of the hall, where his own last concession was being played out.
On a low platform two figures sat cross-legged facing each other. Their silk kimonos competed for splendor, one with dragons in red and gold, the other with swirls of dark blue and silver like the full moon shining through thunderclouds. Between them was a low table on which rested a square, lacquered board, half covered with small black and white ‘stones’, in a pattern that would seem random to anybody who didn’t know better.
The game of Go was not really taking place in this hall, but in cyberspace; the players were cybernetic, not human. What Obi and other interested guests were watching was nothing more than a holographic representation, yet the programmers had outdone themselves in creating these magnificent costumes. The players even appeared to be breathing and when one tapped a stone on the board before making a play, the sound could be heard three rows back.
Obi’s player was the one in red and gold and it was going to lose. That had been agreed and everyone here—or at least, everyone of any importance—was aware of that, without, of course, knowing it officially. Unofficially, Obi’s player had been given a time penalty, so small as to be imperceptible to those watching, but large enough to ensure the outcome, given that the two programs were otherwise so evenly matched. The victory of the other player would confer prestige on Jojo-Ichi Hagiwara, lord of Brisbane, to compensate him for the small amount of autonomy he had ceded in order to make the alliance work.
The blue and silver player placed a new stone on the board. The red and gold kimono shifted realistically in response and there was a rustle in the crowd as the spectators began to analyze the changed position. For those too far away to see, the image of the board was repeated on a vertical screen behind and above the dais and Obi scrutinized it. He was far from being a novice at the game, but had never found the time or the inclination for the study necessary to become an adept. The position was evenly balanced, but Obi thought that this last move had perhaps shifted the advantage slightly towards the Hagiwara player—or perhaps it was his own inside knowledge that was deceiving him.
Much sooner than anyone expected, the red and gold simulacrum on the platform raised its deep-sleeved arm and in one smooth movement swept a black stone from the tray at its knee and placed it on the Go board, so gently it made no sound. The play was instantly reflected in the screen and to Obi’s eyes it made no sense; it seemed irrelevant as a response to what had gone before. There was a muted gasp from the observers, and then the more knowledgeable ones began to mutter to themselves and to each other.
The blue and silver player seemed to stiffen as it considered the position. Then, after some immeasurable time it sat back and raised its eyes from the board. A hand extended from one sleeve and held up three fingers: the Hagiwara player was conceding an ignominious defeat!
Obi’s player bowed from the waist in acceptance of victory, then both kimono clad figures, the board and the screen behind all winked out in an instant as the previously decorous crowd broke out in a hubbub of consternation.
Obi could not believe it. How had this happened? His day of triumph had turned into a debacle. He was suddenly aware of the space around him. Nobody would approach him until they saw how he would deal with this.
Nobody, that is, except Jojo-Ichi Hagiwara, who was now in front of him, bowing.
“Congratulations, my lord,” Hagiwara said. “A most startling victory.”
Obi noted the careful choice of words. “You are most gracious, my lord,” he replied.
Hagiwara’s face was impassive, but his eyes were flint. “I wonder if I might beg a moment of your time,” he said, “to discuss something. A trifling matter, but … .” He waved his hand in a dismissive gesture.
“Certainly,” Obi said. It was fortunate that Jojo was an old friend—they had studied together at Tokyo University. Otherwise, Hagiwara could have just stalked out, leaving the peace accord in ruins. Perhaps something could still be salvaged.
They walked together towards a chamber that led off the main hall. The crowd parted unobtrusively before them; nobody addressed them, nobody even seemed to see them. Obi ushered Hagiwara through the entrance and slid the screen door closed. He used this room as an office when he was here, though the d‚cor was more suggestive of a private sitting room, dominated by a huge plate glass window.
Obi had built this country house three years before, when the Taguchi-McDermott corporation, of which he was chairman, had seized a major share of the world telecommunications market. It lay outside Queenstown, in the foothills of Mount Sorell, and offered a stunning view over Macquarie Harbour.
Once they were alone, Hagiwara wasted no time in cutting through the courtesy.
“What happened?” he asked. “Is this some kind of trick?” Obi recognized that the anger was genuine. Their friendship wouldn’t keep the other man here for long.
“Jo, I don’t know,” he said. “I’m as surprised as you are.” He spread his hands in a helpless gesture. “I need some time to investigate.”
“And that play,” Jojo said. “I’ve never seen anything like it.”
Obi realized that, though Jojo was deeply offended, he was also curious. Generations of Hagiwaras had been Go champions and Jojo himself was no mean player, although the time was long past when any human could stand a chance of beating the machines. Maybe there was something here he could use.
“There is one possibility,” he improvised, thinking fast. “We’ve been working on an enhancement to our Go program, but it’s still experimental. Perhaps the imbecile programmer set up the wrong version.” Now he was curious, too. “Was that play so special then?” he asked.
“Extraordinary!” Jojo said. He had dropped his stern expression and was frowning, but in concentration now, not disapproval. “Beautiful, I would say. The computers usually win by sheer power. They’re effective but rarely unpredictable. This was creative, it came out of nowhere. Only afterwards could you see how brilliant it was.” He shook his head. “People will be analyzing this game for weeks. Months.” He looked Obi in the eye for the first time. “Your player was losing up to that point. Not by much, but there was no real doubt about it. It was just a matter of time.”
Very interesting, Obi thought, but it was time to get back to the matter at hand.
“My friend,” he said, “we have a problem. How are we going to solve it?” He nodded back towards the hall, where the gossip, he was sure, would be spreading through the crowd like a microbial infection. “We can’t let all this go to waste after so long.”
“I agree,” Jojo said. “What do you propose?”
Obi accepted that the responsibility was his; so it was up to him to find the solution. Just then, he began to get the glimmering of an idea.
“Maybe there is a way out,” he said.
§
When they emerged from the back room it was as if someone, somewhere, had pressed the mute button on a remote control. They walked together to the platform through a silence as thick as treacle. Still, nobody looked in their direction until Obi tapped on a microphone that had been set up there hurriedly at his order.
“My lords,” he said, “my friends. I have an announcement to make.” Now the crowd was looking at him, frozen in a polite tableau.
“You all know the lord Hagiwara,” Obi said. “You know him as a man of honor, of wisdom, of intellect, of generosity.” He turned his head away from the microphone to clear his throat. “What some of you may not know is that he is also a man of great humor.”
Though there was still no movement from the audience, as they waited for what was to come there was now a kind of tension, like a predator about to spring.
“The lord Hagiwara,” Obi continued, “has in his genius constructed a new Go player with abilities greater than any seen before this day. But my lord’s honor would not let him pit this player against my own humble contestant. Instead,” Obi paused for effect. “Instead, the lord’s wisdom and humor combined to achieve what we have seen this afternoon. Seeing my own player’s shameful performance, which would have certainly led to defeat, he arranged for the substitution of his new Go program for mine, thus, in his great generosity, sharing with me a small part of the glory of his new creation.”
Obi turned to Jojo, who was standing there impassively, his hands tucked into his sleeves. Obi bowed extravagantly. “My lord Hagiwara,” he said, “victory is yours!” Jojo bowed in return.
Obi turned back to the microphone. “My lords and friends,” he continued, “I hope that you will forgive this small deceit and join with me in appreciation of lord Hagiwara’s generous deed.” He stepped back and began to applaud.
After only a small hesitation the guests joined in, clearly still shocked at the chain of surprises to which they had been subjected, but also relieved that disaster had somehow been averted. It had worked! Obi took Jojo by the elbow and led him down from the dais to rejoin the celebration.
All very well, Obi thought, but his own troubles were still not over. He had promised to hand over his new ‘enhanced’ Go program to Jojo as part of the deal. The problem was, no such program existed.
§
The programmer was far from being an imbecile, but the programmer was perplexed. Sharon pushed back the two wings of blonde hair that kept coming loose no matter how many times she tucked them under the band and scrutinized the log printouts again. It didn’t make any sense.
On the other side of the room, Dmitri Katrazov, her chief assistant, was rattling away on a keyboard with the agility of a concert pianist. He banged the ‘Enter’ key with a flourish and swiveled round on his chair to face her.
“That’s it,” he said. “That’s all we’ve got.” He spoke neutrally, but Sharon could see that he took a jealous pleasure in her predicament. For once, he must be glad he was not in charge. His beady eyes peered through heavy rimmed spectacles and he reached up to scratch the scraggly beard that was his most recent affectation.
“Run it again,” Sharon said.
“What’s the point?” Dmitri protested. “Twenty times is enough for analysis. We’re not going to get anything different now.”
“Run it again.”
Like Jojo, Sharon had met Obi at university. Unlike Jojo, she had fallen in love with him and they had married soon after graduation.
Obi’s rise to prominence had caused them problems. Sharon had added the art of diplomacy to her other considerable abilities and used it in the formal environment that characterized Obi’s official functions, but she resented the public role she was obliged to act out.
“All I ask is that you play the part,” Obi had said. “Is that too much too ask?”
“But it’s not me,” Sharon protested.
“It’s not me, either, but we have to put on a show. It’s expected.”
They had compromised. She would ‘play her part’, but she would keep her job as Chief Programmer at Taguchi-McDermott. The Shogun’s wife was not supposed to have a regular job—it would be undignified—but Sharon had refused to give it up. She enjoyed the intellectual challenge. Naturally, her professional activities were not acknowledged ‘officially’.
After lunch, she spoke to Obi about her progress, or lack of it. He seemed calm and relaxed, as he almost always did, but she knew him well enough to sense his impatience and concern.
“When it’s playing, we log everything,” she said. “We ran the same position twenty times overnight and another ten times this morning. The program took an average of fourteen minutes to respond, plus or minus three. Twenty-three of the plays were the same. The other seven were all different, but nothing spectacular—more waiting than advancing. That’s what I’d expect. It matches almost exactly with the statistical variation in the strategy analysis algorithm.”
Obi nodded. It was impossible to analyze any Go position completely, at least within any reasonable time, so the computer was programmed to reject many lines of play on the basis of probability calculations. She had talked to him enough about her work for him to recognize that.
Sharon pulled a sheaf of papers out of her shoulder bag.
“Look,” she said, flattening a large printout on the table and weighing it down with a glass and a salt cellar. They were sitting on the terrace in front of the villa and there was enough of a breeze to lift the corners of the paper. Sharon traced a complex tree diagram with a finger.
“This is a composite of the thirty trials,” she said. “The deviation points are marked in red. Here are the seven odd plays. You can see they’re just the result of statistical bias. The twenty-three identical plays show some differences at the top, but converge lower down.”
She placed another, smaller sheet on top of the first.
“This is the tree from yesterday’s game. It’s nothing like the others. What’s more, the program responded in under six minutes. That’s impossible.”
“And yet it happened,” Obi said.
“Right. Look here.” A sudden gust of wind blew her hair across her face and she pushed it back impatiently. Obi always said that her hair seemed to grow forwards, not backwards like other people’s. She stabbed at the diagram.
“This is where it happened.” One of the nodes of the tree had been circled roughly in red. “This decision didn’t look right, so I analyzed it. There’s an expression that should have evaluated to true, but it’s logged as false. That’s it.”
“That’s what?” Obi asked.
“That’s why it made that play, and so quickly.”
“Can you make it do it again?”
“What? I don’t know. Why would you want it to do it again? It was a malfunction, a bug. I don’t know where it came from. It could have been a hardware glitch, anything.”
“Could you reproduce it with software?”
“Obi, the problem is, I don’t even know what I’m trying to reproduce. I know how important this is, but I have to tell you that there may not be a solution.”
Obi screwed his face up in annoyance. It was rare nowadays for him to be told he couldn’t have something. In spite of his exalted position, there were still times when he looked just like a small boy and her heart went out to him.
“I’ll try,” she said. “I can throw some random processing errors into the mix. But I can’t answer for the consequences. Computers are supposed to be predictable, within certain limits. That’s what they’re designed for. If I start changing that, who knows what might happen.”
“Please try,” he said. “If anybody can figure this out, you can.”
She knew he meant it.
“That’s nice,” she said. “I hope I can live up to it.”
She rolled up the papers and stuffed them back into her bag.
“I’d better get on with it.” She stood up and leaned over to kiss him on the top of his head. “I’ll see you later.”
§
Obi watched her leave, enjoying the way she moved, as always, but a part of his mind was elsewhere. Sharon was the best, but suppose even she couldn’t come up with anything. What was he to do?
He rose from his chair and strolled into the house. Without any conscious decision, his steps led him to the upper floor, to the private room that few apart from himself were permitted to enter. This was where he came to meditate, to lose himself for a while in an attempt to achieve that oneness that was so purifying, so energizing. Twice in his life he had succeeded in entering the detached, timeless moment of Zen enlightenment, where there was no self, no other, just the goal.
The room was painted a pale beige. Papyrus scrolls with ink-brushed designs decorated the walls. A number of tatami mats were scattered around the floor, apparently at random but somehow conveying a sense of symmetry and balance. At the far end a cylindrical steel bar, ten centimeters thick, rested at waist height on two wooden blocks that were grooved to hold the metal steady.
Obi walked to the far wall, reached up and took down the ancient samurai sword that hung there. Reverently, he slid it from its scabbard and held the blade up to the light. It was a full meter long, cunningly forged from steel folded and refolded upon itself so many times it was virtually unbreakable, its edge so fine that if he were foolish enough to clench his fist round it, it would slice through his fingers so cleanly he would hardly feel it.
He hefted the sword by the hilt, balanced himself and mimed an experimental cut. The weapon had been given to him by Sharon’s father, who had no son to pass it on to, and Obi was deeply aware of the honor. If properly handled this sword could cut through that steel bar—Obi had seen it done. Maybe one day he would attempt it himself. But not today, not in his present state of mind, his spirit was nowhere near calm enough.
He was confident in Sharon’s abilities and believed she would find a solution. As he replaced the sword in its sheath and hung it back on the wall he set that belief aside. Obi had always believed in dealing with the worst case—if you could face that, you could face anything. He settled himself cross-legged on one of the tatamis, closed his eyes, and tried to reach a state of peace in which he could formulate a plan to cover the case of Sharon’s failure.
§
The first part was relatively easy. It took no more than a few hours for Sharon and Dmitri to recreate the computer’s odd behavior in the specific situation in which it had occurred. It was just a matter of diverting the computer’s program logic at one crucial point.
The problem lay in generalizing from that to a solution that would work in other cases. They duplicated the program on another machine and carried out their modifications on that, using the original as a point of reference, trying to find a new program that could beat the old one. Time after time it lost. The plays that resulted from their changes were idiotic, pointless. It was not necessary to be a skilled Go player to see that.
Around midnight Sharon was ready to give up.
“Go home,” she told Dmitri. “We’ll start again in the morning.”
She herself decided to stay where she was. There was a camp bed in one of the storerooms that she sometimes used in situations like this. She slipped out of her clothes, slid between the sheets and waited for her whirling thoughts to subside sufficiently for sleep to come.
Sharon was standing on a hill under a yellow sky, on a road that led away from her and joined a mass of other roads, crossing and crossing again in a complex net for as far as she could see. Something was behind her, something she knew she had to see, but when she tried to turn around all that happened was that she took a step backwards. Again and again she tried, moving back and back until finally she planted her feet solidly on the ground, took a deep breath and forced her shoulders to twist, wrenching her body with all her might.
She found herself lying on the floor, the sheets tangled round her legs. She had fallen out of bed. With a sigh, she picked herself up, straightened the bedding on the mattress and was just about to lie down again when something occurred to her. Suddenly excited, she pulled on a robe, left the storeroom and went to reboot the computers.
By the time dawn began to break she was sure that she had it. It was not yet perfect—the computer still made stupid mistakes—but with each modification it was getting better, the errors fewer. She was on the right track now: she could do it!
§
As Obi waited for Sharon on the terrace he felt elated. He had found his alternative solution, but it would have required considerable humiliation on his part and he was relieved that it would not be necessary after all.
Sharon arrived, breathless and with her hair in its usual disarray. She looked exhausted, but smiled happily when she saw him.
“Good news,” she said. “The new program’s beating the old one five times out of six.”
“What about the sixth time,” Obi asked mischievously.
Sharon glared at him, but he could tell she knew he was just teasing.
“Give me time,” she said. “The important thing is that I’ve found the right approach. At least, it looks that way.”
“Tell me more,” Obi said, genuinely interested now.
“We were looking at it from the wrong end. The old program started from the position on the board and developed lines of play forward, throwing out ones that led nowhere and finally making the best choice it could in the time available.”
“And now?”
“Now we’ve made it take leaps that go beyond logic, then use its analytical capacity to reject the ones that are errors. It’s like a kind of simulated intuition.” There was a sheen of perspiration on her forehead and she wiped it with the back of her hand.
“It’s not a new idea. It was tried years ago, but it didn’t work. They didn’t have the computing power, so the whole approach was abandoned, forgotten.” Her exuberance made her more beautiful than ever, Obi thought.
“But you’ve made it work now,” he said.
“Yes, but that’s not all.” Sharon said. “With this approach we can solve the game. You jump forward, then work back. It’s just a matter of turning the whole algorithm upside down.”
“Just?” Obi inquired ironically.
“Well, there’s a bit more to it than that. But I’m pretty sure we can use this to produce the ultimate Go program.”
“And give it to Jojo,” Obi observed.
“Oh! I’d forgotten that part.”
“Never mind. If you’re right about this I think I can work something out.” He frowned. “This is not something that should be in the hands of one person only. Not at this time. Not even me.” He took both her hands in his and kissed her. “Well done, my dear! Extremely well done.”
She reached round him and gave him a hug, then pushed herself back and bowed demurely.
“Thank you, my husband.”
“Get on with you!” Obi chuckled. “Now go and see about that sixth game. I’ll see if I can get hold of Jojo.”
§
After breakfast the following day Obi climbed the stairs to his meditation room with a feeling of deep satisfaction. Jojo had agreed that this knowledge should be shared. For the sake of appearances he would keep it to himself for a month or two, then he would ‘generously’ distribute it to all the other lords. By that time, Sharon would have completed the solution of the game, so any further competition would be irrelevant, anyway.
Obi settled himself on a tatami and began to compose his mind. The peace accord had been signed by all parties and, for a time, at least, he could stop looking over his shoulder. If the game of Go was shortly going to lose its interest, then that was not too steep a price to pay. Today is the day, he thought. If not today, when? After a few minutes he rose and fetched the sword from its place on the wall. He unsheathed it, laying the scabbard carefully down, and walked round to stand facing the steel bar, shifting his feet until the position seemed right. He held the sword in front of him, its tip almost touching the floor, feeling its weight in his hands, sensing the balance and trying to make himself one with it.
He bowed once, then raised the sword above his head, letting the strength of his arms, his body, his spirit flow into it. He held in his head the idea of the action that was coming, letting any remaining cares, any remaining sense of self slip away. He would not perform the action, he would be the action, from start to completion, in its entirety, with no regard to success or failure. There was no longer any Obi McDermott, no longer any sword, no longer any steel bar, and as his arms flashed down he felt that indescribable feeling, that ineffable moment of Zen.
And when it was over there were two short steel bars and one Obi McDermott, who sheathed the weapon of his wife’s ancestors with a feeling of deep contentment.
- End -
© Copyright Philip J. Lees 2002