So, in the near-future, scientists are trying to develop better and better AI, which are better and better at the tasks they are designed for.

However, rather than coding them, there is another method I came up with which they could potentially use: software breeding.

An algorithm is given the capacity to replicate itself. However, every time it copies itself, a few parts of the copy’s programming will not be the same as the “parent’s” but will be randomly generated. This causes the creation of an algorithm with slightly different characteristics. Most of these characteristics, or “mutations,” will be useless, but a few may improve the AI’s ability to perform its designated task.

Over time, the useless mutations are weeded out, and the useful ones are retained, until you end up with an AI that is much greater than the sum of its predecessors.

However, considering the time it would take to “breed” AI in this way, what are the advantages to be had in doing so, rather than simply coding it?

  • 30
    $\begingroup$ "software breeding" You mean genetic programming? And/or genetic algorithms? In particular you describe it tuned with some amount of mutation but probably low-ish crossover. $\endgroup$
    – VLAZ
    Feb 14, 2023 at 12:44
  • 2
    $\begingroup$ If you squint, this is how AI, such as ChatGPT, already works. $\endgroup$ Feb 14, 2023 at 19:26
  • $\begingroup$ @user253751 and it is also why something like Tay failed so miserably (e.g.: bad mutations). $\endgroup$
    – Nelson
    Feb 15, 2023 at 0:51
  • 4
    $\begingroup$ VTC: Opinion-based. You got lucky and happened to stumble across a generic idea that has already had decades of traction you didn't know about. In general, the idea of coming up with some ultra-simplistic explanation of something and then asking us to explain the advantages fits squarely in the high concept question category. Don't let the phrase, "I'd rather be lucky than good" fool you. It's better to be lucky and good. $\endgroup$
    – JBH
    Feb 15, 2023 at 2:18
  • $\begingroup$ this is not only highly inefficient but also borderline-dangerous since a random breed could inherit the "genetic" feature to wipe it's own database or start a bunch of missiles. also this is not how software works, not even the aformentioned chatgpt. there are some automatic test-systems that use this method to find bugs, but in general a process which modifies it's own codebase is viewed rather "parasitic". there is another point: in many cases there's only ONE correct solution to a problem, where variations only are in naming and styling of the code which is a useless feature for an A.I. $\endgroup$
    – user59660
    Feb 15, 2023 at 14:28

8 Answers 8


Genetic Algorithms vs Programmed Algorithms

These are 2 very real things which are both widely used and debated today. While Genetic Algorithms are useful, they are not a magic cure to never have to write your own code again. They both have thier specific uses such that no one method can ever truly supplant the other.

Things they have in common:

They both need a skilled developer to establish goals and understand the end product of what they are trying to achieve. Without a well established goal, neither kind of development will yield useful output.

The Advantages of Genetic Algorithms

Genetic Algorithms are best used when you know the goal, but have only a vague idea about how to meet that goal, or you predict the solution to be so complex that you can't really figure out how all the bits and pieces exactly need to fit together. For example, if you want to make a truck driving algorithm, and you don't want it to crash, but you don't know how to create a function that accounts for every possible driving condition, then simply creating a model that more-or-less works, generate a bunch of randomized variants of it, and then go through the natural selection processes of smashing 10s of thousands of virtual cars until you arrive at a variant that does not crash itself. This will probably come up with a more robust solution than trying to spend weeks working out complex physics equations to try to guess a good working solution only to find that there is something you got wrong, but there are so many factors to consider you can't even guess what you need to tweak to get it right.

The Advantages of Programmed Algorithms

Programmed Algorithms are actually the better solution to most problems you will ever face. Programmed Algorithms are very quick, easy to make, and precise as long as you fully understand both the problem and the solution you are working on. In most cases, it is quicker to just write the algorithm you need than it is to just set up GA to begin processing. You are also less likely to get an unexpected behavior because you are hard setting all of your preconceived notions into what you are writing. So, if you want to make a character walk across your screen, everything you understand to be true about walking will apply to the solution, but an GA might decide its better to do cartwheels across the screen just because it has no biases towards walking... this is fine if all you care about is getting to the other side, but in any case where HOW you get there matters, Programmed Algorithms are usually your best option.

Disambiguating Genetic Algorithms

There is some debate about whether or not the OP is describing GAs or not. While many Genetic Algorithms don't work exactly as the OP has described, some actually do. At the top level of every Genetic Algorithm you have a Master Algorithm that guides you towards established goals by setting criteria for selective fitness. This Algorithm is never self-modifying/mutating. Letting this Algorithm rewrite itself would result in an output that is purely random because the goal of your Algorithm would become a randomly changing moving target. The Master Algorithm is basically equivalent to the Biological Imperatives in classical evolution. As organisms, our Biological Imperatives include stuff like acquiring resources, regulating our internal organs, and avoiding harm. So, basically think of these as defining a fixed set of rules about how, your environment impacts your fitness.

In most cases of GAs, there is only a master algorithm. It may be able to randomly modify it's coefficients following a set pattern, but the algorithm itself does not change. However, there is a more complex variety of genetic algorithm that incorporates sub-algorithms that can be randomly mutated. As long as the master algorithm is unchanging it will steer the evolution of your sub-algorithms towards the original goal.

These sorts of multi-tiered Genetic Algorithms have all of the same advantages and disadvantages I described above, but cranked all the way up. It takes a lot more work to build than a more basic GA, and it can take a lot more generations and computation to come to a useful final product... that said, these kinds of GAs are used to solve the most complex and nebulous of problems where developers don't even know how to write an approximate algorithm to get started with.

  • $\begingroup$ Genetic algorithms are programmed algorithms. Everything about them is planned and designed. It is just the results that are unpredictable. This is different from the OPs requirement which is self-modifying code. This has a whole other level of unpredictability. $\endgroup$ Feb 15, 2023 at 2:36
  • $\begingroup$ @chasly-supportsMonica Depends on your interpretation of "mutations". Many genetic algorithms include a jitter function that does not change the base algorithm per say, but it does add generational randomization (like mutations) to help it break out of dead end ruts and find possible alternate paths to optimize with. Also, some genetic algorithms also have sub algorithms that they can rewrite completely, but the top level algorithm can't rewrite itself or else you lose the established goal and you just get a random noise generator $\endgroup$
    – Nosajimiki
    Feb 15, 2023 at 17:09
  • $\begingroup$ So there are genetic algorithms out there that meet the OPs criteria. That said, I mostly interpreted this question to be about the advantages and disadvantages of each approach to programming, not the exact technology at play $\endgroup$
    – Nosajimiki
    Feb 15, 2023 at 17:11

What you describe is what happens with genetic algorithms:

In 1950, Alan Turing proposed a "learning machine" which would parallel the principles of evolution.[32] Computer simulation of evolution started as early as in 1954 with the work of Nils Aall Barricelli, who was using the computer at the Institute for Advanced Study in Princeton, New Jersey.


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. Some examples of GA applications include optimizing decision trees for better performance, solving sudoku puzzles, hyperparameter optimization, etc.


During each successive generation, a portion of the existing population is selected to breed a new generation. Individual solutions are selected through a fitness-based process, where fitter solutions (as measured by a fitness function) are typically more likely to be selected. Certain selection methods rate the fitness of each solution and preferentially select the best solutions. Other methods rate only a random sample of the population, as the former process may be very time-consuming.

When it comes to their advantages

Genetic algorithms have a number of advantages over traditional methods, including the ability to find solutions to problems that are difficult or impossible to solve using traditional methods. Genetic algorithms are also less likely to get stuck in local minima, and can often find better solutions than traditional methods.

  • $\begingroup$ Comments have been moved to chat; please do not continue the discussion here. Before posting a comment below this one, please review the purposes of comments. Comments that do not request clarification or suggest improvements usually belong as an answer, on Worldbuilding Meta, or in Worldbuilding Chat. Comments continuing discussion may be removed. $\endgroup$
    – L.Dutch
    Feb 14, 2023 at 20:20

I think you can get a lot of mileage based on how machine learning works. Minor personal complaint about the industry: every term you hear about or read about when it comes to A.I. is, in my opinion, misleading and generally absurd. "Machine learning" sounds super impressive and advanced until you realize it's actually kind of a simple algorithm that doesn't do much and can easily get things very wrong and be sent off the rails by bad input. ("A.I." itself is almost always a misnomer, outside of Hollywood.)

And perhaps that's what the "AI breeding" program is trying to address, in fact.

The way machine learning works is that you have to feed in a data set and give the algorithm feedback on what it's looking at. Suppose you were Amazon, wanting to sell more music. The inputs are soundwave data and user preference. The machine learning is going to try and come up with patterns in the soundwave data you "liked", versus soundwave data you did not "like", and from that it can try to match you up with new music.

But, you know, you were going through that Madonna phase for a while and ended up training an AI that now believes you love female vocals within a certain range and that's all it wants to suggest to you. Its past training has fixated it on a pattern that might not quite be what you had in mind (or has changed in the 10 years since you created it, and the AI is slow to adapt to your changing tastes).

Possible solution? AI breeding! The Amazon music-picking AI has "children" which intentionally wipe bits of the "parent's" model, allowing the child to re-learn, either based on new data or just to see if it picks better patterns this time. Unknown to you, every time you start up Amazon Music, you might be getting a different "child" giving you music suggestions. Less successful ones are wiped and recycled. More successful ones are kept and may become a new "parent".

In this way you don't just have "an AI", but rather, an entire "family" of AIs, and ones that return better results replace the ones that don't. It may help you develop a more ideal model, by having many different ones in play at the same time.

As for breeding vs "normal programming" I kinda left that out originally because as I read it, that's already covered by ML/AI vs normal programming. In normal programming (as I interpret this), the code designer looks at data, decides how it will be handled, and does so directly. i.e. if you purchased albums by Madonna, then the program will recommend more Madonna albums, as well as albums frequently purchased by other people who also like Madonna. There's no ML/AI, it's just straightforward code paths. This is easy to do for simple data sets with simple inputs.

Machine Learning as a concept is designed to algorithmically find patterns in complex data. This can lead to false positive, false negatives and general weirdness but the advantage is potentially finding patterns that humans might have never found, because the data was just too deep or complex to wade through with the Mk.1 eyeball.

  • $\begingroup$ You're still just describing a GA, like OP is. In fact, it's a variation on the concept of a GA which trains a neural net $\endgroup$
    – VLAZ
    Feb 14, 2023 at 15:34
  • $\begingroup$ @vlaz My understanding of a GA is that it's a single ML model, but iterates through its own results -- a literal iterative improvement over base ML. By comparison, Tay vs Zo is about modifying (or scrapping) the model itself. Microsoft didn't just iterate through results to seek improvement, they wiped the learned model and started over (and probably added input filters). I think OP wants something more like that: not a single model which iterates solutions (GA), but models that branch ("breeding"). $\endgroup$
    – JamieB
    Feb 14, 2023 at 15:42
  • 1
    $\begingroup$ General-purpose chatbots has been on the absolute cutting edge of AI development, and will likely remain there for quite a while. Conversation touches on so many different aspects of human knowledge, so the ideal of such a chatbot would need to match human-level intelligence. So it's probably not the best example of AI "easily getting things very wrong". AI is successfully used in a wide range of applications. Although AI is indeed often susceptible to adversarial attacks, as per the chatbot example. $\endgroup$
    – NotThatGuy
    Feb 15, 2023 at 16:03
  • 1
    $\begingroup$ The development of recommender systems has extensively considered how to trade off long-term and short-term trends, as well as how to be responsive to which recommendations users do and don't react to. What you describe is some combination of what happens with genetic algorithms during training, and ensemble models and also just regular retraining of any model. AI researchers and practitioners have thought a lot about how to continuously find the best model. $\endgroup$
    – NotThatGuy
    Feb 15, 2023 at 16:23
  • 1
    $\begingroup$ The Madonna Problem can be countered by treating Jitter as a variable. Jitter is how random your new generations are, but many AIs treat this as a constant, but if you tie jitter to something like how often you press the like button, then the AI can pick up on when you want to broaden your sample list and help you transition into new obsessions whenever you get bored of the last one; so, good AIs have ways to preform large drifts to get out of ruts without scrapping it and starting over $\endgroup$
    – Nosajimiki
    Feb 15, 2023 at 17:56

Genetic Programming (not genetic algorithms)

Genetic algorithms are not what the OP is asking for. The correct term for self-modifying/reproducing programs is Genetic Programming - a subject that has been well researched but, to my knowledge, has not yet produced any startling results. The subject had its hey-day in the late 1990s but there are still international conferences held regularly. Here is the latest textbook I can find

enter image description here https://www.amazon.co.uk/Genetic-Programming-Practice-Evolutionary-Computation/dp/981198459X/ref=sr_1_15?crid=18TOSPFIGDPQZ&keywords=genetic+programming&qid=1676407371&sprefix=genetic+programming%2Caps%2C96&sr=8-15

Genetic Programming is a domain-independent method that genetically breeds a population of computer programs to solve a problem. Specifically, genetic programming iteratively transforms a population of computer programs into a new generation of programs by applying analogs of naturally occurring genetic operations. The genetic operations include crossover (sexual recombination), mutation, reproduction, gene duplication, and gene deletion.


  • $\begingroup$ This is just genetic algorithms applied to the space of programs. (Likewise, genetic algorithms over the space of neural networks are sometimes called GANN.) $\endgroup$
    – wizzwizz4
    Feb 15, 2023 at 0:20
  • $\begingroup$ *wizzwizz4 - Not so if you recognise that the field includes self-modifying programs. A GA has a fixed genetic structure devised by the programmer. A GP can develop its own genetic structure by overwriting copies of its 'DNA' or even modifying how the DNA works. In theory (I don't know if this has been dome - I think it has in the field of Artificial Life) it could develop a genetic structure from scratch. $\endgroup$ Feb 15, 2023 at 0:32
  • $\begingroup$ Genetic algorithms operate over a space where genetic operations (usually sexual crossover, plus some number of domain-specific asexual mutation operations) can be defined. The space of valid computer programs in some language is the space. It can't develop a genetic structure from scratch, for the same reason every programming language must be implemented in a different programming language: bits don't have intrinsic meaning. It can start from "empty program", but you can do that with most genotype spaces. $\endgroup$
    – wizzwizz4
    Feb 15, 2023 at 1:10
  • 1
    $\begingroup$ @wizzwizz4 - There are two points here (1) The OP is not asking about generic GAs, the OP is asking about 'software breeding' which could be considered a specific case of a GA. However I don't believe it is necessarily so in the usually accepted sense. (2) The biological genetic code could in theory be simulated entirely in a computer language. That does not mean that DNA has no meaning (although there's a big philosophical point here ) ... $\endgroup$ Feb 15, 2023 at 2:05
  • 1
    $\begingroup$ The underlying "language" that DNA is implemented in is physics: that's the same underlying "language" that machine code is implemented in. All "software" is data for some process that, eventually, terminates in a physical system influenced by the physical representation of that data to behave in certain ways. And no… chemistry and physics can't develop anything from scratch: they need mass-energy in a configuration with juuuust the right amount of entropy… $\endgroup$
    – wizzwizz4
    Feb 15, 2023 at 2:56

If you squint a bit, this is how AI such as ChatGPT already works.

ChatGPT (and other GPT systems, and other neural networks) were not created by breeding, but more like asexual reproduction: the training system repeatedly causes mutations and then selects the best one. Actually it uses an algorithm called "gradient descent" to predict the best mutation which is faster than making them randomly and selecting one. But it's kinda similar if you squint.


  • We can create systems we have no idea how to actually write, just by having a large set of input and output data. Before GPT, we didn't know how to make computers understand language. After GPT, we still didn't know how to make computers understand language, even though we did it. That's because the evolution/training system did it for us.
  • A very similar evolution system can be used to generate many different softwares: one that talks to you, one that writes poems, one that sings music, one that controls a space shuttle, one that boils water, etc.


  • Because nobody wrote the software, nobody knows if there are any surprises hiding in it.
  • For the same reason, it can't be relied upon. It probably won't crash (that part was written by humans), but the chat-bot could "decide" to start outputting nothing but "lol" for no reason. You don't want this kind of software in charge of anything important. If you put one in charge of an aeroplane, it might fly better on average, but you can't prove it won't crash the plane.
  • 2
    $\begingroup$ You have to squint a lot. Gradient descent behaves differently to GANN: GANN can solve problems gradient descent can't (e.g. neural networks as video game AI is quite hard with gradient descent, but quite easy with genetic algorithms) but is much slower. $\endgroup$
    – wizzwizz4
    Feb 15, 2023 at 0:22

As previous answers explores, your idea is not so different from Genetic Programming / Genetic Algorithms / A.I. methodology in general.

Just a little point to develop about those various methodology in the quest of a perfect AI to rule them all.

Ok you obtain a generalist enough framework that allow your programs to breed by themselves and explore various sets of heuristic. And then the question becomes, how do you tests those new baby programs? Or in another way, how do you know which mutation are useless ?

In evolution this is a metric called fitness. And my gosh fitness is a bitch. Because to test the fitness you need the reality. Yes sure, you can make a simulator to test the solutions (if you think making a simulator is more fun than answering the problem, usually it is not) or you can use big sets of data (but then the sampling as well as the discrete nature of the data will introduce bias).

You can link this idea of fitness to practical example such as "why Theory do not answer every problems" or "why diversity is important" or "why Skynet is wrong in terminator", I will skip speaking about some stupid genocidal dictators here.

Up to now there is no solution to this problem, and depending of P-NP problem it may even not be one. This is maybe even why "time" do exist and we are not into a crystallin space-time (nicely put in the hitchhiker guide).

Still evolution is made based on breeding not programming, I will skip speaking about stupid creationist theories in here. So your idea is far from being absurd, but it may be difficult to control, and also it is few century old.


The disadvantages would be:

  • It is computationally not very efficient. Code is not like other domains - the mutated program must be syntactically correct (possibly trivial to achieve) but also needs to make semantic sense. An awfully high amount of mutations will weed out because they simply do not "compile" or do not work. That said, if your world is at a point where artificial general intelligence is around the corner, they probably have an abundance of computing power.
  • It is unbelievably hard to implement this kind of genetic algorithm since you're not only tuning some parameters or working on some relatively narrow field like image recognition or finding YouTube suggestions, but are trying to solve a problem where the humans working on it fail miserably to even come up with an inkling of an idea how to do it. To solve this kind of issue with random mutation seems to be unlikely. Evolution generally is not goal-driven, but simply goes wherever it goes, to fill in the available spaces in the environment. Even programming the decider (which judges whether the next generation is actually better than the previous) will be very hard indeed.
  • There is the "halting problem". It is a deep fundamental fact that it is never possible to generally tell whether a given algorithm will ever "halt" (i.e., finish its calculation) for a given input, without running said algorithm - and if it does not halt, it will take an infinite amount of time. So actually running those mutated programs to see if they are better requires some hefty heuristic; i.e. a cut-off time where you forcefully abort the run. You could have the break-through AGI on your hand but never know because you killed it a few microseconds too early.

The advantages would be:

  • It could fathomably be the only way to get to AGI in the sense that today, we have no real idea how to do it, at all, or how to recognize it if we should have it.
  • It can just run happily on its own in some, probably rather large, corner in your world, and the highly-qualified researchers are free to do other stuff (or to die out through war or famine, depending on how your story goes).
  • Most importantly: it is an awesome plot device. This process would by its nature spawn all manners of AIs. Good ones, bad ones, absolute devils. I have read some books in the past which had similar features - i.e., self-replicating and modifying AI, and I found them very enjoyable.

Bad idea.

Most people here are suggesting genetic algorithm as a viable option. As someone who has actually worked with this, let me tell you, what you are suggesting is not even close to being optimal. Your random "mutations" you want to do with an AI needs extremely strict parameters to not reinvent the wheel for a hundred times. An AI can never write a good enough code to cover that. There is a reason why CHATGPT was banned in Stack Overflow. It might look legit, but the code it writes for complex problems are almost always useless. Asking it to mutate itself is just asking for trouble.

Even if you managed to make an AI good enough to mutate itself, the concept of genetic algorithm itself leaves a lot to be desired. As an example, here is my research on this topic. (https://computerresearch.org/index.php/computer/article/view/1842/1826)

You can check the full journal here: (https://computerresearch.org/index.php/computer/issue/view/306)

If you cant be bothered to read it through, TLDR: Genetic algorithm is visibly bad in handling small datasets, both in time and memory complexity. This is NOT something you want to use in a day to day problem solving basis. It cant be commercialized. And an agency rich enough to fund a project large enough for this to be effective isnt gonna let an AI write random code. Coding takes practice and effort to be good. Most of us in the industry can only achieve that after years of practice. A software by itself can't magically get good at solving problems. It might have some gimmicks like playing a board game better and better, but that is about it.

TLDR: Can you do it? Yes. Can you pull of the sales pitch? Improbable.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .