schrum2 / EvoCraft-SCOPE

0 stars 0 forks source link

Make an option to disallow duplicates in the block_list #36

Closed MuellMark closed 2 years ago

MuellMark commented 2 years ago

Right now the block_list can have duplicates. We should change it so that this can be toggled on and off.

schrum2 commented 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).

MuellMark commented 2 years ago

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.