Closed schrum2 closed 2 years ago
Did a successful run for the first time and we're getting really high fitness scores
This is what the structures ended up looking like:
Here are what the redirect confined snakes looked like when they finished
Here are what stop confined snakes looked like when they finished
To me it seems like it is a lot easier for the large cubic like structures to have a lot more variety but I can definitely tell that the snakes are also way more diverse than they would be regularly
Extend
CheckBlocksInSpaceFitness
to makeBlockDiversityFitness
. The point is to reward structures that feature a lot of blocks adjacent to blocks of different types. Specifically:Go through each block X. If the block X is not AIR, check the 6 neighbors of X. Each of those neighbors whose type is different from the type of X adds a point to a tally (including AIR blocks)
In order to do this, you will need to have a way of easily looking up the neighbors of any given block, but the input is simply a
List
ofBlock
objects where eachBlock
contains its position. Therefore, the first thing you should do is create a 3D array ofint
and fill every index with the value ofBlockType.AIR.ordinal()
. Next, loop through the list of blocks and place the type of each block at the appropriate place within the 3D array (you will need to subtract out the corner coordinates to get relative coordinates for the 3D array).A clever thing you can do is make the 3D array 2 units larger in each dimension. This provides a buffer of AIR around the shape, so you won't have to check for array index out of bounds errors, but you will need to offset your coordinated by 1 to make this work.