Closed philswatton closed 1 year ago
I should add: I've done a little testing with these but not much as it's getting late in the day to be working. Will test some more tomorrow!
Also, just realised i forgot to add the ability to turn mutation off completely. Will add it tomorrow!
Thanks a lot for this! I see the general idea -- my plan is to merge this in its current state so I can resolve some conflicts with the other PRs (somewhere along the line, your work wasn't rebased into other branches, so I'm taking this to be the most up-to-date stuff!)
This should be a good skeleton for me to design some functions based on the previous work :)
This PR adds the two main genetic operations: crossover and mutation.
Crossover works to preserve good 'genes' (pokemon team mebers) by selecting two 'chromosomes' (teams) (with replacement) in proportion to their fitness, then swapping their 'genes' (pokemon).
Mutation works to maintain 'genetic' diversity (pokemon diversity) by occasionally randomly adding members to the teams and removing old ones.
There's been some discussion about how best to do this, so I've made this code as modular and as flexible as possible.
For crossover:
crossover = build_crossover_fn(crossover_method = locus_swap, locus=3)