Skip to content

Instantly share code, notes, and snippets.

@Albertbol
Last active March 7, 2021 19:31
Show Gist options
  • Save Albertbol/08167a796dcc497acb2839f6b6ba8336 to your computer and use it in GitHub Desktop.
Save Albertbol/08167a796dcc497acb2839f6b6ba8336 to your computer and use it in GitHub Desktop.
const mutationRate = 0.01
mutate(child) {
const chars = child.split('')
for (let i = 0; i < chars.length; i++) {
if (Math.random() <= mutationRate) {
chars[i] = newChar()
}
}
return chars.join('')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment