Program: 39264
Project: 39264
Buggy source:
/** 
 * a method for looping through all nodes of two substrates to be linked Link is only created if CPPN output reaches a certain threshold that is dictated via command line parameter.
 * @param linksSoFar All aded links are accumulated in this list
 * @param cppn used to evolve link weight
 * @param outputIndex index from cppn outputs to be used as weight in creating link
 * @param s1 first substrate to be linked
 * @param s2 second substrate to be linked
 * @param s1Index index of first substrate in substrate list
 * @param s2Index index of second substrate in substrate list
 * @param subs list of substrates
 */
public void loopThroughLinks(ArrayList<LinkGene> linksSoFar,TWEANN cppn,int outputIndex,Substrate s1,Substrate s2,int s1Index,int s2Index,List<Substrate> subs){
  for (int X1=0; X1 < s1.size.t1; X1++) {
    for (int Y1=0; Y1 < s1.size.t2; Y1++) {
      for (int X2=0; X2 < s2.size.t1; X2++) {
        for (int Y2=0; Y2 < s2.size.t2; Y2++) {
          ILocated2D scaledSourceCoordinates=MMNEAT.substrateMapping.transformCoordinates(new Tuple2D(X1,Y1),s1.size.t1,s1.size.t2);
          ILocated2D scaledTargetCoordinates=MMNEAT.substrateMapping.transformCoordinates(new Tuple2D(X2,Y2),s2.size.t1,s2.size.t2);
          double[] inputs={scaledSourceCoordinates.getX(),scaledSourceCoordinates.getY(),scaledTargetCoordinates.getX(),scaledTargetCoordinates.getY(),BIAS};
          double[] outputs=cppn.process(inputs);
          boolean expressLink=Math.abs(outputs[outputIndex]) > CommonConstants.linkExpressionThreshold;
          if (expressLink) {
            linksSoFar.add(new LinkGene(getInnovationID(X1,Y1,s1Index,subs),getInnovationID(X2,Y2,s2Index,subs),NetworkUtil.calculateWeight(outputs[outputIndex]),innovationID++,false));
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * a method for looping through all nodes of two substrates to be linked Link is only created if CPPN output reaches a certain threshold that is dictated via command line parameter.
 * @param linksSoFar All aded links are accumulated in this list
 * @param cppn used to evolve link weight
 * @param outputIndex index from cppn outputs to be used as weight in creating link
 * @param s1 first substrate to be linked
 * @param s2 second substrate to be linked
 * @param s1Index index of first substrate in substrate list
 * @param s2Index index of second substrate in substrate list
 * @param subs list of substrates
 */
public void loopThroughLinks(ArrayList<LinkGene> linksSoFar,TWEANN cppn,int outputIndex,Substrate s1,Substrate s2,int s1Index,int s2Index,List<Substrate> subs){
  for (int X1=0; X1 < s1.size.t1; X1++) {
    for (int Y1=0; Y1 < s1.size.t2; Y1++) {
      for (int X2=0; X2 < s2.size.t1; X2++) {
        for (int Y2=0; Y2 < s2.size.t2; Y2++) {
          ILocated2D scaledSourceCoordinates=MMNEAT.substrateMapping.transformCoordinates(new Tuple2D(X1,Y1),s1.size.t1,s1.size.t2);
          ILocated2D scaledTargetCoordinates=MMNEAT.substrateMapping.transformCoordinates(new Tuple2D(X2,Y2),s2.size.t1,s2.size.t2);
          double[] inputs={scaledSourceCoordinates.getX(),scaledSourceCoordinates.getY(),scaledTargetCoordinates.getX(),scaledTargetCoordinates.getY(),BIAS};
          double[] outputs=cppn.process(inputs);
          boolean expressLink=Math.abs(outputs[outputIndex]) > CommonConstants.linkExpressionThreshold;
          if (expressLink) {
            long sourceID=getInnovationID(X1,Y1,s1Index,subs);
            long targetID=getInnovationID(X2,Y2,s2Index,subs);
            double weight=NetworkUtil.calculateWeight(outputs[outputIndex]);
            linksSoFar.add(new LinkGene(sourceID,targetID,weight,innovationID++,false));
          }
        }
      }
    }
  }
}