Closed MuellMark closed 2 years ago
Parameter: PREVENT_DUPLICATE_BLOCK_TYPES defaults to True (once you get it working)
This will affect the mutate method of the custom genome.
Also, crossover too. Two different genomes could have the same block type but in different locations, and you could end up with duplicates. If PREVENT_DUPLICATE_BLOCK_TYPES is True, then as you loop through the two parent genomes, you can add the type given to the child to a set
. However, before adding to the set
, check if it contains the thing you are about to add. If it does, then take the value from the other parent. If the block types from both parents are already in the set, then get a new random type (within the bounds of the allowable block types).
Edited mutate and crossover to disallow duplicates (when selected).I also added a statement into main to make sure there aren't more blocks in a genome's block list than there are types of different blocks.
Right now the block_list can have duplicates. We should change it so that this can be toggled on and off.