Created
November 16, 2019 06:11
-
-
Save IntegerMan/0ec49272a6c271d5d9119475533b8b0f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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