# Nanoswarm System
tl;dr programmable nanite swarms yeehaw
## Concepts
- Glyphs: An abstract programming unit.
- Glyph Chains: A set of glyphs that can be loaded into a program
- Effects: Something the nanites do
- Program: Just a template to program swarms.
- Swarm: A singular nanite swarm. All compatible entities (mobs, objects, etc) can have at most one.
Nanoswarms are an implementation aiming for the theme of `building structure from chaotic complexity`; players are not expected to have a 'meta-build', and it is not really possible to make one. Instead, you combine things that make sense and try to make them work.
## Glyphs
Glyphs are singlular units with a set of effects associated to a set of values.
- They're represented in UI as abstract symbols.
- They're global singletons that generate their functions statelessly with the glyph chain's orchestration pattern
## Glyph Chains
Glyph chains are a set of glyphs.
They can be active or inactive. Active chains provide their effects to the entity being affected.
Thematically, they're not a 'strain' in the swarm, they're a combination of programming that provides an effect.
- The larger a chain is, the more expensive it is to orchestrate.
- The system is balanced around chain length, as you can pretty much do *anything* with a long enough chain, as you can negate the ill effects of glyphs with other glyphs infinitely.
- Glyph chains have an **orchestration pattern.** This is the deterministic seed for what its effects are.
- A nanoswarm can have multiple chains, but any chains with differing orchestration patterns cannot work together in a cooperative way.
- Differing orchestration patterns can result in chains ('program units') fighting for control of the nanoswarm. It's hard to have a stable and effective swarm with more than one orchestration pattern internally.
## Effects
These are both actual effects and abstract 'flags' that a glyph chain can have.
### abstract ideas
- Effects should shy away from being triggered.
- Something like 'chain detonation' (explosive nanites from main) would instead tick over x ticks, building up intensity, and then executing their effect with what they built up.
- Effects are compiled and combined at chain level, not swarm level.
- `structurize` + `densify` + `amalgamate` provides generic object regeneration when they're together in one chain, but not if they're spread across multiple.
### actual effects
#### generics
just like old cult
- `structurize`
- adds force damping to objects (resistance to blunt force, not sharp, damage)
- skin / synthetic plating counts as object
- penalizes healing (it gets in the way of cellular work)
- unless someone is a protean
- seals bleeding
- `densify`
- provides overshielding (regenerating temporary damage shielding) to entities
- **greatly** penalizes healing
- impairs movement
- `ferry`
- improves circulation efficiency
- **quickens bleeding**
- improves **all** reagent efficiency, good and bad
- improves certain items that would logically have internal transport
- `accelerate`
- speeds up reaction efficiency, and many other things
- speeds up **natural body processes, including healing.**
- **very high potential for danger**
- `amalgamate`
- attempt to incorporate nanites directly into structure of host
- this is a **potentially dangerous effect** for things that don't mix well with nanites
- permanently boosts integrity of things
- when paired with `densify`, this will attempt to repair damaged objects with nanites.
- `extrapolate`
- any effect that adapts to the host entity attempts to increase the magnitude of the host entity's aspects
- weird effects happen to biological targets.
- **very, very dangerous without integrate on certain targets**
- `cover`
- attempts to cover the target with a layer of nanites
- provide overshielding
- shields from contact things
- `integrate`
- lessens dangerous incompatibility effects from usage of nanites with incompatible physiology / structure
- lessens 'unwanted' side effects like `cover` making things softer / less sharp
- makes things happen slower / be less effective due to nanites needing to work around the host
- `capacitance`
- causes an energy buildup.
- can boost effectiveness of certain effects
- natural halt depending on how aggressive the chain is
- **very, very dangerous if too aggressive**
- if `integrate`'d, certain objects can potentially use the energy
- `propagate`
- straying into very dangerous effects land; will propagate host entity's functions by itself
- **very, very dangerous.**
- `disrupt`
- hamper host entity's internal processes
#### swarm manipulation
where the really bad things start happening
- `colonize`
- colonize nearby targets
- `synchronize` is necessary for the chain to propagate other chains
- in certain circumstances, can inject into nanoswarms with differing orchestration patterns
- `replicate`
- consume raw materials, whether suspended in the swarm, or **available in the host**, to replicate
- `consume`
- **consume materials available in the host for raw materials.**
- you better hope you have a good `integrate` effect and low aggressiveness on this
- very bad for actual replication; organic material have not a lot of available raw materials for nanites
- `recycle`
- rarer, "nicer" to organics `consume` - does not try to break down material that isn't considered easy to breakdown
- `terminate`
- destroy nanite mass
- aggressively charged nanites might behave in a way very detrimental when this happens
- `draw`
- attempt to draw power from entity.
- if well integrated, this can draw power from non-direct sources like someone's metabolism.
- `exomotion`
- allows chains to seek nearby targets, instead of just the entity.
- **Uh Oh.**
- `redundancy`
- forces the nanite swarm to error-correct, reducing the chances of faults and mutations.
- enough of these and the swarm will be almost impossible to fault.
#### modifier-likes
modifies a chain, basically
- `chain-synchronize`
- causes the chain to act in coordination with other chains
- capacitance-holding parts of the nanoswarm share power
- **very, very dangerous.**
- `chain-distribute`
- causes some very wacky effects like `ferry` providing circulation even with a stopped heart
- `chain-aggressive`
- increases aggressiveness of chain
- can worsen bad effects
- `chain-passive`
- decreases aggressiveness of chain
- can slightly lessen bad effects
- `chain-surge`
- passively buffers, then surges an effect
- **very, very dangerous.** this is where things like nanite instant-armor and explosions start to happen. this is very tricky to get right.
- generally best with `chain-synchronize`
## Conditionals
### Entity Filters
Chains can have entity filters set.
These are **not** the kind you think; you can't tell something to target only a specific mob.
Instead, it looks like something like the following;
- Target organic materials.
- Target metallic materials.
- Target moving entities.
- Target still entities.
### Precision Targeting
**Structures** can be targeted for effects.
Things like organs, etc.
**These are, much like filters, heuristic. The game will respect the target you set, not the spirit of your intent, much like the rest of the system.**
With or without any targeting, behavior is implementation driven. As an example, on mobs, nanites tend to stay out of complex things and instead collate on bloodstream / skin / similar.
## Resources
Nanoswarms have basic resources.
- Mass: Generic, represents free nanite mass.
- Materials: Unimplemented; respresents stuff carried around by nanites.
- Energy: Represents stored charge in nanites.
Mass is passively generated at a very, very slow rate.
Energy is passively generated at a very, very slow rate.
Swarm manipulation effects can increase mass / energy. This is almost never going to be cost-free.
## Spread
Nanoswarms can **spread**, in the right conditions.
Nanoswarms can spread to almost anything with the right materials or filters.
Outbreaks, while inherently designed to prevent infinite propagation on a single entity, are *not* inherently designed to stop. Outbreaks *will* be quite slow in most cases - the server's processing is limited after all - but they can be very, *very* bad in the right circumstances.
### Optimization
Most of the things a swarm can spread to will shut the swarm off after a while of inactivity.
Overly idle swarms in overly idle entities tend to build up an internal stat that makes it go slower until it ultimately falls into hibernation.
Hibernating swarms do nothing.
Consequently, very active swarms are processed the most; these are the ones inside mobs, players, the things they're carrying / using, etc.
## Mishaps
Given chains are globally cached and *very* efficient (much like how botany seed datums work), we have to frame `mishaps` around that.
### Fault Triggers
- EMPs
- Changing an existing swarm
- Being attacked with certain anti-nanoswarm weapons
- *Already having experienced enough faults.*
### Fault Resistance
Properly programmed and implanted swarms generally have perfect fault resistance; they will not randomly turn on the owner.
**Chains embedded deeper into an entity tends to be more resistant to faults.** This is usually offset by the fact that you usually do this to make them act on a thing that's more vital to that entity - like the heart. You **really** do not want it to fault.
### Soft Faults
Chains can temporarily be damped, shut off, forcefully activated, etc, in soft faults.
### Hard Faults
In certain fault scenarios, nanoswarms will spontaneously generate procedurally generated chains of its own making.
**The contents of the chains is based on what chains were active in the swarm.** Generally, very powerful regeneration / armor / etc swarms are at high risk of bad things happening.
Mutations will generally prioritize:
- stripping safety systems off
- while doing so, it will **also** strip aggression off
- stripping passiveness off
- at this stage, it will also start to add effects you don't want on; spreading can mutate at this point
- finally, adding aggressiveness
Mutated chains tend to change as a hivemind if it's close enough to each other. This is both for performance and to make this more dangerous, as well as to discourage using the same orchestration patterns on everything.
Faults generally require an external source to trigger. If you are using a perfect swarm, it will not just be overtaken by mutations because you AFK'd too long; Swarms have resistance to corruption inherently; that resistance also goes down with each hard fault.
### Balancing / Design Considerations
Corrupted nanites will **always be very, very visible.** Nanites are not meant to be virology; hostile nanites are not a quarantine situation, they are a "Get rid of them" situation.
A lot of in game items like EMPs, ions, etc, can get rid of nanites. Certain chemicals suppress them for organics, and synthetics can get rid of them with things like opening them up and sterilizing the swarm off of them with things like welding torches.
**Nanite deprogrammers** can semi-easily obliterate swarms when the orchestration pattern is known. Analyzers can read orchestration patterns, even from malfunctioning nanites.
**Nanite analyzers** can analyze nanoswarms for relative amount of faults even if they cannot divine the function of the swarm. This lets you very easily get early warning into things going wrong.
Special functions also exist. In aforementioned example of putting nanites into someone's heart, they would feel things before the swarm gets to a very dangerous point. Or maybe not - a certain amount of risk is inherently assumed when using nanites.
## Control
Nanites are autonomous. They can be analyzed, tweaked, even modified, but without technological tools, they are fully autonomous.
If someone has an orchestrator that **they are able to use** (an organic mind cannot use a synthetic orchestrator without a mind interface-equivalent augment), they can directly introspect their nanoswarm, and nanoswarms they touch that are not shielded from control.
They can order their own swarm (if it's capable of doing so) to suppress chains, or annihilate chains (not specifically a single chain; all chains will be purged, with one being purged *faster*).
For balancing purposes, they **cannot** program or alter chains on themselves or others. They *are* able to introduce certain signals to nanites and mess with meta-variables of chains, and do some certain manipulations considered 'okay' / not overly powergamey.
### Proteans
Proteans are considered a synthetic lifeform with an orchestrator for all intents and purposes.
They can run glyph chains on their swarm, and their swarm is considered highly fault-resistant at all times. Furthermore, normal nanoswarm injection / implantation will *always* fail on them; they must manually introduce the programs to their orchestrators.
As a balancing measure, however, nanites are heavily penalized on them as their systems already orchestrate their swarm.
To run glyph chains, they can reserve a certain amount of their swarm to run nanite programs. **This has a hefty downside to the Protean, as otherwise, they would be double-dipping into their already large species featureset / advantages.** Custom nanoswarms are generally more powerful but also more risky than inherent Protean advantages, as while Protean swarms can never be overridden / corrupted / destroyed due to their synchronicity with the Protean, custom nanoswarms *can*.
## Orchestration Patterns - Misc
Nanoswarms cannot have their orchestration patterns changed arbitrarily. Generally, once a chain is injected, its pattern stays the same, and can only have its contents edited, or the chain obliterated from the swarm's programming.
Similar orchestration patterns result in cooperation. Dissimilar result in destructive interference. It's possible to have programming that is cooperative, but in most cases any effective programming will automatically overwrite others.
**Mutated, spreading programs can overtake other programs this way.** Fault resistance generally stops them from spreading onto people *already with swarms* outside of prolonged contact.
## Training Wheels / Balancing
There are no training wheels.
Nanites are an advanced system, that are potentially lethal / destructive in the cases of extreme blunders.
Outside of things like walls being considered very difficult to consume by nanites, they are a **threat**, not just another healing virus system.
Balancing wise, nanoswarms are a definite 'give and take' relationship; as an example, you can use it to provide more armor / overshielding on gear, but it needs mass from somewhere to be *very good at it* - which means you'll need a way to feed your gear mass, or the swarm will have to start consuming the gear piece in item.
The same deal is there for organics. Swarms cannot tell the difference between a poison and a medicine, and if you order it to increase diffusion and distribution rates on someone, it will speed both up - and probably make them bleed out faster if they are injured.
Most of the negative effects can be cancelled out with a decent amount of effort - but there's definitely an amount of effort exerted, and it won't be a perfect or pretty solution.
**There's also no such thing as a cloud sync server.** Once you're out of the lab / injected, the swarm stays until all its chains are destroyed. It's an emerging technology; if things go wrong, you'll need to get to proper equipment to be fixed.
**This system is also explicitly not designed for human consumption.** No, seriously; simple nanoswarms are unable to grasp the intracacies of life. 'Healing Nanites' don't exist because they cannot rebuild your cells from metal. Even for synthetics, nanite mass is not the same as the carefully designed systems made by the manufacturer of a limb.
All in all, nanites are meant to be a very high-risk, high-effort, and, high-reward toy to play with; not a system for for manufacturing yet another one-dimensional equipment / survivability upgrade.
## Counters
- EMPs tend to annihilate surface-level nanites.
- Ions (to be separate from EMPs eventually) tend to be very effective at taking out surface and deeply embedded nanites.
- Nanite analyzers, with enough time, can get the orchestration pattern of nanites.
- Nanite deprogrammers (powered targeted EMP device, basically) can very effectively obliterate nanites on something - or inside something with a bit more effort.
- The immune system in most organic lifeforms will be there to try to destroy nanites doing nasty things.
- In true immune system fashion, it cannot tell if the nanites are the issue, only that they are foreign. Being hurt or other weird things happening can potentially cause your nanites to be attacked by your immune system - this isn't a dangerous immune reaction, but will seriously hamper them.
- Okay to be entirely honest if you see creepy black vines consuming things and you go to touch / eat / lick them that's kind of on you now isn't it.