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

Missile with multiple targets #926

Closed schrum2 closed 1 year ago

schrum2 commented 1 year ago

It occurs that with the slime target located at a specific location, this means that for missiles to succeed, they have to fly in the right direction. Although possible, this seems challenging.

Perhaps an easier task we could try first is having multiple targets around the shape, but there are unfortunately a lot of different ways we could do this. Let's try starting with four targets surrounding the shape in the N, S, E, W directions. Basically, we're only excluding Up and Down. We can have a boolean parameter: "minecraftCompassMissleTargets", and if it is true, then instead of the one target we make four targets, and this is how we place them:

Currently, in preSpawnSetup of the missile fitness, the code adds shapeCorner to targetCornerOffset to get the target location.

A second target can be placed with shapeCorner.sub(targetCornerOffset). This gives us a target on the opposite side of the shape (180 degrees).

To get a shape 90 degrees to one side, multiply x-coordinate by -1 and then swap x and z.

To get the shape rotated the different direction by 90 degrees, multiply z-coordinate by -1 and then swap x and z.

This will spawn the 4 targets around the shape, but you also have to update the fitness calculation. When "minecraftCompassMissleTargets" is true, there are 4 times as many blocks to destroy. You need to read the locations of all 4 target locations and add up the blocks.

schrum2 commented 1 year ago

Fitness calculation needs to take all targets into account. The new minimum fitness has to be multiplied by the number of targets, and the new calculation has to subtract the number of blocks in ALL 4 locations.

schrum2 commented 1 year ago

I fixed the fitness calculation