TorusPredPreyTask extends NoisyLonerTask<T> implements TUGTask, NetworkTask, HyperNEATTask { @Override public int numOtherScores() { return otherScores.get(0).size(); } 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", "unchecked" }) @Test public void testNumOtherScores() { MMNEAT.task = new TorusEvolvedPredatorsVsStaticPreyTask(); homoPred = (TorusEvolvedPredatorsVsStaticPreyTask)MMNEAT.task; ArrayList<ArrayList<GridTorusObjective<T>>> objectives = homoPred.objectives; ArrayList<ArrayList<GridTorusObjective<T>>> otherScores = homoPred.otherScores; assertEquals(otherScores.size(), 1); assertEquals(homoPred.numOtherScores(), numOthers); homoPred.addObjective(new PredatorCatchCloseObjective(), otherScores, 0); assertEquals(homoPred.numOtherScores(), numOthers + 1); homoPred.addObjective(new PredatorCatchObjective(), otherScores, 0); assertEquals(homoPred.numOtherScores(), numOthers + 2); homoPred.addObjective(new PreyMinimizeCaughtObjective(), otherScores, 0); assertEquals(homoPred.numOtherScores(), numOthers + 3); homoPred.addObjective(new PredatorEatEachPreyQuicklyObjective(), objectives, 0); assertEquals(homoPred.numOtherScores(), numOthers + 3); }