Skip to content

Instantly share code, notes, and snippets.

@IntegerMan
Created November 16, 2019 06:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IntegerMan/0ec49272a6c271d5d9119475533b8b0f to your computer and use it in GitHub Desktop.
Save IntegerMan/0ec49272a6c271d5d9119475533b8b0f to your computer and use it in GitHub Desktop.
let mutate (random: System.Random, magnitude, value) =
(value + (random.NextDouble() * magnitude))
|> max -1.0 |> min 1.0
let mutateGenes (random: System.Random) mutationChance genes =
Array.map (fun g -> if random.NextDouble() <= mutationChance then
mutate(random, 0.5, g)
else
g
) genes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment