Now that James had gained some experience putting spells together, Barry finally gave him a book that was actually about spell construction. James dove into it with eager glee. Spell-crafting was feeding his hobby of programming, and at the same time constantly exercising his knowledge of physics and chemistry, to the point that he had returned to making a little time every day to study in the books from his original world. They also fed the puzzle-building and solving urge that had grown in him as a direct consequence, he felt, of all of Barry's little tests. He was still in awe of the way Barry kept coming up with new tests and challenges.
His enthusiasm waned rapidly, however. The book was focused on a sub-division of spell research that was built around numerology, a pseudo-science that had been so thoroughly debunked in James' world that he really could not give it any credit. It was like a third grader's idea of math, assigning importance to individual numbers in their own right. Sure some numbers might have more use than others, such as prime numbers and the like, but by the same token, it had only addition and subtraction as concepts, negatives were not present, decimals were unmentioned, fractions were nowhere to be found. Irrational and imaginary numbers were far beyond the pale.
It was almost as if they thought any spell could be composed merely by adding and subtracting whole numbers. Now, in point of fact, James did know enough of modern math to know there was something to this, Gödel's Incompleteness Theorem depended on turning symbology into numbers to allow proofs to be referenced by other proofs, and eventually to be self-referential, which was, assuming he was remembering this all correctly, the key component to proving the incompleteness - basically using Gödel numbers to build the equivalent of a statement that claimed its own falsehood, and therefore could not be proven either true or false.
But really, you only did that to prove a point, no-one wanted to actually work with numbers in that way, and even if they did, how did you know what the transformation from algorithm to Gödel number went? As far as he could tell, the methods taught in this book came from people who quite clearly did not know what the transformation was. Instead, they had some technique that, and this was not clearly specified so he was unsure of his interpretation, either parsed a spell into these strung together numbers, or at least guided a search process into converging on the correct set of numbers for a spell.
In the absence of a real underlying theory, they made assumptions about the types of numbers to add based on attributes of the individual integers, by analogy to smaller bits of working spells, and by trial and experiment. Part of the problem, of course, was that numerology, lacking any formal means of proof or disproof, admitted many more varied meanings for numbers than modern mathematics. Math could tell you a number was prime, or a perfect square, or a perfect number (oddly a different meaning than perfect square), or a variety of other more or less silly attributes, such as friendly, amicable, and so on - but all based on some mathematical definition, such as how many factors a number had, or whether they added up to something interesting, or had other interesting patterns.
Numerology, on the other hand, mixed in theology, which varied from group to group, and other oddities, such as ideas derived from plane geometry and whether a number could be defined in a certain number of graphing motions, and odd ideas of the power of repetition, wherein one number could be broken or improved by being repeated a number of times tied to a different number.
By all rights, none of it should work at all. There should be no way to string together an arbitrary series of numbers and have that mean something in magic. Even Gödel numbers meant nothing without a mapping, a translation between the symbols of a specific formal system and the natural numbers, and how could magic have such a mapping independent of someone first devising it?
Yet apparently it did work, and he puzzled over this, and reread the book, much to his disgust, over the next two days, trying to work out a sensible way in which this numerology could be allowed to operate without requiring him to believe in something so patently ridiculous. Eventually, he had to concede that there was no logical constructive way to manage it, so he instead chose to believe that it worked solely because they themselves, in researching the numbers, built up a belief in their minds about what the spell would do, and as they worked towards an implementation, were actually honing their understanding until it allowed them to convey that understanding to magic, whereupon the whole process of repeated casting made the connection steadily stronger and stronger.
That thought lead to another interesting sideline. Perhaps it was true in worlds that operated in that basic fashion, especially those with any form of centralized schooling, that common spells were easy, and rare spells hard, precisely because they were common, or rare. A common or widespread spell would become, by this way of thinking, steadily easier to cast, as it became more patterned and people slowly came to expect more similar results, as each generation's training went through a sort of bottleneck due to the smaller number of teachers versus students. By the same token, commonly used spells would be more restrictive in actual use, since the variables left open in them would become patterned, and more and more would take on the same values.
This then might also explain the ridiculous number of highly specific spells common to such worlds, based on his reading. As a spell became more common, and thus more specific, its uses grew slowly more restricted, and those spell-casters sufficiently skilled to create or tweak spells would make more general variants to accomplish more varied goals, only for these new spells to go through a similar narrowing process. The only truly broadly potent and malleable spells would be wholly new spells, or spells so ancient that their patterning had been degraded or lost with time and lack of use, so that they were effectively new.
That same pattern would make dimensional travel extremely dangerous for such wizards traveling anywhere beyond their own close neighborhood unless the wizard was so powerful that supplying the extra magic to overcome the sudden increase in the degrees of freedom of a spell would not bother them.
His own custom designed spells should hopefully fare better in such a situation, since they had no extra degrees of freedom to suddenly go wild, though if he ever ended up in a world with a sufficiently different physical environment that might fail to hold. For example, if he ended up in space, then spells formerly constrained to some degree by gravity, by his mere assumption that they would behave similarly to physical projectiles, might have a sudden large degree of freedom - perhaps choosing between nearby stellar bodies for the strength of gravity, or just treating the apparent strength of gravity as an open ended variable for magic to choose.
Even after deciding how to treat numerology he still found himself unwilling to attempt any form of analytic breakdowns on his own spells. What good would it do him to have so simplistic a conversion, down to meaningless numbers?
He did begin to test going in the other direction, however. If, in fact, communication of intent to the magic was as important as he had decided it was, then he might actually have some success with writing spells as programs, sort of pseudo-code, as it would guide his own mental understanding of the spell. If nothing else, if he could find a better description of a diamond's brilliant cut, it would probably be a lot easier to express the innumerable facets as some sort of program than trying to build a spell from them directly.
It had one other prominent potential use, as well. He had already been composing spells out of multiple cantrips. If he could make subroutine-like cantrips, cantrips that had multiple open variables, and either outputs or direct effects, and cast them enough that they were nearly instinctual to him, that his understanding of them was sufficiently deep, he might be able to build layered spells, constructs of magical energy that could use multiple spells, not merely for separate but linked effects as he had done up to now, but actually as fully interconnected components, then he could potentially build spells that were entire orders of magnitude more complex than would otherwise be possible.
He wondered if the really great mages did something similar, ingraining certain lesser effects so much into their muscle memory or the magic of their realm so that they could chain innumerable small spells, not only one after the other, but actually one into another.
His first attempt was intensely simple, and constituted two remarkably simple cantrips. They each had a single input and a single output. One of the two was actually his cantrip attempt from the day before, slightly modified.
What he had done yesterday for his cantrip was a step towards allowing him to see his hands without making them visible, and that was to cause magic to form a display on a flat plane of air, with the light constrained so that it was produced and traveled almost entirely within a thin cone of divergence, so that the plane was only visible when looking either directly, or almost directly at it, but totally invisible, aside from the reflected glow from objects placed in the light's path, from the back or sides. Currently, the display could show any single image that he could provide it mentally.
What he did now was to adjust it to use his understanding of language to render visible text from an input. His second cantrip was a very simple one designed so that the input was a variable dropped in, that basically tied it by reference to some physical, measurable attribute of some real object, while the output was the result of the measurement in words.
Unlike his previous spells, it was not enough to link these spells so that they both used the same measure, or operated on the same substrates, or in the same location. Here, he actually needed to tie the two spells together, to feed results from one spell directly into the input for the second, preventing the input from being treated by magic as an open variable.
He tied the input of the first cantrip to one of his carbon sticks, tying it to the height of the stick in whole inches above the ground. He spent the next twenty minutes casting and recasting the second cantrip, then casting and recasting the first with the second already going, while Barry watched with mild interest. It was a frustrating and draining process, as each failed casting left an open variable. After the first casting, James found that the casting of the display often had magic picking up the curses he was vocalising in his mind, causing the screen to curse at him.
He persevered until he could cast no longer, and ended up going to bed that night without reading, exhausted. Throughout breakfast the next morning, and even as he tried to read, he was distracted with thoughts of how to get the spells to link up. His answers to Barry's challenges were lacking, but somehow he made it through the day until the time came to try his spells again.
His first three tries were equally useless, and he was beginning to despair of his goal. Surely it could not be actually impossible to link two spells together? Yet so far everything he had tried had failed, from picturing a portion of the spell as a physical plug and socket, to threads that could be tied together, to just willing it to f-ing work already, to picturing physical overlap of the spells.
The one method he knew could work as was also something he was saving as a last resort - and that was to actually modify a physical variable, such as vibrating a spot of air, and tying the second spell to that physical variable. He did not like it, it exposed things to environmental noise, and gave a target for disrupting his spells, not to mention it would simply be mentally tiresome having to define each time the item and behavior to draw from with sufficient clarity and minimal degrees of freedom.
What it he could do the same thing though, with magic? Stop trying to tie the two spells together as if they were physical objects, and think of it more like a program, like a computer - have the output be put into a register as it were, assigned a magical code, and have the other spell look up that code.
There obviously was some form of memory available in magic, for the whole conditioning thing to work. Could he access some local form of that, have magic record some named values for him, and then look them up later?
He settled down and began to rework his spells for his fourth try that day. This time, the first cantrip was set up to pull from the physical measure and push the data into a conceptual variable slot that he titled 'Register 1'. Then he set up the second cantrip to pull the contents of 'Register 1' and display it as text on his flat display.
He ran through the sequence several times in his head while he went through the meditative practice, then he finally cast the cantrips in order. The text '30 inches' appeared floating in glowing green letters in front of him. He leaned over and, holding his breath, picked up the stick. The number jumped from 30 to 31, 32, 33, then back down as he dropped his hand towards his lap, ending up at 26 inches.
Though he felt like leaping for joy, he first canceled and recast the second cantrip. '26 inches' vanished and reappeared. He dispelled the first cantrip, but '26 inches' remained visible. He lifted and moved the stick around, and the words remained unchanged. He set the stick back on the table, and recast the first cantrip, and the text changed abruptly to '30 inches,' and this time he cried out in glee, leaping up and dancing about.
Barry and Battie did nothing to stop his capering, but once he had settled, and set aside the current book as completed, Barry handed him the next one. For a moment, James was struck by the thought that there was no-where in the house to store all these books that Barry continually supplied. He had managed to get a glimpse through the only door the house had, and it merely lead into an obvious bedroom, with no bookshelves that he had seen, yet he had been reading a book every two to three days now for several weeks and Barry continued to supply them with no rummaging about or digging up of packed away boxes.
He made a mental note to look into the feasibility of magical storage, whether by expanding the space in his pack to hold more than it should, or by creating a portable hole or something similar, as he had overheard some of the role-players chatting about back in high school. If he could not, he would certainly not be able to carry much in the way of supplies if and when he managed to find a way to step across dimensions like the Thin Man.
He sat on his bed and opened the new book, diving straight into it, and discovering to his chagrin that had he merely moved on past the previous book, many of his questions might have been answered.
This book was all about using magic on magic, about spells that linked with or modified other spells. As with all the books he had been given so far, there was no explicit instruction given, no 'cast such and such in this way, and it will have this effect.'
Instead it was a more general discussion of the types of what it termed meta-spells, their uses and limitations, their applicability and prevalence in different magical systems. It was after about the third paragraph talking about a different system of magic that James realized that somewhere along the line, Barry had shifted from giving him individual books about a specific magical system, such as one might have if one collected books from a number of worlds, to overview books that in a single text covered the systems of multiple worlds, or even generalized concepts, such as worlds where all magic was voiced, or worlds where all wizards used wands, or another where magic was done with hand motions and focal elements.
When he picked up the reading the next morning, after a long and pleasant night's sleep, James found himself getting intrigued not merely by the magic-on-magic described, but by the subtext the book was giving about the various magical systems. It was detailing things with finer gradations, pointing out that even amongst, for example, wizards that used wands, there were those whose wands were wooden, like a stage magicians, in which case the grain and species of the wood could leave a sort of signature on the magic, such that potentially spells could be tied back to the wand that cast them, to those where wands were made of precious materials, gold, platinum, mithril, and gemstones of high quality, where each wand was individually made and designed to actually hold the full pattern of a spell, along with charges of magic to cast it, and the wizard had only to trigger it.
Storing spells, trapped and ready to execute was an interesting concept all of its own, and James found himself wondering whether his graphite rods could be used to channel spells, and whether the diamond he had made could use used to store magical energy, even if it did look worthless. If it could be so used, then its worthless appearance was actually a benefit, as compared to a brilliant cut stone. When held in the hand, so that only the upper face was visible, it had looked almost black, and no-one would have likely been tempted to see it as valuable, or steal it. More to the point, it would have blended in nicely with the graphite, and potentially been almost unnoticeable.
The book described a variety of meta-magic in addition to the subtext about the systems. A spell could apparently be crafted to have no other effect than to increase the range, duration or power of a spell. Or a much more intricate spell could be devised allowing one to cast multiple effects into it, almost as if tossing grains of sand into a spiders web, where they would be caught up, fully cast yet held in abeyance, until the triggering conditions of the meta-spell were met, at which point all the spells would go off at once.
Apparently such meta-spells were a common component of some world's warding schemes, wherein webs of magic were spun about a place to ward against intruders. It was not quite the same thing as having spells stored in a gemstone or a previous metal wand, for while wards were often tied to carved stones, the ward itself was an active magic, actively testing to see if its conditions had been met, and releasing one or more spells when they were.
It was also possible, and this also found use in warding, to cast spells that consumed other spells or magic used in their vicinity as fuel, sometimes actively absorbing other spells to create a sort of null-magic region, and sometimes only capturing ambient energy, so as to maintain the power-level of their responsive abilities.
Barry's lecture and testing that morning met with better attentiveness as James was no longer quite so distracted, though he was still pondering how the meta-magic compared with what he had done by storing information in magic for another spell to retrieve. So far, he had not come across a direct equivalent for that in his reading, and so it might actually have been a good thing that his stubbornness had kept him reading and rereading the previous book looking for insight.
His cantrip that day was probably a disappointment to his teacher, he supposed, but it had immense significance for him. Having memory storage was all well and good, but communicating between more than a single spell demanded coordination, and all of James' programming experience was on modern computers. One attribute that they all shared, and that all of his computer science theory was predicated on, was something called a clock. It was not a clock in the usual sense of something that told you what time it was, but rather the underlying basis that allowed almost all such clocks to exist - a regular, repeating action.
There had been clocks in history that did not work that way - water clocks, the sun-dial, and candle-clocks, for instance, but all digital computers needed a signal pulse, so that everything happened in lock-step, and while he knew that analog computers had existed that did not operate in this way, he unfortunately knew far too little about them to use them in designing his spells. So, he needed a clock.
His cantrip also served a second purpose, for he first cast his display cantrip from the day before. It lit up with '30 inches' still visible, and he noted that apparently the magical memory slots retained their datum for at least a day. Then he cast his second cantrip, designing this one with a single degree of freedom, a single variable tied to his will that would simply be the cycles per second, or Hertz, Hz, as it was known in computing. All the spell would do is push 'On' or 'Off,' alternately, into 'Register 1', flipping every cycle, with the speed of cycling set as the one variable.
He cast it, and the display changed to 'On.' He willed the cycle to 2 Hz, or two cycles per second, and grinned widely when it worked, and the displayed word began flipping back and forth. He pushed the Hz up and up, watching it flip faster and faster until it blurred to the point that it looked like Off and On were both written in the air on top of each other, overlapping, and then canceled the cantrips.
As he dove back into the book, he found his mind rolling over some interesting possibilities. He was sure that it would be inappropriate to try to create any sort of magic spell that fed on magical energy here in the house, as surely Barry already had wards or something that drew on that excess energy. Probably it was some such permanent spell that had removed any need for the bathroom while he was here. It might even be sophisticated enough that it was actually causing his body to somehow internally recycle the water he would otherwise be losing, by removing the excess materials from the blood before it even went through the kidneys and liver?
Still, he kept going back to the idea of a spell that gathered energy and stored it in something akin to the metal wands described. Could something like that explain wishing items, such as the Djinni ring from Aladdin? If a wizard created such artifacts in his lifetime, designed to slowly harvest and store large quantities of magical energy, was it possible that long after he died, the amount of energy might be so vast that it would substitute fully for every degree of freedom in a wish, allowing even someone with no magical training to basically cast the most powerful of spells? And how much more powerful would such a device be in the hands of someone who knew how to craft a spell that did not leave all the variables open, that was actually efficient?
He could not attempt such a thing now, but it was worth remembering, and putting on the back-burner for later use. He almost considered trying to write that into a register, to use the already observed magical memory as a notepad, before it occurred to him to wonder how easy it might be for another wizard to see or draw that memory from the magic. If another wizard drew on his 'Register 1,' would they be able to see what he had placed there?
On a different note, he realized, he needed to test multiple registers, and make sure that his naming of it had actually done something. If it was really a single item communications channel, with magic only able to remember one item, it would be impossible to build a sophisticated multi-level spell system on that foundation.
The book had moved on to spells that twisted the intent of other spells now. The most important one of these, to James' mind, the most immediately useful, and the one that he promptly put on his mental list of spells to find a way to replicate, was what the book termed a target aberration spell. This covered the basic idea of manipulating the targeting of another spell, from a reflect spell that simply switched the target and caster, rebounding the spell back upon the caster, to spells that could take a spell normally cast on an individual, and stretch that to affect a group, to spells that warped a spell designed to affect something that was touched into one that could be cast for effect at a distance.
While the reflection aspect was particularly enticing, James could also see uses for this in changing connection between spells on the fly, to link his spells into an existing ward set, or to attach a monitoring spell to a running spell-group, like he might attach alligator clips to a circuit to check for shorts. It might also be usable for extending a protective spell to cover someone else on the fly.
He would certainly have to make the attempt to create spells that would alter the inputs of another spell, as well, just to see if he could, though he could not think of too many uses for that off the top of his head.
The book also covered a concept called spell breaking, in which the magic-user used similar techniques to the target aberration to twist a spell back on itself. The descriptions in this part were vague, but James knew enough about feedback cycles from chemistry to understand the idea of a positive feedback loop and the way it could lead to an explosion. If you have two chemicals that would combine with a small input of energy, and if combined, would release more than twice the amount of energy they took to combine, then mixing a large quantity together and supplying that small initial bit of energy would cause the first tiny bit to combine. That would release enough energy to combine two bits, which would release enough to combine four bits, and so on. Boom! The same idea worked equally well with something being split as combined, that part was not important. Only the exponential nature of the self-fueling positive feedback loop mattered.
Of course, a positive feedback loop did not have to be explosive, you could equally have a loop that was more akin to an elevator, lifting the temperature or some other attribute of a chemical process ever higher, until some other feedback loop dampened it.
Most magic seemed to avoid loops, being more akin to straight-through procedural code. Wards and other permanent spells, however, generally had what the book called a 'loop of quiescence,' a steady state that was actually a circular process, where the wards sort of pulsed, very similar to the clock he had himself designed, but in a more analog fashion, where rather than the clock mediating each step of the loop, each loop was itself an entire clock cycle.
Any permanent spell, then, had at least the potential for a negative or positive feedback loop to be created, wherein the output of the spell became one of its own inputs. This was not the case with the normal ward scheme, where the loop was simply a cyclical process of checking the inputs, determining the action, taking the action, and so back to checking the inputs. The action taken was not normally one of the inputs to the spell. If you could make it an input, however, then you could set up a feedback reaction that could potentially tear a ward to pieces.
As a practical example, the book described what it called a gossamer ward, a ward that had multiple trip-lines, whose only purpose was to warn the caster of something approaching, normally by sending the caster a mental signal, such as feeling a tingle or buzz. If the ward was adjusted just a tiny bit, such that it also detected sending a signal as something worth sending a signal about, then one had a simple feedback loop that would continually warn the wizard once the warning went off the first time, and would not be able to be shut off without either taking down the spell, or finding and dismantling the feedback look. If the spell had graduated messages - sending a stronger signal if more than one signal was detected, for example, then it could become a positive feedback loop, with each pass through the loop increasing the number of signals detected, increasing the number or strength sent, and could potentially fry a wizard's brain, kill them outright, or just draw too much power and collapse the ward entirely.
Of course, there was also the possibility that it would do exactly what a runaway positive feedback loop would do in chemistry, and blow up in the ward breaker's face. That did not sound like nearly so much fun, especially since an explosion of concentrated magic could probably have much more interesting effects than merely heat and a shockwave.
The next day James spent designing logic gates, little cantrips with multiple inputs and a single output. Each had an input for a clock, and one or more inputs for the logic values. This bit felt very uncomfortable to him using his registers, and made him really want wires or plugs, as he had tried and failed to manage, and he certainly did not actually intend to build anything up from the level of logic gates.
No-one sensible would seriously take a high-level language where clear English statements could be almost directly executed, and attempt to build simple logic gates on it so as to build back up to the level of being able to run a high-level program - but many programmers do that sort of thing for fun, or to learn.
It was especially unpleasant when each implementation of a logic gate would require its own independent non-overlapping set of register names. Only the clock output, which he titled 'Register Clock,' would be the same for all. When the Register Clock's value was one, each cantrip would compute its bit of logic on its inputs and store its output value in a private register. When the Register Clock's value was zero, each cantrip would ignore its inputs, and simply copy the private register value to its output.
James was not quite sure if that was how clocks worked in normal computer chips, but it seemed to him to be what would give him the best result. The real meat of the session, once he got a small set of them running, and at least presumably actively changing their outputs, was casting the display, still attached to 'Register 1,' and then trying to cast a separate spell to change the output that the display was monitoring.
Without any clear descriptions from the books on exactly how any of this was to be done, it took some time before James managed to get any result at all from casting a spell on his display spell, and he was completely exhausted by the time he finally got anything to actually happen. Barry watched all this with bemusement, clearly not understanding the purpose of all the tiny spells, none of which seemed to be actually doing much of anything at all.
He did not interrupt nor complain, however, when James cleared the spells away and went back to collapse on the bed. James did not manage to read any more that night.In the morning he tried to pick back up where he had left off in the book, but found that concentrating enough to read was difficult. His head was pounding, and his muscles ached as though he were coming down with a fever. Indeed as the morning wore on, he continued to deteriorate, the pain building to a bone deep ache in seemingly every muscle he had, though as far as he could tell, he was not running a fever.
Barry seemed unsurprised. "You pushed too far last night," he said curtly. "Now you've got to recover. Go back to bed."