schrum2 / MM-NEAT

Modular Multiobjective (Hyper) Neuro-Evolution of Augmenting Topologies + MAP-Elites: Java code for evolving intelligent agents in Ms. Pac-Man, Tetris, and more, as well as code for Procedural Content Generation in Mario, Zelda, Minecraft, and more!
http://people.southwestern.edu/~schrum2/re/mm-neat.php
Other
50 stars 20 forks source link

Block Diversity Fitness #768

Closed schrum2 closed 2 years ago

schrum2 commented 2 years ago

Extend CheckBlocksInSpaceFitness to make BlockDiversityFitness. 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 of Block objects where each Block contains its position. Therefore, the first thing you should do is create a 3D array of int and fill every index with the value of BlockType.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.

richeyme commented 2 years ago

Did a successful run for the first time and we're getting really high fitness scores image

This is what the structures ended up looking like: 2022-06-01_16 38 07

richeyme commented 2 years ago

Here are what the redirect confined snakes looked like when they finished 2022-06-03_14 42 11

richeyme commented 2 years ago

Here are what stop confined snakes looked like when they finished 2022-06-03_14 50 27

richeyme commented 2 years ago

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