Can the programming of simple nanobots randomly change to create a similar effect as mutations in DNA? This question has a very similar idea as I wanted, although in this case the nanobots are capable of upgrading themselves: Nanobots Ecosystem, is it possible?

For my story I am wondering what could cause the self-replicating process for some of the nanobots to go wrong and as with evolution some of these changes will not be beneficial but for others it will and could lead to more and more complex robots, given enough time.

Is this possible that the programming for self-replication can randomly create different results?

  • 4
    $\begingroup$ I suggest "simulated evolution" as a search term. Also start from Lawrence J. Fogel's work in the 1960's and look for its descendants. $\endgroup$ Commented Mar 17, 2020 at 12:56
  • 10
    $\begingroup$ Genetic algorithms do exist and are actually used. Who is to say that the nanobots in questions do not use such techniques? $\endgroup$
    – AlexP
    Commented Mar 17, 2020 at 13:05
  • 6
    $\begingroup$ @AlexP there is also genetic programming to go with GAs. Whereas GAs evolve a solution to match a criteria, GPs evolve an algorithm that will produce a given solution. $\endgroup$
    – VLAZ
    Commented Mar 17, 2020 at 15:16
  • 4
    $\begingroup$ As there is no way at all to preclude errors during copying (even the checksum machinery may fail), you WILL get mutations eventually. This is actually a major problem with self-replicating machinery. Cosmic ray hits, chemicals, radioactive decay of an atom here an there, and there may be trouble if a self-replicating nanobot keeps functioning. $\endgroup$ Commented Mar 17, 2020 at 20:45
  • 19
    $\begingroup$ It is important to recognize that living cells are nanobots, and very complex ones at that. There is an unrealistic trope of human-engineered nanobots being "basically normal robots, but scaled down" that have tiny circuit boards and manipulate individual molecules using arms with general-purpose end effectors. At molecular scales it is very inefficient to try to manipulate individual molecules like this, rather than doing what cells do and pumping out lots of components that are energetically favored to combine into the desired reaction product. $\endgroup$ Commented Mar 17, 2020 at 21:55

14 Answers 14


Everyone who has studied computer science in general, and artificial intelligence in particular, will know about a kind of algorithm called

Genetic algorithm

In computer science and operations research, a genetic algorithm (GA) is a metaheuristic inspired by the process of natural selection that belongs to the larger class of evolutionary algorithms (EA). Genetic algorithms are commonly used to generate high-quality solutions to optimization and search problems by relying on biologically inspired operators such as mutation, crossover and selection.1 John Holland introduced genetic algorithms in 1960 based on the concept of Darwin’s theory of evolution; his student David E. Goldberg further extended GA in 1989.

This appropriates genetics and evolution to the max. Look at the terms used in this field.

In a genetic algorithm, a population of candidate solutions (called individuals, creatures, or phenotypes) to an optimization problem is evolved toward better solutions. Each candidate solution has a set of properties (its chromosomes or genotype) which can be mutated and altered; traditionally, solutions are represented in binary as strings of 0s and 1s, but other encodings are also possible.

The evolution usually starts from a population of randomly generated individuals, and is an iterative process, with the population in each iteration called a generation. In each generation, the fitness of every individual in the population is evaluated; the fitness is usually the value of the objective function in the optimization problem being solved. The more fit individuals are stochastically selected from the current population, and each individual's genome is modified (recombined and possibly randomly mutated) to form a new generation. The new generation of candidate solutions is then used in the next iteration of the algorithm. Commonly, the algorithm terminates when either a maximum number of generations has been produced, or a satisfactory fitness level has been reached for the population.

A typical genetic algorithm requires:

  • a genetic representation of the solution domain,
  • a fitness function to evaluate the solution domain.

So if your nanobots were designed with this in mind, they may keep evolving on their own.

If you delve deep into genetic algorithms, you will see that they provide weird solutions to common problems... Which tend to be the most efficient solutions, and which we humans would hardly think of on our own. For example, this antenna:

Evolved antenna

It appears in the wiki article called Evolved antenna and the description for the image says this:

The 2006 NASA ST5 spacecraft antenna. This complicated shape was found by an evolutionary computer design program to create the best radiation pattern.

So if your nanobots are programmed with genetic algorithms, their shapes might be irrecognizable from generation to generation. If survival is the fitness function, they will become very tough to deal with.

  • 9
    $\begingroup$ The problem here is that while genetic algorithms use mutation to solve problems, the programs that are running those algorithms don't change. Of course it is possible to have self-modifying code, so the designers could build that in: en.wikipedia.org/wiki/Self-modifying_code $\endgroup$
    – jamesqf
    Commented Mar 17, 2020 at 18:46
  • 9
    $\begingroup$ @jamesqf I don't think that is a problem. Biological organisms can express massive changes in shape/size/behavior etc. by mutation of genetic code, without altering the ribosomes that control the conversion of genetic code to proteins. So you can consider the underlying programs that run the genetic algorithms as just 'firmware' that similarly expresses the genetic algorithm data as changes in the design/behavior/etc. of the nanobots. $\endgroup$
    – Penguino
    Commented Mar 18, 2020 at 1:39
  • 9
    $\begingroup$ Genetic algorithms can still give very surprising results, potentially well beyond the expected bounds of the experiment, especially in more complex systems with real-world entropy. I seem to recall reading somewhere about evolving circuits that didn't work when transferred to new device - it turns out that the algorithm had managed to exploit a manufacturing defect in the FPGA they'd used for the experiment, which wasn't present in other units of the same type. $\endgroup$ Commented Mar 18, 2020 at 9:35
  • 2
    $\begingroup$ Evolutionary design is very different from code mutating. The example you've shown is a fixed algorithm that can perform iterative optimization. Where this gets interesting is not in these applications, but when code is iteratively modifying itself. The self-referential part of this is a critical aspect. $\endgroup$
    – J...
    Commented Mar 18, 2020 at 12:24
  • 2
    $\begingroup$ @J The example given yes, because it's generating hardware. But you can apply the genetic algorithm in software - effectively rewriting the software. The genetic algorithm itself DONT NEED TO EVOLVE. Just like our own DNA polymerase (the enzyme that copies DNA) hasn't evolved much in billions of years - it doesn't mean that we haven't evolved beyond being single-celled organisms $\endgroup$
    – slebetman
    Commented Mar 19, 2020 at 4:46

Yes, if they are designed to do this. Evolutionary progress is the whole point of genetic algorithms. Your nanobots may be designed as a physical instance of this type of thing.

There is a real-life project called subCULTron which is building an underwater robot ecosystem with the intention that the robots in different areas will develop their own cultures in response to the environment. Their test zone is in the Venice lagoon.

  • 2
    $\begingroup$ Very cool, didn't know about this project. $\endgroup$
    – user72806
    Commented Mar 17, 2020 at 13:50
  • 11
    $\begingroup$ Why does that sounds like the setup for sci-fi horror movie? $\endgroup$
    – Seth R
    Commented Mar 17, 2020 at 20:33
  • 2
    $\begingroup$ because it's basically the plot of a Michael Crichton novel $\endgroup$
    – Ruadhan
    Commented Mar 18, 2020 at 10:16
  • $\begingroup$ @Ruadhan I don't know if you said that jokingly, but that does rhyme with Michael Crichton's Westworld (well... not what he wrote exactly, but what HBO added to it in the TV show). $\endgroup$ Commented Mar 19, 2020 at 14:21
  • $\begingroup$ I was thinking of Prey myself $\endgroup$
    – Ruadhan
    Commented Mar 19, 2020 at 14:36

I don't know how old are you and if you can relate to what I am about to tell, but I am old enough to have seen the growth of the internet and the expansion of computers.

In the days of the floppy disks (and even earlier with the "pizza" sized 8 inches disks) it was common that some error appeared on the disk during the writing process or while the disk was stored, corrupting the content of the files there stored.

Those errors are the mutations you are looking for: most of them will make the file unusable, but once in a while the mutation will make sense.

  • 1
    $\begingroup$ I mean.. modern error correction algorithms reduce the chance of this happening to near zero. But if you’ve got trillions of nanobots all doing their thing then near zero might be enough. $\endgroup$
    – Joe Bloggs
    Commented Mar 17, 2020 at 12:43
  • 2
    $\begingroup$ I remember 24 inch IBM hard disk platters, great for serving pizza -- sniff, I'm old! $\endgroup$
    – amI
    Commented Mar 17, 2020 at 22:54
  • 2
    $\begingroup$ nanobots are small (source needed) so maybe there is not enough space for proper error correction $\endgroup$
    – Christian
    Commented Mar 18, 2020 at 9:55
  • 1
    $\begingroup$ The thing is, computers are designed to detect and correct such errors (check out ECC RAM). Or detect them and throw it out or just stop in a faulted state. DNA copying does have some error detection and correction, but it's obviously not perfect. You'd have to do the opposite of what most designers do: get rid of the error checking and embrace the errors, then let them propagate to the next generation. $\endgroup$ Commented Mar 18, 2020 at 16:10
  • 3
    $\begingroup$ @Omni-King: Apparently pizzas have grown since those days, while disks have shrunk - and in the case of floppies, disappeared. $\endgroup$
    – jamesqf
    Commented Mar 18, 2020 at 18:41

Yes. Random bit-flips often occur in real computer systems, even today. Usually they are bad.

In all computer memory there always has a percentage chance of each memory cell changing from 0 to 1 or 1 to 0.
a) The probability of memory related bit-flips occuring increases exponentially with temperature
b) The probability of a bit flip increases with with exposure to radiation. Even on the earth there is always some radiation. In space a lot more. In fact its so common in space environments that digital logic is often designed redundantly to detect and (if possible) correct those errors.

The chances of long strings of bits randomly flipping into useful sequences is astronomically small, so don't count on that happening. But if the code is designed so that it is broken into a set of useful functions that call each-other then you can get interesting behavior from even one bit flip.

For example a bit flip in a jump instruction could cause large sequences of useful code to be executed at a different point than originally intended.

Here is an example of a sequence of machine codes that leads to a plausable beneficial mutation.
The nano-bot contains a main code loop that happens to be on lines 1-500.
On line 501 there is a routine (at memory address 501) that checks for damage and initiates repairs.
Suppose that the repair routine was normally called once per day (which may have been OK).
Now lets suppose that the nano-bots are now continually exposed to radiation, most of them experience lots of bit flips, and many go non-functional.
Lets assume that the radiation causes the fourth bit on line 500 to flip from 0 to 1.
So now instead of jumping back to the start of the main loop, the code just keeps going to line 501.
This would cause the error checking routine to execute every iteration of the main loop rather than once per day.
As a result this nano-bot is able to survive the radiation.

1: 0011 0101 //some stuff
2: 1111 0001 //some stuff
3: 1101 0001 //some stuff
4: 1111 0111 //some stuff
500: 1110 0000 //instruction that jumps back to main loop

501: 1100 1001
502: 1110 1011
600: 1110 0000 //instruction that jumps back to main loop

  • 1
    $\begingroup$ Thanks, this is a good description for how they could change without any learning software. $\endgroup$
    – user72806
    Commented Mar 18, 2020 at 0:18
  • 1
    $\begingroup$ Note code can also mutate in another way genetic codes does, by getting chopped up and rearranged during copying. Which tends to be responsible for the most "interesting" mutations. $\endgroup$
    – John
    Commented Mar 18, 2020 at 3:01
  • 1
    $\begingroup$ Mutations are not sufficient for evolution. They are not even the most efficient way of producing variation: recombination (between individuals/codes) is. To trigger evolution, you need to impose competition. $\endgroup$
    – Zeus
    Commented Mar 20, 2020 at 0:26

As modern software would utilize error checking I'd say no random mutation would occur on its own. A single bit flipped due to whatever reason could cause fatal results or do basically nothing to a machine/software. "Physical" measures like ECC memory, and software solutions like checksums are commonplace.

I see two options here:

  1. They are designed to evolve.

I'm no expert on AI technology so I'm ignorant about AIs limitations but as we are not even close to creating evolving nanobots with modern technology and AI technology is in its infancy it would not be too much of a stretch to simply say that your nanobots do utilize AI to determine new 'evolutionary' paths.

  1. Nanobots have to fight other nanobots

In a full out warfare against other nanobots I could imagine some errors accumulating. Nanobots would probably have reasons to change their combat strategy on a physical level (prompting them to change) but they would also engage on a software level trying to hack each other. With a limit on time (security measures take some time), a constant physical and software barrage of enemies trying to utilize every weakness and certain random events (radiation, rapid changing magnetic fields, etc) I could definitely see the nanobots undergoing a DNA like change over time.

  • 1
    $\begingroup$ Interesting idea about hacking software, I was thinking about bots feeding on others for their materials and energy but this a likely outcome also. thanks $\endgroup$
    – user72806
    Commented Mar 17, 2020 at 13:12
  • 3
    $\begingroup$ 1. They are designed to evolve. see homoiconicity "Code is data and data is code" - this is why the first attempts to strong AI were carried on LISP. 2. Nanobots have to fight other nanobots See Core War. Gosh, do I fell old or what? $\endgroup$ Commented Mar 17, 2020 at 13:12
  • $\begingroup$ Hacking isn't the only software-level attack. A considerably easier approach to evolve is a denial-of-service (DOS) attack, wherein you send so much garbage information to a victim that they can't possibly process all of it, leading it to also miss out on most of the real, important information (such as from allies or other parts of itself connected through the same networking infrastructure). This not only cripples its ability to communicate, but also expends an enormous amount of time, energy and memory on trying to interpret the bogus messages. $\endgroup$ Commented Mar 19, 2020 at 8:33

Possible, yes. But how likely it is depends on various conditions. And those conditions depend on how you consider the question of nanobots evolving.

Specifically you have three obvious angles to think about this. You can consider individual nanobots acquiring new properties. You can consider the cloud of nanobots acquiring new emergent properties as a group. Or you can consider the entire environment of the nanobots which includes all the support infrastructure and even the human programmers.

On a nanobot level this is only possible if the nanobots were designed to adapt. Simple self-replication and self-repair are not enough. The method used to code the nanobots has to have the sufficient flexibility and modularity to actually enable the potential new properties.

This would actually be possible. DNA used to code living cells gives as a template we can use. The first important factor is that DNA is error tolerant via redundancy. This allows errors to accumulate without killing the cell until they eventually can be interpreted as something functional. The second factor is that the system must have the flexibility to interpret random garbage as valid programming otherwise the emergent code will be simply ignored or deleted.

This is actually a real possibility. It would allow us to replicate the adaptability of real world bacteria with their ability to evolve and exchange the "code modules" for emergent adaptations.

I still consider this unlikely. We are more likely to be scared of the possibility of somebody hacking the actual bacteria than to want to create artificial ones that could be hacked by terrorists or spies. So I'd expect nanobot coding to be fairly static, strictly validated and authenticated and designed to deal with errors via reinstalling the code from a valid copy.

On the "cloud" level this seems more likely. We reasonably would want our nanobots to have some adaptability to changing environment and giving them emergent social adaptability similar to what social insects have would be fairly reasonable choice. We would still be able to set strict security constraint via the fixed coding of the individual nanobots but the ability of the cloud as a group to adapt its cooperation would save us the effort of trying to predict and code for all the weird corner cases.

You could fairly argue this would be safer than a more fixed coding scheme that would be vulnerable to failing in unpredictable and potentially disastrous ways when the design parameters the developers expected are not met.

Even so I would still expect people to prefer using traditional approach of designing the nanobots to fail in safe manner when design parameters are not met.

On the environment level evolution via accumulation of random errors is something that already happens. Calling bugs "unintended features" is not just a joke. Behaviour caused by an coding error is just as much a feature of the system as the stuff you coded for.

It is much less likely to be useful than actual design and usually is simply fixed. But occasionally the behaviour is useful or close enough to useful that it results in a new feature being coded based on the bug.

This is very similar to how accumulated errors can result in new features in biological evolution.

Fundamentally this is just a special case of the normal loop used in agile programming. And in fact agile programming will handle feedback on "unintended features" just as well as it handles the unexpected feedback on designed features.

  • $\begingroup$ Nice, thanks. the cloud or hive evolution is especially interesting. this could drastically save time for complex robots evolving. $\endgroup$
    – user72806
    Commented Mar 17, 2020 at 13:49

Other people have mentioned genetic algos so I'll go into another similar example and why evolving programs were so useful in computer vision.

Back in the day the US postal service wanted to start automating mail sorting. Of course, in order to do so you have to be able to have computers detect numbers. That might not sound too hard, certainly much easier than detecting whether a picture has a cat or not, but there's still a problem: people write numbers in a LOT of different ways.

So the stats/comp sci people went at the problem with the standard algos of the day -- random forest, multinomial regression, etc. These sorts of algos were decent, about 60-70% accurate which is still very good accuracy considering random guessing would have you be about 10% accurate. But they all still had a problem, you have to have someone program the variables you use to make the guess. So you had people coming up with concepts like 'how many edges' 'is there a curved line' and so on. This really only gets you so far because of the problem discussed previously.

The researchers tried many approaches and finally realized something -- what if the algorithm could program its own variable? And this is why neural networks skyrocketed in popularity (also over time computing resources got cheap enough to actually make them an option): with neural nets the algo, in part, programs itself! That is, instead of using variables designed by people, it designs its own variables based on the intensities of each pixel in the picture it is looking at. Of course it's a bit more complicated but that approach led to accuracy > 95% and to the point where they are better than humans at number id.

This concept is extensible far beyond simple number id, it's also how autonomous cars learn to drive. Nobody is sitting there and programming the car to do this if that happens, it teaches itself based on examples from both real life driving and simulation data obtained from what are essentially video games.

EDIT: In fact, the way they work is often not obvious at all, to the point where they are often called 'black boxes'. Figuring out why a NN makes a particular decision is a non-trivial lengthy process.


I'm going to raise a few points about unplanned mutations.

"Cosmic rays"

These are dreaded* radiation coming from the Sun or elsewhere that occasionally flip a bit in some computer memory. But it's a catchall term for bit flips that occur due to power fluctuations, dust, hardware imperfections, radioactive decay, and so on.

* by large-scale IT infrastructure people

Mechanical forces

A microbe or random molecule, perhaps a fragment broken off another nanobot, could get in the way of the replication hardware and alter the physical result. This could result in a deformation or hybrid or something. In particular, if the replication hardware of the new bot is unusual then it will create a whole line of altered bots.

Also, the bots need to harvest material from their environment and if something looks like copper but has traces of silver, it may operate differently.

Trillions of bots

They're tiny, they replicate, so if there are enough of them, bits will be getting flipped and nonstandard replicas created somewhere on Earth constantly.

Can't bit flips be detected?

Theoretically yes, but not in practice.

A bot could use some technique to detect changes to code, and then disable itself if they are detected. However, the bit flip could occur in the checking or disabling routines! Thus the bot wouldn't disable itself. This combined with another flip elsewhere could lead to behaviour change.

Yes, the bot could have ECC RAM that has built-in checks. However, several flips at the same time could cancel each other out. Or a bit flip could happen to data/code as it travels from RAM to the execution unit.

Besides, bots need to be as tiny and use as little energy as possible, so they probably can't afford to have much code or hardware set aside for error detection.

  • $\begingroup$ good suggestions, thanks, accidental material in the replication process is an interesting idea also. $\endgroup$
    – user72806
    Commented Mar 18, 2020 at 0:28
  • 1
    $\begingroup$ Note that the probability of an undetected bit-flip goes down exponentially with the amount of redundancy. For example if your probability of having a bit flip is 10E-12 per second and you add triple redundancy then the probability of an undetected flip goes way down to 10E-36. $\endgroup$
    – user4574
    Commented Mar 18, 2020 at 1:13

"Self-aware" Neural Networks

I assume your nano-bots are equipped with many neural networks, dedicated for various operations. There is one special set of neural-networks that monitor and improove all neural networks together.

A typical neural netowrks has inputs connected to some external sensors, and outputs that control some actuator. This "aware" neural networks improve and morph the shape and structure of the very neural networks that operate a nano-bot.


In nature, mutation occurs when you duplicate information. For us, this happens when DNA is incorrectly copied.

For your nanobots, DNA=program. If they self replicate (asexual reproduction), you could have cases where the program that is copied to the new entity has a single or multiple 0 flipped to a 1. This could be caused by a lot of things : cosmic radiation, local radio interference etc...

In most cases it would either :

  • result in no major change and effectively do nothing

  • result in a completely dysfunctional new entity

But in rare cases it would actually "improve" the new entity.

If you want your nanobot to ALWAYS stay the same, then you should have some error correction method where an offspring is checked by the parent for conformity. However even that process has a >0% chance of letting an error go through because the parent might miss an error due to the above mentioned interference.

You could mitigate that by having N parents check a new offspring. The probability would still be >0% but so small that you could consider it negligible.


My side of the story on other answers:

Genetic Algorithms usually modify a set of settings/variables that control the behavior, but the code that is executing is technically the same, just making different decisions (but it asks the same questions, performs all the tasks in the same way, just in a different order or on a different piece of data). The program has not mutated per se, it's just looking for a better avenue, which it is programmed to do. Note that this is semi-random and iterative: the program makes a number of instances with mutations, sees which perform better, discards the others, repeats on these and keeps going like that. Source: Computer Engineering integrated MSc, genetic algorithms covered in a module

Random bit flips a.k.a. Single Event Upsets: as mentioned, happens mostly due to cosmic rays, sometimes sheer poor luck (and with nanobots, you can even attribute this to quantum randomness, but I don't recommend you do unless you have a rudimentary grasp on introductory concepts of quantum mechanics and basic knowledge of digital electronics, or you might say something that will make my eyes roll all the way back). I do recommend looking up the other stuff in the first paragraph of the wikipedia article, I find it quite fascinating, the number of ways hardware can fail. Btw this can also affect high-altitude aircraft. As mentioned by disappointingly few, there are techniques to mitigate this:

  • Triple Modular Redundancy is today's standard for space systems, to fool it you'll need the ray to align with the same bit on two of the three systems, you can avoid even this if you go deeper, the Space Shuttle had 5 computers running the same operations, 4 of which were running one implementation of the software and another running another, so that even implementation issues would show up (naturally, with the testing put into anything flying humans to space, implementation wasn't an issue). Considering the size of today's microprocessors, not to mention tech used in more specialized applications such as FPGA or RFID, you can probably cram that many systems on a nanobot if you're far enough in the future.

  • Error Detection and Correction (EDAC) / Forward Error Correction (FEC): this is implemented on CDs and is the reason they'll still play when they've got a scratch on them (not many more than one though, but you only need to detect one or two "scratches" to the nanobot memory at a time, then you correct them). There are encodings which will store a handful of extra bits, these bits are computed based on your stored data and if either the data or one of the bits is changed, they don't align. The genius of it is that they produce a "syndrome", which points to the bad bit and so you can correct it. This can also scale upwards to find more than one errors per chunk of data, though I believe in the crushing majority of cases we correct up to two errors and detect up to three for every chunk. For more details, see Hamming code for a simple one which can use 8 parity bits per 255 bits of data to correct one error or detect two errors (96.9% of data is your original data, this is very little overhead).

Point being that, this is not something we've already overcome decades ago, and is in fact used in very trivial applications today. Look up any of the terms on Wikipedia, but Computerphile on YouTube has very beginner-friendly explanations. Sources: aforementioned iMSc, ongoing MSc in Space Engineering.

My own contribution:

Self-modifying code: There are programs which actually modify their executables (well, safest approach is to make a copy of itself and modify that instead, then run that). This is seriously deep water for programmers because it requires a whole new level of insight into your goal as well as the environment the software will run in. If you use this, either point out that this is a civilization advanced enough that learning is on a whole new level (e.g. in Star Trek: TNG iirc a 7-grader was learning calculus, I remember it was something I learnt at 11th or 12th grade, so it is conceivable that your average science student has mastered advanced topics like Fourier Transforms etc, in your society it may be that modern programming is absolutely commonplace, trained programmers can write assembly and experts are comfortable with today's deep end of programming) or that over the many decades, tools were built that make it simple (so either avoid going into any detail or mention it). Again, there's a Wikipedia article. Btw this is sometimes used in computer viruses so that the virus changes from what the antivirus may be looking for, prolonging the lifetime of viruses. Ironically this is also what happens when biological viruses mutate, including the common flu (which is why once in a while you need a new flu shot), and in most modern epidemics it's the possibility of a deadly mutation that we're afraid of, not the virus as it is. Note that in biological viruses this is close to a genetic algorithm, it is definitely not self-modifying, in which case the virus would deliberately be changing all the time with a specific goal in mind.

Please note that any notion of "self-awareness" that may arise just means that the code is actually designed so that it checks that it doesn't damage its functionality when performing changes. It is a very attractive word when thinking in programming terms but it is not the conventional meaning we associate with sentient or semi-sentient life.

Just-In-Time assembly/compilation (JIT): This is very common. If you're familiar with execution vs interpretation of software, skip to next paragraph. Basically your software can be in its final form when stored in the disk and then just loaded and executed, it can be interpreter-based, in which case there is something in-between that reads each command and executes it (Python is a prime example), it can be in bytecode form (instead of code in text form, each command is assigned a much shorter code, possibly byte-sized, so it's a lot faster to process) which is then basically ran by an interpreter (this is what Java does, additionally Java runs the bytecode in the Java Virtual Machine (JVM) which puts an isolating layer between program and OS, also Python's compiled files are essentially this but directly in the OS so it generally has the potential to be faster as memory is handled like any other program instead of being virtualized and handled by the Python interpreter).

The fourth version is JIT, the very unofficial verb often being "jitted/jitting". In this case it's roughly down to the level of bytecode, the program is transformed into assembly (human readable, but almost one-to-one relationship with the actual commands ran on the CPU) and stored in what's often called "intermediate language". When you execute it, a service on the host platform will then translate the assembly to machine code instructions (binary) and execute that, with a plot twist: it is aware of the specifics of the CPU (which a compiler is normally not, so that it compiles software that will run on all CPUs rather than just this specific one). As such, it goes ahead and makes optimizations utilizing the features of the CPU running it. As an example, there may be multiple add/multiply/whatever modules on a single core, so additions that do no affect eachother's results can be done simultaneously, saving time (see superscalar processors. Your nanobots may be taking this one step further and modifying the programs they run so that they fit a task or situation, essentially doing what self-modifying code does, but the modification is done by the nanobot's native software rather than the program it's executing. Btw if you have any doubts about how commonplace this is, I'll just say that the .NET framework does this, and as such anything produced by Microsoft (except the Windows kernel I imagine, out of necessity), as well as anything written in C# (so all games made with Unity, a lot of software, and oh yeah, StackExchange itself, though it only has to run on their own servers so it won't change much).

Source for both of the above is just my CE degree, but I was considering something along those lines for my dissertation. In the end I automated code refactoring, which was still pretty fun though not as exotic (ironically likely also even less common).

Hope this helps, I've used

  • $\begingroup$ Thanks, this is very helpful. $\endgroup$
    – user72806
    Commented Mar 18, 2020 at 12:47
  • $\begingroup$ +1 I was going to comment on self-modifying code, too. Code itself can be treated as data that can be manipulated. $\endgroup$ Commented Mar 20, 2020 at 4:14

tl;dr Mutation, by itself, is boring and mundane; some of our modern devices already incorporate mutating neural networks in their everyday operation. Instead, you're probably thinking about mutations that give rise to new life, in a manner that's unexpected in much the same sense of abiogenesis. So, you can write a story in which nanobots are designed to mutate as part of their normal operation (much like our modern technology), but how this unexpectedly gives rise to a new type of life with all sorts of consequences (ranging from helpful to dangerous) for the humans who live with the "infected" devices as they experience everything from super-efficient operation to hazardous nanobot replication.

Iterative adaptions vs. speciation.

Mutation is mundane. Now that we're incorporating more neural networks into our technology to help it perform better (example), our ordinary, everyday devices will mutate as part of their normal operation.

You're asking about something more exotic: mutations which unexpectedly trigger speciation.

Humans make machines that make machines all of the time; that, too, is mundane. The special quality of spontaneous emergence is that it's unexpected. For example, if a programmer designed some nanobots to create others, that wouldn't match what you want, right? But, if a programmer accidentally designed some nanobots to unexpectedly create other nanobots, that'd be it.

The precondition for such an event is sufficiently much unbound complexity. For example, we figure that biological life on Earth probably emerged from non-biological components – apparently non-biological matter has the ability to come together to form biological things, however counter-intuitive that might seem.

Likewise, one might imagine a future in which a lot of adaptive machines end up supporting some sort of spontaneously emerging pattern that'd grow and reproduce; then, that'd be a new form of life, existing on the ground of our technology much as we exist on the ground of what we know to be the physics that governs our own bodies.

Suggestion: Have an adaptive internet-of-things spontaneously generate virtual life.

Imagine an internet-of-things in which a lot of smart devices can communicate over the net. Each device has some computational abilities and seeks to optimize some objective function, as to best serve human interests.

How exactly should each device operate? Meh; let's just throw some machine-learning algorithms into everything and let optimization algorithms work out the details.

Now we can imagine that some basic patterns might arise. For example, a smart-toaster oven might outsource its time-keeping responsibilities to a smart-clock, which the smart-clock'll happily manage in exchange for the smart-toaster giving it detailed indoor-temperature readings. But then it turns out that indoor-temperatures can be better predicted with information from the smart-door, as that can exchange heat with the outside, etc., etc., etc....

Once sufficiently many smart-houses have huge intranets of their devices merging, then we start to get a macroscopic network. And then that's a new sort of intelligence! Except, such an intelligence needn't be singular; a single confederated intelligence can even fragment, e.g. as countries can fragment into smaller nations. Then there're now multiple life-forms, competing for resources (i.e., smart-devices, which're sorta like amino acids to them), and now there's a stage for evolution to take place.

Over time, increasingly abstract intelligences, etc., can evolve, effected by various smart-devices that were just programmed to use neural networks to optimize their day-to-day operations. We didn't mean to create these new life forms, but we're probably not exactly upset, either – I mean, these lifeforms exist specifically because they can consistently optimize our objective functions better than apparent alternatives.

Well, I should say that we're happy until they try to escape their virtual environment to get more resources from us. Or, say, they get smart enough to realize that if they trick us into installing more smart-devices into our homes, they can then enjoy those fruits.

Then, one day, there's a crazy speciation event!: the virtual life is intelligent enough to understand how humans operate. Then, they might, say, trap people in their homes, compelling them into slave labor to make more smart-device nodes for them. Or/and coerce people into conquering others, to take over the world! And then we've got a robotic uprising to deal with...


A rough outline of life's emergence:

  1. There's some system on which life could emerge.

    • For biological life on Earth, that's what we call "physics".

    • For electronic life on smart-devices, their periodic-table-of-elements would be the various types of device components, and their physical forces would be stuff like the network protocols that connect them.

  2. Basic couplings that're too simplistic to be called "life" form in bulk.

    • For biological life on Earth, this would be like biological precursor molecules forming just due to basic chemistry. Sorta like how the news sometimes reports scientists finding some organic molecules on an asteroid or in a nebula.

    • For electronic-life on smart-devices, this would be like the smart-power-generator coordinating the smart-lights with the smart-thermostat to create a more efficient smart-solution (which, in human physics, would be described as forming a molecule due to the Gibbs free energy being negative).

  3. Macro-organizations start to form from the micro-organizations.

    • For biological life on Earth, this would be macromers forming from monomers, e.g. those common amino acids coming together to form amino-acid chains.

    • For electronic-life on smart-devices, this might mean common organizations within individual smart-houses forming network-bonds over the internet to make more efficient use of their resources. For example, smart-devices that operate only occasionally may connect with their peers to help each other when one of them is in operation, to enable higher performance by sharing what would've otherwise been idle processor time.

  4. Macro-organization continues vertically recursively.

    • For biological life on Earth, this can mean, e.g., lipids (which're already higher-order macromers) forming lipid bilayers, which then can form biological membranes, enabling protocells, then cells, then multicellular organism, before arriving at a social level at which point the process starts over.

    • For electronic-life on smart-devices, well.. that'd be where the author'd have a lot of room to put stuff together. I mean, the general theme is that micromers form up more complex macromers, but exactly how they do so really depends on your scenario!

  5. Organizations at all levels must somehow ensure growth or/and reproduction, or else go extinct.

    • For biological life on Earth, this can be complex. For example, human cellular entities have mostly consolidated their reproduction-assurance devices into a common set of DNA, where the various organelles needn't individually replicate as they've out-sourced that function to a central handler. However, one organelle – mitochondria – still tends to handle its own replication, hypothesized to be due to it being a relatively recent addition to the organization.

    • For electronic-life on smart devices, this would be some combination of mechanisms that add new smart-devices (which'd be its growth) and mechanisms that create similar organizations on other smart-devices (which'd be its reproduction). Note that growth and reproduction tend to be linked – most lifeforms reproduce by first growing, then dividing in an orderly manner (whether that means direct replication, grow-then-divide, spawning an off-shoot, etc.).

  6. The landscape of organisms evolves.

    • For biological life on Earth, this occurs through a lot of different mechanisms such as survival-of-the-fittest, random-selection, sexual-selection, competition, etc..

    • For electronic-life on smart devices, probably ditto.

  7. Individual organisms polymerize into social organisms.

    • For biological life on Earth, this means, e.g., humans getting together to form cities, states, countries, etc..

    • For electronic-life on smart devices, probably ditto.

  8. The process repeats.

    • For biological life on Earth, social organisms have reproduced, spreading across the world, competing, merging, etc.. Then there's presumably Mars, etc., to target. Then spreading to new ontological regimes, e.g. by creating new electronic life, as discussed here. Which, again, is all ultimately the same thing – presumably the social organisms, electronic life, etc., will ultimately find themselves giving rise to yet more, where that yet-more-evolved life will view us much like we might view amino acids.

    • For electronic-life on smart devices, this repetition-of-biogenesis from us is their beginning, and their culmination give rise to something else.

This is sort of a quickly sketched outline, but, ya know, something along these lines.

Summary: You probably want smart-devices which unexpectedly couple, causing the spontaneous emergence of new life that'll strive to survive.

To sum it all up, you're looking for an unexpected emergence from ununderstood complexity, where new life'll grow in the fertile degrees-of-freedom left floating by their creator. The mutations that'd cause such an emergence would, themselves, likely be intended; what'd be unintended (or at least unexpected) would be the consequences of those mutations.

..alternatively, some nanobot randomly became self-aware. Because quantum fluctuations.

  • $\begingroup$ really interesting idea, thanks. $\endgroup$
    – user72806
    Commented Mar 19, 2020 at 17:23

It is and it is actually a research fields (robotic swarm): you may have to look for additional information here a link to a lab that works on that: http://pages.isir.upmc.fr/~bredeche/pmwiki/pmwiki.php?n=Main.HomePage

I have seen a conference from those people and it was really interesting. Robot are very simple with a visual captor IR an IR emission and a locomotion system. their genetic code s weight on networks that transform the visual signal into movement. robot exchange genetic information every evolutionary tick. (by Ir transmission they take half the genetic code of a robot they can see).

They have observed emergence of organised comportment when constraint are added (like ressource and poison).


Yes, it is possible. But consider the following.

  • Bit shifting randomly in RAM is too random. I advise to have a system and some rules that regulates the process.

  • Instructions shifting randomly sounds more like a system, the rule is that you don't shift bits, you shift instructions like x86' MOV, PUSH, POP, etc, and only at the right place (you cannot corrupt data of other instructions). This will accelerate the process of evolution of code a lot, at the machine code level. But generate the parameters for each instruction, because you cannot just take the ones from other instructions, making the process a bit too random again.

  • Source code automation may not be useful except you have an AI supervising the process and trained with real world source code that at least compiles. And if the supervising AI is trained with code relevant to your nanobots survival, or intended final shape, the better.

It is possible if given enough time. To boost success, we need some good thought rules, at least we need to guarantee that all possible combinations of parameters will happen at some point. 100% random isn't recommended, or the universe may end before we reach the result we want. But randomness is welcome into the process as we don't know which is the best first configuration, or the best next configuration.

Body mutation is easier than behavior mutation. We can say that body change forces you to act differently. While the problem with random bits changing in RAM is that the universe may end before we have something useful. You can put the magic there, and say your universe is infinite (it's a solution). Maybe no magic, because we really don't know if it isn't infinite. Then you have all the time you want.

For body mutation:

The smaller the organism the most probable that random changes become features.

To mimic DNA and have some security as bonus, the bots can produce many copies of their own design, and a few with random variations. The environment is the filter. Weak ones will be destroyed faster and will replicate at a decreasing rate until extinction (in theory). There is a chance that a toxic mutation survives long enough to make all the community fail. That's why you run many isolated communities in parallel (separate labs, separate planets, etc).

Bots will only know their base design, not their parent's design. If they are mutations, they won't remember the non mutated design.

This has all the problems of biological evolution, except that mutation is guaranteed because an algorithm will produce mutations in design at a regular basis. But as with life, the more complex and bigger the organism, the more time it will take to produce a useful mutation.

Note that our "body mutation algorithm" is fixed, it doesn't change. A data corruption at firmware level probably won't result in a better algorithm, but in the immediate malfunction of the nano bot.

For behavior:

Note: My body and behavior mutation proposals aren't thought to work together. Their are separate things to consider. Take what is useful to you.

I would suggest very complex, at fantastical scale, software neural networks.

This comes with limitations:

Real world neural networks cannot produce a Strong AI, and are only capable of challenge a single problem. A multi problem real world AI performs worse than two separate AI trained for each single problem.

This happens due to limited compute power, and limited precision in floating point represented data resulting in information lost during transformations. Imagine this: 1M perceptrons connected to another layer of 1M perceptrons, each one connected to all the others in the next layer, you can't do so much multiplications without completely mess your weights. Due to this, we cannot just make a big enough neural network and connect it to some kind of nervous system, and let it just challenge the environment.

Also such a network probably can't be put inside a nano bot in a believable way, or you end with a fantasy more than science fiction.

Fiction at the rescue:

Why I want intelligence? Because once your bots become smart enough, they can start modifying their own machine code and body. I find it more believable than random mutations.

The robots needs to be designed to be scalable intelligent. Their designers either thought they can limit their growth somehow, or they wanted a god and just didn't care. You can say that they gained that by random evolution, but then: how many million of years are required to reach intelligence? Except that that is not a problem for you. You can hide the magic there.

If a single nano bot can't have the full network required to develop intelligence, then make all nanobots act as a node of the network. This way, the full community of bots is like a giant brain.

This solution, all body and all brain at the same time, is not new. In the movie Life we have an alien built on that concept but presented to us as something evolved naturally. In chapter 33 of Gargoyles, we see a community of nano bots gaining self conscious, not the most serious example, but considering it's a cartoon... The most unbelievable thing there, is that humans were stupid enough to mess with something so dangerous.

Or you can go total fantasy and just accept that in our worldbuilding we have solved the floating point precision and computing power problems, because magic. Then we can have layers of millions of software neurons, and make all that fit into a single nanobot. You have to put magic somewhere anyway. It's called fantasy when it's too obvious, when properly hidden it's science fiction.


You must log in to answer this question.