schrum2 / EvoCraft-SCOPE

0 stars 0 forks source link

Minimum required blocks #27

Closed schrum2 closed 2 years ago

schrum2 commented 2 years ago

Sometimes a "shape" is generated that is nothing but empty space. This is boring, and should be prevented.

Make a command line parameter MINIMUM_REQUIRED_BLOCKS whose default value is sys.maxsize (need to import sys), which means there is effectively no requirement. Also make parameters USE_MIN_BLOCK_REQUIREMENT (default False) and MIN_BLOCK_PRESENCE_INCREMENT (default 0.1)

Now, have query_cppn_for_shape count the number of non-air blocks that are generated. If USE_MIN_BLOCK_REQUIREMENT is True and the resulting number is less than MINIMUM_REQUIRED_BLOCKS, then the effective presence threshold (for this shape only, NOT for all future shapes) will be incremented by MIN_BLOCK_PRESENCE_INCREMENT. Basically, the presence threshold from args needs to be saved in a separate variable that changes if needed. Also, all the code for generating the blocks needs to be in a loop that depends on a boolean that sees if either USE_MIN_BLOCK_REQUIREMENT is False or the number of non-air blocks was big enough.

At a high-level, the CPPN will generate a shape, but if there are not enough blocks, it changes its presence threshold (which makes it more likely to place blocks) and tries again. Eventually, the effective presence threshold should be big enough that enough blocks are generated.

alejmedinajr commented 2 years ago

Added the new command line parameters for this issue (MINIMUM_REQUIRED_BLOCKS, USE_MIN_BLOCK_REQUIREMENT, MIN_BLOCK_PRESENCE_INCREMENT).

alejmedinajr commented 2 years ago

The last commit causes an infinite loop due to the value of presence_thresholdbeing assigned inside a different helper function.

schrum2 commented 2 years ago

I think this is resolved. Comment, test, and then close if appropriate

alejmedinajr commented 2 years ago

Commented and tested, seems to work now. I also changed the default value for MINIMUM_REQUIRED_BLOCKS to 10 and USE_MIN_BLOCK_REQUIREMENT to True.