TorusPredPreyTask extends NoisyLonerTask<T> implements TUGTask, NetworkTask, HyperNEATTask { @Override public double[] minScores() { double[] result = new double[numObjectives()]; for (int i = 0; i < result.length; i++) { result[i] = objectives.get(0).get(i).minScore(); } return result; } TorusPredPreyTask();  TorusPredPreyTask(boolean preyEvolve);  TorusPredPreyTask(boolean preyEvolve, boolean competitive); abstract TorusPredPreyController[] getPredAgents(Genotype<T> individual); abstract TorusPredPreyController[] getPreyAgents(Genotype<T> individual); final void addObjective(GridTorusObjective<T> o, ArrayList<ArrayList<GridTorusObjective<T>>> list, int pop); final void addObjective(GridTorusObjective<T> o, ArrayList<ArrayList<GridTorusObjective<T>>> list, boolean affectsSelection, int pop); @Override /** * A method that evaluates a single genotype Provides fitness for that * genotype based on the game time as well as other scores * * @param individual * genotype being evaluated * @param num * number of current evaluation * @return A Pair of double arrays containing the fitness and other scores */ Pair<double[], double[]> oneEval(Genotype<T> individual, int num); TorusPredPreyGame runEval(TorusPredPreyController[] predAgents, TorusPredPreyController[] preyAgents); @Override int numObjectives(); @Override int numOtherScores(); @Override double[] startingGoals(); @Override double[] minScores(); @Override String[] sensorLabels(); @Override String[] outputLabels(); static String[] outputLabels(boolean forPredators); @Override double getTimeStamp(); static TorusPredPreyController[] getStaticControllers(boolean isPred, int num); static void getEvolvedControllers(TorusPredPreyController[] container, Genotype<T> g, boolean isPred); static void getEvolvedControllers(TorusPredPreyController[] container, Genotype<T> g, boolean isPred, int startIndex, int numCopies); static void getEvolvedControllers(TorusPredPreyController[] container, Genotype<T>[] genotypes, boolean isPred); static void getEvolvedControllers(TorusPredPreyController[] container, Genotype<T>[] genotypes, boolean isPred, int startIndex); void addAllObjectives(); void addAllObjectives(int pop); void addAllObjectives(int pop, boolean isPreyPop); @Override List<Substrate> getSubstrateInformation(); @Override List<Triple<String, String, Boolean>> getSubstrateConnectivity(); double[] getSubstrateInputs(List<Substrate> subs); @Override int numCPPNInputs(); @Override double[] filterCPPNInputs(double[] fullInputs); static final String[] ALL_ACTIONS; static final String[] MOVEMENT_ACTIONS; static final int HYPERNEAT_OUTPUT_SUBSTRATE_DIMENSION; public TorusPredPreyController[] evolved; static boolean preyEvolve; final boolean competitive; public ArrayList<ArrayList<GridTorusObjective<T>>> objectives; public ArrayList<ArrayList<GridTorusObjective<T>>> otherScores; }
@SuppressWarnings("rawtypes") @Test public void testMinScores() { Parameters.initializeParameterCollections(new String[] { "io:false", "netio:false", "torusTimeLimit:1000", "torusPreys:2", "torusPredators:3", "staticPreyController:edu.utexas.cs.nn.gridTorus.controllers.PreyFleeClosestPredatorController", "predatorCatchClose:true", "preyRRM:true" }); MMNEAT.loadClasses(); MMNEAT.task = new TorusEvolvedPredatorsVsStaticPreyTask(); homoPred = (TorusEvolvedPredatorsVsStaticPreyTask)MMNEAT.task; assertEquals(homoPred.minScores()[0], 0, doubleThreshold); assertEquals(homoPred.minScores().length, 1); Parameters.initializeParameterCollections(new String[] { "io:false", "netio:false", "torusTimeLimit:1000", "torusPreys:2", "torusPredators:3", "staticPreyController:edu.utexas.cs.nn.gridTorus.controllers.PreyFleeClosestPredatorController", "predatorCatchClose:true", "predatorMinimizeDistance:true", "predatorsEatQuick:true"}); MMNEAT.loadClasses(); MMNEAT.task = new TorusEvolvedPredatorsVsStaticPreyTask(); homoPred = (TorusEvolvedPredatorsVsStaticPreyTask)MMNEAT.task; assertEquals(homoPred.minScores()[0], 0, doubleThreshold); assertEquals(homoPred.minScores()[1], -2000, doubleThreshold); assertEquals(homoPred.minScores()[2], -600, doubleThreshold); }