# Mutation Phase

Here, randomness is introduced to algorithm. With mutation, certain offspring are subject to (low probability) random mutations at each crossover, meaning that some of their traits randomly change (or mutate) and are not inherited from their parents.

![](/files/-LrPm35WdCzu-9fAk8ML)

The motivation for mutation is that, with some luck, a mutant offspring may have even better features than its parents, making it more likely to be selected for crossover in the next stage and that its good genes become entrenched in the population.

The logic is the same in biological evolution - for example, mutation allowed sea creatures to finally walk on land. Mutation is therefore useful for ensuring genetic diversity.

In technical terms, mutation helps to ensure that the algorithm doesn’t get stuck at a local optimum – that is, a set of features that are arguably quite good but still not the best.

This might happen when a set of good features is identified early on and the algorithm quickly breeds a lot of offspring with these features. Without mutation it can be hard to break out of this cycle and find an even better solution.

By lowering the odds of a random mutation at each crossover, the algorithm is more likely to converge to a global optimum - the best possible solution for that problem.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.generativedesign.org/02-deeper-dive/02-04_genetic-algorithms/02-04-06_mutation-phase.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
