public void eval(
     final EvolutionState state,
     final int thread,
     final GPData input,
     final ADFStack stack,
     final GPIndividual individual,
     final Problem problem) {
   PredatorPrey p = (PredatorPrey) problem;
   PredatorPreyData rd = ((PredatorPreyData) (input));
   int x = p.getIndX();
   int y = p.getIndY();
   int orientation = p.getIndOrientation();
   // Finds which square is behing the agent depending on its facing
   switch (orientation) {
     case 0:
       rd.val = p.getAgentType(x, y + 1);
       break;
     case 1:
       rd.val = p.getAgentType(x - 1, y);
       break;
     case 2:
       rd.val = p.getAgentType(x, y - 1);
       break;
     case 3:
       rd.val = p.getAgentType(x + 1, y);
       break;
   }
   if (rd.val < 0) {
     System.out.println(toString() + " is negative, rd.val = " + rd.val);
   }
 }
Example #2
0
  public void eval(
      final EvolutionState state,
      final int thread,
      final GPData input,
      final ADFStack stack,
      final GPIndividual individual,
      final Problem problem) {
    int result;
    PredatorPreyData rd = ((PredatorPreyData) (input));

    children[0].eval(state, thread, input, stack, individual, problem);
    result = rd.val;
    // If the first child was less than or equal to the second child, set the value
    // back to that of the first child
    children[1].eval(state, thread, input, stack, individual, problem);
    if (result <= rd.val) {
      rd.val = result;
    }
    rd.val = rd.val % 4;
    if (rd.val < 0) {
      System.out.println(toString() + " is negative, rd.val = " + rd.val);
    }
  }