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

TimedEvaluationMinecraftFitnessFunction #870

Closed schrum2 closed 1 year ago

schrum2 commented 1 year ago

Before starting work on #863 , complete this issue. Create a class TimedEvaluationMinecraftFitnessFunction that is abstract. Although we hope that eventually, the ChangeCenterOfMassFitness can be modified to be an extension of this, do not attempt to modify the ChangeCenterOfMassFitness at all. Just make TimedEvaluationMinecraftFitnessFunction as a useful starting point to build off of. Here is how it should work:

This fitness function will assume that a shape will be spawned at a corner, evaluated for some amount of time, and then assessed. It will also assume that the space is cleared at the start of each evaluation. Some of the code you use can be copied or adapted from the getCenterOfMassBeforeAndAfter method of ChangeCenterOfMassFitness.

In fitnessScore, first clear out the space around the designated corner. Note that ChangeCenterOfMassFitness also has a loop to verify that the space is clear before spawning a shape in. Next, spawn the shape. Then, wait/pause for a fixed amount of time (this is simpler than ChangeCenterOfMassFitness, since you are not going to periodically check, though we might add that). Finally, end by returning the result of a method call to calculateFinalScore which you will specify as an abstract method in this class.

The idea is that when you move on to #863, you will extend this class, and only have to implement the calculateFinalScore method and nothing else.

This is a pretty complicated issue, and the path I've laid out above is just brainstorming, but could need lots of adjustment. Still, it gives you a starting point, and it avoids the hassle/challenge of needing to make things work well with ChangeCenterOfMassFitness, which is hyper-specialized, and which I am hesitant to change unnecessarily.

schrum2 commented 1 year ago

Above, I said that this function would simply wait a fixed amount of time instead of periodically reading the shape. However, I thought of a way to generalize this to give the fitness functions more information. Have a loop like in the change center of mass fitness function that periodically reads the shape from the evaluation space, and save all results in a history. The change center of mass fitness tracks this using a list like this:

ArrayList<List<Block>> history = new ArrayList<>();

Each time the blocks are read from the world, they are added to this list. You can send this list of historical readings to the calculateFinalScore method as a parameter. Some functions might ignore this, but others could make use of it.

schrum2 commented 1 year ago

We have two fitness functions that build on this, so it seems to work. All that is left is the commenting, and then it can be closed.

schrum2 commented 1 year ago

This has enough comments in it now to close the issue.