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

MaximizeVolumeFitness has an error in calculateFinalScore #888

Closed JoannaBlatt closed 1 year ago

JoannaBlatt commented 1 year ago

When calculating the minecraft coordinates the min coordinate creates an error that terminates the run.

Error cod:

Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.rangeCheck(Unknown Source) at java.util.ArrayList.get(Unknown Source) at edu.southwestern.tasks.evocraft.MinecraftUtilClass.minCoordinates(MinecraftUtilClass.java:131) at edu.southwestern.tasks.evocraft.fitness.MaximizeVolumeFitness.calculateFinalScore(MaximizeVolumeFitness.java:29) at edu.southwestern.tasks.evocraft.fitness.TimedEvaluationMinecraftFitnessFunction.multipleFitnessScores(TimedEvaluationMinecraftFitnessFunction.java:162) at edu.southwestern.tasks.evocraft.fitness.TimedEvaluationMinecraftFitnessFunction.fitnessScore(TimedEvaluationMinecraftFitnessFunction.java:33) at edu.southwestern.tasks.evocraft.MinecraftShapeTask.lambda$calculateFitnessScores$1(MinecraftShapeTask.java:403)

schrum2 commented 1 year ago

The code in the calculateFinalScore method of MaximizeVolumeFitness is wrong in several ways #871 .

First, if currentShapeBlockList is empty, then don't do any calculations on it. This is the source of the crash above.

However, this also has other errors. You are simply replacing the min and max coordinates each time, not computing the min and max across the history of all shapes. For each current shape, get the min and max coordinates. Then use the other version of the min/max coordinate method (e.g. MinecraftCoordinates minCoordinates(MinecraftCoordinates c1, MinecraftCoordinates c2)) to compare the min/max of one shape in the history to the next shape in the history. This will give you the min/max across all shapes.

However, if you do this, then initializing the min/max to (0,0,0) is incorrect. Start with the min/max coordinate of the shape at index 0 in the history

schrum2 commented 1 year ago

Possibly fixed. Need to test

schrum2 commented 1 year ago

Seems fixed. Need to keep monitoring