Magical Programming
How to think about your magic system to increase audience understanding and make your story feel more real and grounded, even when conjuring hurricanes with wooden sticks.
How do you develop a magical system that allows for things like the creation of spells? What does the consequence of something like healing have upon your entire magical system? What does it mean to create a spell? How does a magician/wizard/sorcerer achieve such a thing and what does that say about your magical system as a whole?
Table of Contents
Part One – Introduction
Get a grounding for the ideas you’re going to be exploring in your magical system, including the 4 major categories of magic and their effect upon ‘programming magic’ as well as the 3 types of programmable magic.
Part Two – Magical Circuits
What would it mean to take raw power from a magical source and then program that magic to create a physical effect using either physical circuits/devices, or ones of a more Ethereal nature?
Part Three – Magical Coding Basics
If you are using an Aether system, how does the spell get into the Aether? How does the answer to such a basic question influence your entire magical system? What difference would it make to have a coding language vs. having to instruct the Aether in some native machine code?
Part Four – Deeper Magical Coding
Now we’re getting into the real nitty gritty of magical coding. What does a spell look like on the inside? Do you have to create each spell from the ground up? Can you use another spell and build on it? Is there an Aether administrator out there making sure you don’t break magic?
Part Five – Countering Magical Code
Now that you’ve developed what the ‘code’ of your magical system looks like, its time to go further. How does your magic interact with the world around it? Can a magician counter magic? Are some spells unstoppable? Why would they be? Does your magician have to know ever spell in order to counter them? Can you stop a spell once cast?
Part Six – Hexes, Curses and Charms
Most of your spells are probably one-time, intermittent uses. Unlock the door? Dorus Unlockus. So can you have a spell that just keeps doing its thing? Will the door never lock again? And how does magic allow this? What does it cost your magician? How does another magician stop it?
Part Seven – Healing with Magic
If you want to describe your entire magic system in one go, then answering for yourself how/if a magician can heal a wound either magic or mundane will force you to really decide how your magic works and why. But now you’ve got the tools to think about it effectively.
Part Eight – The Inevitable Time War…
…And other pitfalls that you may encounter when opening up magic too far. If your magician can manipulate time, then why isn’t there already a time war in progress? Did someone already win the war and now your magician has no clue it even happened? When magic can undo reality, what’s left for you to build your magic system on?
Part Nine – Putting it all together
“It all begins with an idea. Maybe you want to launch a business. Maybe you want to turn a hobby into something more. Or maybe you have a creative project to share with the world. Whatever it is, the way you tell your story online can make all the difference.”
Part One – Introduction
Before we jump in to the nitty gritty, we need to establish some basic grounding points for later discussions. What is the difference between Mediated and Non-Mediated Magic, and how does that affect the ability to ‘program’ that magic?
4 Major Categories of Magic
There are four major categories of magical power that I’m going to use as broad reference points before jumping into the idea of creating spells and what that means for your magical system. I have a separate thread where I look at common genres of magic, so we won’t be getting into that here. This is more about the underlying principles of how a spell could function, and not the type of spell or the source of power for that spell. The integration of those will come after you gather together the ‘physics’ of your magical system.
You will likely see that you actually have several distinct systems already in your sketches, so this will help you to really ground them in a codified way and intentionally draft their rules so that you can achieve really amazing dramatic tension which uses something like Sanderson’s Laws effectively and keeps you from writing yourself into a corner later in a series.
So, to begin, what are the four major categories of Magic?
Mediated Magic
Connects to power/source but then mediates/controls the flow/shape etc. of that power into a magical effect.
Can be accessed via a tool/affinity/API (Spell)
Non-Meidated Magic
Raw power/source which flows directly
Can be directed into the magician, into a channel, or into an object/mold
Magical Abilities
Some sort of genetic/inheritance model
Highly specific
Could be instinctive or natural mediation
A Unicorn shines with light
A werewolf heals quickly from injuries
Usually non-transferable
Only repeatable if ability is active
A demon shoots pillars of fire from its eyes
A fay can heal by laying on of hands
A arcane spider secrets toxins/acid
Gift or Boon
Similar to abilities, but it is placed upon an individual/creature by another source
A god gifts healing to a cleric
A demon gifts pestilence to an acolyte
Can be temporary and may be transferable
May be the result of an object of power
Once imbued, any user/wearer is granted the power
Can be destroyed
Not usually transferable to another object
Not usually able to be copied or reproduced
What makes magic programmable?
Here I’m using ‘programmable’ to mean that an individual magician is able to create a spell, rather than magic simply having a set of spells that have existed always or were created via some higher order being. In order for magicians to be able to create their own spells, there are certain requirements that have to exist in your world at a fundamental level aside from the obvious, which is a source of magical energy waiting to be called upon.
What allows Magic to be programmed to respond to a spell?
Magic must be mediated in order to be programmed OR it must be capable of being placed into a mold/container which can be further manipulated by structure/circuitry that takes raw power and converts it into magical effect.
In programming, there are several words which have some use to us when thinking about “programming” magic. The first is Application Program Interface (API) which I generally refer to as a correlation to the magical spell. It is a call from one program to another that allows for actions to be performed, and likely some sort of output to be returned to the program that called it.
A great example is logging in to a website with your Apple or Google account. The website you want to enter uses an API to validate your information with Apple or Google, in essence you cast a login spell, and Apple or Google is the source of your magic. If you are favored by remembering your password, then Apple or Google will grant you the access effect for that website. (This is a gross over-simplification for our needs, and the distinction between APIs, programs and functions may be interesting to you if you want to really dive into your magical system at a very deep level. But for now, let’s just continue with the top-level ideas.)
A spell could be like an API where it calls up spells another magician has created and simply receives an output, like getting the temperature outside. A programmer doesn’t have to have a weather station to tell you what the weather is like in New York City today. A magician wouldn't have to know how to create a fireball if there were a fireball API just waiting for someone to call on its services.
But spells could also be programs, coded or run specifically by one magician, in some local setting, like having a website hosted by your desktop computer. Not ideal for allowing the whole world to browse it, but perhaps you just need to keep your recipes in order for your own home cooking.
Don’t get too hung up on the technical aspects, though if you’re still reading this, then likely you enjoy technical aspects. I promise, we will start to breakdown the correlation between program code and the ability to create spells.
What types of programmable magic are there?
Aether based magic would have a layer that stands between the raw source and the final effect, which could be implanted with code to shape the raw power into the magical effect. This code would linger until an API (spell) is called that activates the program and therefore produces the effect.
Infinitely reproducible as long as spell conditions are met
Infinitely extendable, as long as programming language/interface conditions are met
Can be limited to only certain sockets (alignments) or ports (affinities) such that not all APIs (spells) can be called by all magicians
Can be called simply by words or thought, or may require access keys like wand, staff, or focus.
Spell conditions can stipulate thresholds or power requirements, especially if there is an access key involved, such that limitations can be set based on the type of access key and the individual magician calling the API.
Certain security conditions can be set to prevent types of magicians from accessing the spell, or only allowing a specific kind of magician to access the API
Raw Energy based magic would need a physical structure/circuitry to allow items/materials in the physical world to hold and manipulate raw power/source and produce a magical effect.
Requires some ability or mechanism to connect with raw power/source and safely transfer that into mundane setting.
Raw plasma cannot simply be scooped up and slopped into a shell
Dimensional or Eldritch energies cannot merely be laid into a crystal
Would have to be constructed like a machine or circuit board, each piece working to either hold or change the raw power/source into the specific magical effect.
Repeatable based on longevity of physical device and connection to power source.
If continuously powered by raw power/source, then it would reproduce effect as long as the object remained whole and functioning, ie magical crossbow is able to fire magical bolts unless damaged or destroyed.
If powered by energy cells of captured raw power/source then it would operate as long as there was power and the device was functional, ie same magical crossbow with a limited amount of energy to produce bolts
If device is consumed or converts itself into raw power/source, then it would be a one-time use, ie magical lightning grenade
Reproducible if the design is known to the maker, and if the process of harnessing the raw power/source is within the makers ability
Subject to wear and tear of the magical effect as well as that of the mundane world.
An iron magical sword will still rust if not cared for
A wooden magical crossbow will still swell and shrink under temperature and moisture
If using circuitry, then complexity increases the more the raw power/source has to be manipulated in order to achieve magical effect
A magical communicator would have to change sound waves into magical signals that were then potentially encoded before being transmitted, either through the source, or through another medium, to be then detected and transformed back into sound waves at the other end.
A wand that could choose the intensity of the shock applied would need to have some sort of resistor as well as a selector to change the resistance, on top of whatever mechanism is changing the raw power/source into the effect of electricity.
Ethereal based magic would rely upon non-physical means to trap/contain the raw power of magic and then manipulate into magical effect. This could look exactly like a physical circuit, but would exist immaterially. I call these lattices and meshes in my own writing to give them a physical sense without specifically likening them to a mundane circuit board.
The raw power/source can of itself be stored/trapped/structured into a lattice or structure of some kind which can later be triggered to create a magical effect.
Repeatable only if the structure is able to reset itself after use
Reproducible only if the structure is visible/decipherable to another magician
Raw power/source would still need to be conducted by something, so some tool would be necessary to draw the raw power/source into the lattice for later use.
May also be immediate effect if the magician can conduct the raw power/source while they are crafting the lattice, though there would be some delay between conduction and release of effect, likely based on the complexity of the lattice.
If producing lightning,
Magician would need to conduct the raw power into a lattice that changed that power into positive and negatively charged particles
Magician would need to use more raw power/source to arrange those particles into the four layers necessary to produce lightning
Magician would need to use additional power to align those layers between themselves and the target
Magician would need to use yet more power to excite the flow of these particles in order to build up a charge
Magician may need to use additional lattices to protect themself from the heat rushing back at them.
“Programmability” of the magic varies in its definition here. For most writers, the Aether based system is probably what you have in mind. A way to create spells that a magician can call upon when needed. The other two systems probably also exist in your world though you haven’t quite thought about them that way. Anytime you have a magical item, you may have been using programmable raw power just like a circuit board transforms electricity into the words on your screen right now. And if you have magic in your fiction that seems to lay on top of or exist in a different plane than the mundane word, you might already be exploring an Ethereal type of programming.
I will cover what the ‘programming’ would look like for the Physical and Ethereal systems next. They are less advanced and more concrete than the much larger Aether based system can be. Though they are no less dramatic and interesting, just lacking some of the more complex thinking that Aether entails. Using the iceberg theory, a physical battery of magic that runs across a magical circuit doesn’t need much more explanation for most fiction, unless your magician is the architect and designer. Even then, there’s an inherent correlation for the audience to the world around them. Whereas crying out a power word and getting a hurricane is less like pressing a button and getting a sports score.