nus-yam/ex-repair huggingface dataset:
Program: 39290
Project: 39290
Buggy source:
/** 
 * constructor for a task where the prey are evolved while the predators are kept static sends true to the parent constructor, indicating that the prey is the agent evolving Includes all of the fitness scores that the user wants from the command line parameters
 */
public TorusEvolvedPreyVsStaticPredatorsTask(){
  super(true);
  if (Parameters.parameters.booleanParameter("String_Node_Str"))   addObjective(new PreyMaximizeGameTimeObjective<T>(),objectives);
  if (Parameters.parameters.booleanParameter("String_Node_Str"))   addObjective(new PreyRawalRajagopalanMiikkulainenObjective<T>(),objectives);
  if (Parameters.parameters.booleanParameter("String_Node_Str"))   addObjective(new PreyLongSurvivalTimeObjective<T>(),objectives);
  if (Parameters.parameters.booleanParameter("String_Node_Str"))   addObjective(new PreyMaximizeDistanceFromPredatorsObjective<T>(),objectives);
  if (Parameters.parameters.booleanParameter("String_Node_Str"))   addObjective(new PreyMinimizeCaughtObjective<T>(),objectives);
}

Fixed version (ground truth):
/** 
 * constructor for a task where the prey are evolved while the predators are kept static sends true to the parent constructor, indicating that the prey is the agent evolving Includes all of the fitness scores that the user wants from the command line parameters
 */
public TorusEvolvedPreyVsStaticPredatorsTask(){
  super(true);
  if (Parameters.parameters.booleanParameter("String_Node_Str"))   addObjective(new PreyMaximizeGameTimeObjective<T>(),objectives);
  if (Parameters.parameters.booleanParameter("String_Node_Str"))   addObjective(new PreyRawalRajagopalanMiikkulainenObjective<T>(),objectives);
  if (Parameters.parameters.booleanParameter("String_Node_Str"))   addObjective(new PreyLongSurvivalTimeObjective<T>(),objectives);
  if (Parameters.parameters.booleanParameter("String_Node_Str"))   addObjective(new PreyMaximizeDistanceFromPredatorsObjective<T>(),objectives);
  if (Parameters.parameters.booleanParameter("String_Node_Str"))   addObjective(new PreyMinimizeCaughtObjective<T>(),objectives);
  addObjective(new PreyMaximizeGameTimeObjective<T>(),otherScores,false);
  addObjective(new PreyRawalRajagopalanMiikkulainenObjective<T>(),otherScores,false);
  addObjective(new PreyLongSurvivalTimeObjective<T>(),otherScores,false);
  addObjective(new PreyMaximizeDistanceFromPredatorsObjective<T>(),otherScores,false);
  addObjective(new PreyMinimizeCaughtObjective<T>(),otherScores,false);
}
Program: 39291
Project: 39291
Buggy source:
/** 
 * for adding fitness scores (turned on by command line parameters)
 * @param o objective/fitness score
 * @param list of fitness scores
 */
public final void addObjective(GridTorusObjective<T> o,ArrayList<GridTorusObjective<T>> list,boolean affectsSelection){
  list.add(o);
  MMNEAT.registerFitnessFunction(o.getClass().getSimpleName(),affectsSelection);
}

Fixed version (ground truth):
/** 
 * for adding fitness scores (turned on by command line parameters)
 * @param o objective/fitness score
 * @param list of fitness scores
 * @param affectsSelection  true if objective score false if other score
 */
public final void addObjective(GridTorusObjective<T> o,ArrayList<GridTorusObjective<T>> list,boolean affectsSelection){
  list.add(o);
  MMNEAT.registerFitnessFunction(o.getClass().getSimpleName(),affectsSelection);
}
Program: 39292
Project: 39292
Buggy source:
/** 
 * @return the minimum possible scores (worst scores) for this genotype ifit is a prey then the min score is 0 and if it's a predator min score is the total time limit
 */
@Override public double[] minScores(){
  double[] result=new double[numObjectives()];
  for (int i=0; i < result.length; i++) {
    result[i]=objectives.get(i).minScore();
  }
  return result;
}

Fixed version (ground truth):
/** 
 * @return the minimum possible scores (worst scores) for this genotype
 */
@Override public double[] minScores(){
  double[] result=new double[numObjectives()];
  for (int i=0; i < result.length; i++) {
    result[i]=objectives.get(i).minScore();
  }
  return result;
}
Program: 39293
Project: 39293
Buggy source:
/** 
 * @return the number of minimum scores for this genotype of this task
 */
@Override public int numObjectives(){
  return objectives.size();
}

Fixed version (ground truth):
/** 
 * @return the number of fitness scores for this genotype
 */
@Override public int numObjectives(){
  return objectives.size();
}
Program: 39294
Project: 39294
Buggy source:
@Override public Pair<double[],double[]> oneEval(Genotype<T> individual,int num){
  TorusPredPreyController[] predAgents=getPredAgents(individual);
  TorusPredPreyController[] preyAgents=getPreyAgents(individual);
  exec=new TorusWorldExec();
  TorusPredPreyGame game;
  if (CommonConstants.watch) {
    game=exec.runGameTimed(predAgents,preyAgents,true);
  }
 else {
    game=exec.runExperiment(predAgents,preyAgents);
  }
  double[] fitnesses=new double[objectives.size()];
  if (CommonConstants.monitorInputs) {
    for (int i=0; i < evolved.length; i++) {
      ((NNTorusPredPreyController)(evolved)[i]).networkInputs.dispose();
    }
  }
  int numModes=((NNTorusPredPreyController)evolved[0]).nn.numModules();
  int[] overallAgentModeUsage=new int[numModes];
  for (  TorusPredPreyController agent : evolved) {
    int[] thisAgentModeUsage=((NNTorusPredPreyController)agent).nn.getModuleUsage();
    overallAgentModeUsage=ArrayUtil.zipAdd(overallAgentModeUsage,thisAgentModeUsage);
  }
  Organism<T> organism=new NNTorusPredPreyAgent<T>(individual,!preyEvolve);
  for (int j=0; j < objectives.size(); j++) {
    fitnesses[j]=objectives.get(j).score(game,organism);
  }
  ((NetworkGenotype<T>)individual).setModuleUsage(overallAgentModeUsage);
  double[] otherStats=new double[0];
  return new Pair<double[],double[]>(fitnesses,otherStats);
}

Fixed version (ground truth):
@Override public Pair<double[],double[]> oneEval(Genotype<T> individual,int num){
  TorusPredPreyController[] predAgents=getPredAgents(individual);
  TorusPredPreyController[] preyAgents=getPreyAgents(individual);
  exec=new TorusWorldExec();
  TorusPredPreyGame game;
  if (CommonConstants.watch) {
    game=exec.runGameTimed(predAgents,preyAgents,true);
  }
 else {
    game=exec.runExperiment(predAgents,preyAgents);
  }
  double[] fitnesses=new double[objectives.size()];
  double[] otherStats=new double[otherScores.size()];
  if (CommonConstants.monitorInputs) {
    for (int i=0; i < evolved.length; i++) {
      ((NNTorusPredPreyController)(evolved)[i]).networkInputs.dispose();
    }
  }
  int numModes=((NNTorusPredPreyController)evolved[0]).nn.numModules();
  int[] overallAgentModeUsage=new int[numModes];
  for (  TorusPredPreyController agent : evolved) {
    int[] thisAgentModeUsage=((NNTorusPredPreyController)agent).nn.getModuleUsage();
    overallAgentModeUsage=ArrayUtil.zipAdd(overallAgentModeUsage,thisAgentModeUsage);
  }
  Organism<T> organism=new NNTorusPredPreyAgent<T>(individual,!preyEvolve);
  for (int i=0; i < objectives.size(); i++) {
    fitnesses[i]=objectives.get(i).score(game,organism);
  }
  for (int i=0; i < otherScores.size(); i++) {
    otherStats[i]=otherScores.get(i).score(game,organism);
  }
  ((NetworkGenotype<T>)individual).setModuleUsage(overallAgentModeUsage);
  return new Pair<double[],double[]>(fitnesses,otherStats);
}
Program: 39295
Project: 39295
Buggy source:
@Override public double fitness(Organism<T> individual){
  TorusAgent[] preds=game.getPredators();
  TorusAgent[] prey=game.getPrey();
  return sumOfPreyToPredDistances(preds,prey);
}

Fixed version (ground truth):
@Override public double fitness(Organism<T> individual){
  return PredatorMinimizeDistanceFromPreyObjective.sumOfPredToPreyDistances(game.getPredators(),game.getPrey());
}
Program: 39296
Project: 39296
Buggy source:
public HyperNEATCPPNGenotype(ArrayList<LinkGene> links,ArrayList<NodeGene> genes){
  super(genes,links,1,false,false,0);
}

Fixed version (ground truth):
/** 
 * Constructor for random hyperNEATCPPNGenotype. 
 * @param networkInputs number of network inputs
 * @param networkOutputs number of newtork outputs
 * @param archetypeIndex index of genotype in archetype
 */
public HyperNEATCPPNGenotype(int networkInputs,int networkOutputs,int archetypeIndex){
  super(networkInputs,networkOutputs,archetypeIndex);
}
Program: 39297
Project: 39297
Buggy source:
/** 
 * Uses another CPPN to create a TWEANN controller for the domain. This created TWEANN is unique only to the instance in which it is used. In a sense, it's a one-and-done network, which explains the lax use of innovation numbers
 * @return TWEANN generated by CPPN
 */
@Override public TWEANN getPhenotype(){
  TWEANN cppn=super.getPhenotype();
  HyperNEATTask hnt=(HyperNEATTask)MMNEAT.task;
  List<Substrate> subs=hnt.getSubstrateInformation();
  List<Pair<String,String>> connections=hnt.getSubstrateConnectivity();
  innovationID=0;
  ArrayList<NodeGene> newNodes=createSubstrateNodes(subs);
  HashMap<String,Integer> substrateIndexMapping=new HashMap<String,Integer>();
  for (int i=0; i < subs.size(); i++) {
    substrateIndexMapping.put(subs.get(i).getName(),i);
  }
  ArrayList<LinkGene> newLinks=createNodeLinks(cppn,connections,subs,substrateIndexMapping);
  TWEANNGenotype tg=new TWEANNGenotype(newNodes,newLinks,1,false,false,-1);
  return tg.getPhenotype();
}

Fixed version (ground truth):
/** 
 * Uses another CPPN to create a TWEANN controller for the domain. This created TWEANN is unique only to the instance in which it is used. In a sense, it's a one-and-done network, which explains the lax use of innovation numbers
 * @return TWEANN generated by CPPN
 */
@Override public TWEANN getPhenotype(){
  TWEANN cppn=super.getPhenotype();
  HyperNEATTask hnt=(HyperNEATTask)MMNEAT.task;
  List<Substrate> subs=hnt.getSubstrateInformation();
  List<Pair<String,String>> connections=hnt.getSubstrateConnectivity();
  innovationID=0;
  ArrayList<NodeGene> newNodes=createSubstrateNodes(subs);
  HashMap<String,Integer> substrateIndexMapping=new HashMap<String,Integer>();
  for (int i=0; i < subs.size(); i++) {
    substrateIndexMapping.put(subs.get(i).getName(),i);
  }
  ArrayList<LinkGene> newLinks=createNodeLinks(cppn,connections,subs,substrateIndexMapping);
  int phenotypeOutputs=0;
  for (  Substrate s : subs) {
    if (s.getStype() == Substrate.OUTPUT_SUBSTRATE) {
      phenotypeOutputs+=s.size.t1 * s.size.t2;
    }
  }
  TWEANNGenotype tg=new TWEANNGenotype(newNodes,newLinks,phenotypeOutputs,false,false,-1);
  return tg.getPhenotype();
}
Program: 39298
Project: 39298
Buggy source:
@Override public Genotype<TWEANN> copy(){
  int[] temp=moduleUsage;
  ArrayList<LinkGene> links=new ArrayList<LinkGene>(this.links.size());
  for (  LinkGene lg : this.links) {
    links.add(new LinkGene(lg.sourceInnovation,lg.targetInnovation,lg.weight,lg.innovation,false));
  }
  ArrayList<NodeGene> genes=new ArrayList<NodeGene>(this.nodes.size());
  for (  NodeGene ng : this.nodes) {
    genes.add(new NodeGene(ng.ftype,ng.ntype,ng.innovation,false));
  }
  HyperNEATCPPNGenotype result=new HyperNEATCPPNGenotype(links,genes);
  moduleUsage=temp;
  result.moduleUsage=new int[temp.length];
  System.arraycopy(this.moduleUsage,0,result.moduleUsage,0,moduleUsage.length);
  return result;
}

Fixed version (ground truth):
/** 
 * Copies given genotype
 */
@Override public Genotype<TWEANN> copy(){
  int[] temp=moduleUsage;
  ArrayList<LinkGene> links=new ArrayList<LinkGene>(this.links.size());
  for (  LinkGene lg : this.links) {
    links.add(new LinkGene(lg.sourceInnovation,lg.targetInnovation,lg.weight,lg.innovation,false));
  }
  ArrayList<NodeGene> genes=new ArrayList<NodeGene>(this.nodes.size());
  for (  NodeGene ng : this.nodes) {
    genes.add(new NodeGene(ng.ftype,ng.ntype,ng.innovation,false));
  }
  HyperNEATCPPNGenotype result=new HyperNEATCPPNGenotype(links,genes,MMNEAT.networkOutputs);
  moduleUsage=temp;
  result.moduleUsage=new int[temp.length];
  System.arraycopy(this.moduleUsage,0,result.moduleUsage,0,moduleUsage.length);
  return result;
}
Program: 39299
Project: 39299
Buggy source:
@Override public int[] getAction(TorusAgent me,TorusWorld world,TorusAgent[] preds,TorusAgent[] prey){
  double[] inputs=inputs();
  double[] outputs=nn.process(inputs);
  System.out.println("String_Node_Str" + inputs.length);
  System.out.println("String_Node_Str" + outputs.length);
  System.out.println("String_Node_Str" + nn.numInputs() + "String_Node_Str"+ nn.numOutputs());
  double[] modifiedOutputs=mapSubstrateOutputsToStandardOutputs(outputs);
  return isPredator ? predatorActions()[StatisticsUtilities.argmax(modifiedOutputs)] : preyActions()[StatisticsUtilities.argmax(modifiedOutputs)];
}

Fixed version (ground truth):
@Override public int[] getAction(TorusAgent me,TorusWorld world,TorusAgent[] preds,TorusAgent[] prey){
  double[] inputs=inputs();
  double[] outputs=nn.process(inputs);
  double[] modifiedOutputs=mapSubstrateOutputsToStandardOutputs(outputs);
  return isPredator ? predatorActions()[StatisticsUtilities.argmax(modifiedOutputs)] : preyActions()[StatisticsUtilities.argmax(modifiedOutputs)];
}
Program: 39300
Project: 39300
Buggy source:
public double[] mapSubstrateOutputsToStandardOutputs(double[] outputs){
  double[] modifiedOutputs=new double[numOutputs];
  if (numOutputs == NUM_OUTPUTS_WITH_NO_ACTION) {
    modifiedOutputs[NOTHING_INDEX]=outputs[SUBSTRATE_NOTHING_INDEX];
  }
  System.out.println(Arrays.toString(outputs));
  modifiedOutputs[TorusPredPreyController.UP_INDEX]=outputs[SUBSTRATE_UP_INDEX];
  modifiedOutputs[TorusPredPreyController.RIGHT_INDEX]=outputs[SUBSTRATE_RIGHT_INDEX];
  modifiedOutputs[TorusPredPreyController.DOWN_INDEX]=outputs[SUBSTRATE_DOWN_INDEX];
  modifiedOutputs[TorusPredPreyController.LEFT_INDEX]=outputs[SUBSTRATE_LEFT_INDEX];
  return modifiedOutputs;
}

Fixed version (ground truth):
public double[] mapSubstrateOutputsToStandardOutputs(double[] outputs){
  double[] modifiedOutputs=new double[numOutputs];
  if (numOutputs == NUM_OUTPUTS_WITH_NO_ACTION) {
    modifiedOutputs[NOTHING_INDEX]=outputs[SUBSTRATE_NOTHING_INDEX];
  }
  modifiedOutputs[TorusPredPreyController.UP_INDEX]=outputs[SUBSTRATE_UP_INDEX];
  modifiedOutputs[TorusPredPreyController.RIGHT_INDEX]=outputs[SUBSTRATE_RIGHT_INDEX];
  modifiedOutputs[TorusPredPreyController.DOWN_INDEX]=outputs[SUBSTRATE_DOWN_INDEX];
  modifiedOutputs[TorusPredPreyController.LEFT_INDEX]=outputs[SUBSTRATE_LEFT_INDEX];
  return modifiedOutputs;
}
Program: 39301
Project: 39301
Buggy source:
@Override public int numFeatures(){
  return super.numFeatures();
}

Fixed version (ground truth):
@Override public int numFeatures(){
  return super.numFeatures() + TetrisState.worldWidth;
}
Program: 39302
Project: 39302
Buggy source:
@Override public double[] extract(Observation o){
  double[] base=super.extract(o);
  int[] worldState=new int[worldWidth * worldHeight];
  System.arraycopy(o.intArray,0,worldState,0,worldWidth * worldHeight);
  double[] blockIndicator=new double[possibleBlocks.size()];
  for (int i=0; i < possibleBlocks.size(); i++) {
    blockIndicator[i]=o.intArray[worldState.length + i];
  }
  int blockId=StatisticsUtilities.argmax(blockIndicator);
  int blockX=o.intArray[TetrisState.TETRIS_STATE_CURRENT_X_INDEX];
  int blockY=o.intArray[TetrisState.TETRIS_STATE_CURRENT_Y_INDEX];
  int blockRotation=o.intArray[TetrisState.TETRIS_STATE_CURRENT_ROTATION_INDEX];
  double[] added=new double[worldWidth];
  for (int i=0; i < added.length; i++) {
    double h=columnHeight(i,worldState);
    added[i]=columnHoles(i,worldState,(int)h);
  }
  double[] combined=new double[base.length + added.length];
  System.arraycopy(base,0,combined,0,base.length);
  System.arraycopy(added,0,combined,base.length,added.length);
  return combined;
}

Fixed version (ground truth):
@Override public double[] extract(Observation o){
  double[] base=super.extract(o);
  int[] worldState=new int[worldWidth * worldHeight];
  System.arraycopy(o.intArray,0,worldState,0,worldWidth * worldHeight);
  double[] blockIndicator=new double[possibleBlocks.size()];
  for (int i=0; i < possibleBlocks.size(); i++) {
    blockIndicator[i]=o.intArray[worldState.length + i];
  }
  double[] added=new double[worldWidth];
  for (int i=0; i < added.length; i++) {
    double h=columnHeight(i,worldState);
    added[i]=columnHoles(i,worldState,(int)h);
  }
  double[] combined=new double[super.numFeatures() + added.length];
  System.arraycopy(base,0,combined,0,super.numFeatures());
  System.arraycopy(added,0,combined,super.numFeatures(),added.length);
  return combined;
}
Program: 39303
Project: 39303
Buggy source:
@Test public void number_of_holes(){
  TetrisState testState=new TetrisState();
  BertsekasTsitsiklisTetrisExtractor EBTTE=new ExtendedBertsekasTsitsiklisTetrisExtractor();
  testState.worldState[166]=1;
  testState.worldState[167]=1;
  testState.worldState[168]=1;
  testState.worldState[169]=1;
  testState.currentX+=2;
  testState.currentY+=14;
  testState.worldState[171]=1;
  testState.worldState[172]=1;
  testState.worldState[180]=1;
  testState.worldState[181]=1;
  testState.worldState[192]=1;
  testState.worldState[193]=1;
  testState.worldState[194]=1;
  testState.worldState[182]=1;
  testState.worldState[197]=1;
  testState.worldState[187]=1;
  testState.worldState[177]=1;
  testState.worldState[178]=1;
  testState.worldState[195]=1;
  testState.worldState[185]=1;
  testState.worldState[175]=1;
  testState.worldState[186]=1;
  Observation o=testState.get_observation();
  double[] inputs=EBTTE.scaleInputs(EBTTE.extract(o));
  double[] expected=EBTTE.scaleInputs(new double[]{2,3,3,1,1,3,4,4,4,4,1,0,2,0,2,1,0,0,0,4,9,1,1,1,0,0,0,0,2,0,2,3});
  for (int i=0; i < inputs.length; i++) {
    assertEquals(inputs[i],expected[i],0.0);
  }
}

Fixed version (ground truth):
@Test public void number_of_holes(){
  TetrisState testState=new TetrisState();
  BertsekasTsitsiklisTetrisExtractor EBTTE=new ExtendedBertsekasTsitsiklisTetrisExtractor();
  testState.worldState[166]=1;
  testState.worldState[167]=1;
  testState.worldState[168]=1;
  testState.worldState[169]=1;
  testState.currentX+=2;
  testState.currentY+=14;
  testState.worldState[171]=1;
  testState.worldState[172]=1;
  testState.worldState[180]=1;
  testState.worldState[181]=1;
  testState.worldState[192]=1;
  testState.worldState[193]=1;
  testState.worldState[194]=1;
  testState.worldState[182]=1;
  testState.worldState[197]=1;
  testState.worldState[187]=1;
  testState.worldState[177]=1;
  testState.worldState[178]=1;
  testState.worldState[195]=1;
  testState.worldState[185]=1;
  testState.worldState[175]=1;
  testState.worldState[186]=1;
  Observation o=testState.get_observation();
  double[] inputs=EBTTE.scaleInputs(EBTTE.extract(o));
  System.out.println(inputs.length);
  System.out.println(Arrays.toString(inputs));
  double[] expected=EBTTE.scaleInputs(new double[]{2,3,3,1,1,3,4,4,4,4,1,0,2,0,2,1,0,0,0,4,9,1,1,1,0,0,0,0,2,0,2,3});
  System.out.println(expected.length);
  System.out.println(Arrays.toString(expected));
  for (int i=0; i < inputs.length; i++) {
    assertEquals(inputs[i],expected[i],0.0);
  }
}
Program: 39304
Project: 39304
Buggy source:
@Override public double[] extract(Observation o){
  double[] base=super.extract(o);
  int[] worldState=new int[worldWidth * worldHeight];
  System.arraycopy(o.intArray,0,worldState,0,worldWidth * worldHeight);
  double[] blockIndicator=new double[possibleBlocks.size()];
  for (int i=0; i < possibleBlocks.size(); i++) {
    blockIndicator[i]=o.intArray[worldState.length + i];
  }
  int blockId=StatisticsUtilities.argmax(blockIndicator);
  int blockX=o.intArray[TetrisState.TETRIS_STATE_CURRENT_X_INDEX];
  int blockY=o.intArray[TetrisState.TETRIS_STATE_CURRENT_Y_INDEX];
  int blockRotation=o.intArray[TetrisState.TETRIS_STATE_CURRENT_ROTATION_INDEX];
  double[] added=new double[5];
  for (int i=0; i < added.length; i++) {
    added[i]=pieceDistanceFromBlocks(worldState,blockId,blockX,blockY,blockRotation,i);
  }
  double[] combined=new double[base.length + added.length];
  System.arraycopy(base,0,combined,0,base.length);
  System.arraycopy(added,0,combined,base.length,added.length);
  return combined;
}

Fixed version (ground truth):
@Override public double[] extract(Observation o){
  double[] base=super.extract(o);
  int[] worldState=new int[worldWidth * worldHeight];
  System.arraycopy(o.intArray,0,worldState,0,worldWidth * worldHeight);
  double[] blockIndicator=new double[possibleBlocks.size()];
  for (int i=0; i < possibleBlocks.size(); i++) {
    blockIndicator[i]=o.intArray[worldState.length + i];
  }
  int blockId=StatisticsUtilities.argmax(blockIndicator);
  int blockX=o.intArray[TetrisState.TETRIS_STATE_CURRENT_X_INDEX];
  int blockY=o.intArray[TetrisState.TETRIS_STATE_CURRENT_Y_INDEX];
  int blockRotation=o.intArray[TetrisState.TETRIS_STATE_CURRENT_ROTATION_INDEX];
  double[] added=new double[5];
  for (int i=0; i < added.length; i++) {
    added[i]=pieceDistanceFromBlocks(worldState,blockId,blockX,blockY,blockRotation,i);
  }
  double[] combined=new double[super.numFeatures() + added.length];
  System.arraycopy(base,0,combined,0,super.numFeatures());
  System.arraycopy(added,0,combined,super.numFeatures(),added.length);
  return combined;
}
Program: 39306
Project: 39306
Buggy source:
/** 
 * Absolute value function for x. Uses Math.abs();
 * @param x Function parameter
 * @return value of abs(x)
 */
public static double absVal(double x){
  return Math.abs(x);
}

Fixed version (ground truth):
/** 
 * Absolute value function for x. Uses Math.abs(); Also clamps result to range [0,1] after use of absolute value because of problems with values rising to infinity.
 * @param x Function parameter
 * @return value of abs(x) clamped to [0,1]
 */
public static double absVal(double x){
  return halfLinear(Math.abs(x));
}
Program: 39307
Project: 39307
Buggy source:
/** 
 * An input is added to the sum in case it holds recurrent activation
 * @param input = sensor input
 */
protected void load(double input){
  sum+=input;
}

Fixed version (ground truth):
/** 
 * An input is added to the sum in case it holds recurrent activation
 * @param input = sensor input
 */
protected void load(double input){
}
Program: 39308
Project: 39308
Buggy source:
/** 
 * Creates connection from this Node to target Node via a new Link.
 * @param target Node to link to 
 * @param weight synaptic weight of link between nodes 
 * @param innovation Innovation number of new Link 
 * @param recurrent whether or not link is recurrent 
 * @param frozen whether or not link can be changed
 */
protected void connect(Node target,double weight,long innovation,boolean recurrent,boolean frozen){
  Link l=new Link(target,weight,innovation,recurrent,frozen);
  outputs.add(l);
}

Fixed version (ground truth):
/** 
 * Creates connection from this Node to target Node via a new Link.
 * @param target Node to link to
 * @param weight synaptic weight of link between nodes
 * @param innovation Innovation number of new Link
 * @param recurrent whether or not link is recurrent
 * @param frozen whether or not link can be changed
 */
protected void connect(Node target,double weight,long innovation,boolean recurrent,boolean frozen){
  Link l=new Link(target,weight,innovation,recurrent,frozen);
  outputs.add(l);
}
Program: 39309
Project: 39309
Buggy source:
protected void transmit(double signal){
  target.sum+=(signal * weight);
}

Fixed version (ground truth):
protected void transmit(double signal){
}
Program: 39310
Project: 39310
Buggy source:
private void activate(){
switch (ftype) {
case ActivationFunctions.FTYPE_SAWTOOTH:
    activation=ActivationFunctions.sawtooth(sum);
  break;
case ActivationFunctions.FTYPE_HLPIECEWISE:
activation=ActivationFunctions.halfLinear(sum);
break;
case ActivationFunctions.FTYPE_SIGMOID:
activation=ActivationFunctions.sigmoid(sum);
break;
case ActivationFunctions.FTYPE_TANH:
activation=ActivationFunctions.tanh(sum);
break;
case ActivationFunctions.FTYPE_ID:
activation=sum;
break;
case ActivationFunctions.FTYPE_APPROX:
activation=ActivationFunctions.quickSigmoid(sum);
break;
case ActivationFunctions.FTYPE_FULLAPPROX:
activation=ActivationFunctions.fullQuickSigmoid(sum);
break;
case ActivationFunctions.FTYPE_GAUSS:
activation=ActivationFunctions.gaussian(sum);
break;
case ActivationFunctions.FTYPE_SINE:
activation=ActivationFunctions.sine(sum);
break;
case ActivationFunctions.FTYPE_ABSVAL:
activation=ActivationFunctions.absVal(sum);
break;
}
}

Fixed version (ground truth):
private void activate(){
}
Program: 39311
Project: 39311
Buggy source:
@Override public Pair<double[],double[]> oneEval(Genotype<T> individual,int num){
  TorusPredPreyController[] predAgents=getPredAgents(individual);
  TorusPredPreyController[] preyAgents=getPreyAgents(individual);
  exec=new TorusWorldExec();
  TorusPredPreyGame game;
  if (CommonConstants.watch) {
    game=exec.runGameTimed(predAgents,preyAgents,true);
  }
 else {
    game=exec.runExperiment(predAgents,preyAgents);
  }
  double[] fitnesses=new double[objectives.size()];
  TorusPredPreyController[] evolvedAgents=preyEvolve ? preyAgents : predAgents;
  if (CommonConstants.monitorInputs) {
    for (int i=0; i < evolvedAgents.length; i++) {
      ((NNTorusPredPreyController)(evolvedAgents)[i]).networkInputs.dispose();
    }
  }
  int numModes=((NNTorusPredPreyController)evolvedAgents[0]).nn.numModules();
  int[] overallAgentModeUsage=new int[numModes];
  for (  TorusPredPreyController agent : evolvedAgents) {
    int[] thisAgentModeUsage=((NNTorusPredPreyController)agent).nn.getModeUsage();
    overallAgentModeUsage=ArrayUtil.zipAdd(overallAgentModeUsage,thisAgentModeUsage);
  }
  Organism<T> organism=new NNTorusPredPreyAgent<T>(individual,!preyEvolve);
  for (int j=0; j < objectives.size(); j++) {
    fitnesses[j]=objectives.get(j).score(game,organism);
  }
  ((NetworkGenotype<T>)individual).setModuleUsage(overallAgentModeUsage);
  double[] otherStats=new double[0];
  return new Pair<double[],double[]>(fitnesses,otherStats);
}

Fixed version (ground truth):
@Override public Pair<double[],double[]> oneEval(Genotype<T> individual,int num){
  TorusPredPreyController[] predAgents=getPredAgents(individual);
  TorusPredPreyController[] preyAgents=getPreyAgents(individual);
  exec=new TorusWorldExec();
  TorusPredPreyGame game;
  if (CommonConstants.watch) {
    game=exec.runGameTimed(predAgents,preyAgents,true);
  }
 else {
    game=exec.runExperiment(predAgents,preyAgents);
  }
  double[] fitnesses=new double[objectives.size()];
  TorusPredPreyController[] evolvedAgents=preyEvolve ? preyAgents : predAgents;
  if (CommonConstants.monitorInputs) {
    for (int i=0; i < evolvedAgents.length; i++) {
      ((NNTorusPredPreyController)(evolvedAgents)[i]).networkInputs.dispose();
    }
  }
  int numModes=((NNTorusPredPreyController)evolvedAgents[0]).nn.numModules();
  int[] overallAgentModeUsage=new int[numModes];
  for (  TorusPredPreyController agent : evolvedAgents) {
    int[] thisAgentModeUsage=((NNTorusPredPreyController)agent).nn.getModuleUsage();
    overallAgentModeUsage=ArrayUtil.zipAdd(overallAgentModeUsage,thisAgentModeUsage);
  }
  Organism<T> organism=new NNTorusPredPreyAgent<T>(individual,!preyEvolve);
  for (int j=0; j < objectives.size(); j++) {
    fitnesses[j]=objectives.get(j).score(game,organism);
  }
  ((NetworkGenotype<T>)individual).setModuleUsage(overallAgentModeUsage);
  double[] otherStats=new double[0];
  return new Pair<double[],double[]>(fitnesses,otherStats);
}
Program: 39312
Project: 39312
Buggy source:
@Override public Score<T> evaluate(Genotype<T> individual){
  ArrayList<Pair<double[],double[]>> trainingSet=getTrainingPairs();
  ArrayList<ArrayList<Pair<Double,Double>>> samples=new ArrayList<ArrayList<Pair<Double,Double>>>(trainingSet.size());
  Network n=individual.getPhenotype();
  for (  Pair<double[],double[]> pattern : trainingSet) {
    double[] inputs=pattern.t1;
    double[] desiredOutputs=pattern.t2;
    double[] actualOutputs=n.process(inputs);
    if (CommonConstants.watch) {
      System.out.println("String_Node_Str" + Arrays.toString(desiredOutputs) + "String_Node_Str"+ Arrays.toString(actualOutputs));
    }
    ArrayList<Pair<Double,Double>> neuronResults=new ArrayList<Pair<Double,Double>>(n.numOutputs());
    for (int i=0; i < desiredOutputs.length; i++) {
      neuronResults.add(new Pair<Double,Double>(desiredOutputs[i],actualOutputs[i]));
    }
    samples.add(neuronResults);
    if (CommonConstants.watch && pauseForEachCase) {
      MiscUtil.waitForReadStringAndEnterKeyPress();
    }
  }
  double averageError=StatisticsUtilities.averageSquaredErrorEnergy(samples);
  return new Score<T>(individual,new double[]{-averageError},null);
}

Fixed version (ground truth):
@Override public Score<T> evaluate(Genotype<T> individual){
}
Program: 39313
Project: 39313
Buggy source:
public static double average(double[] xs){
  double avg=0;
  for (int i=0; i < xs.length; i++) {
    avg+=(xs[i] - avg) / (i + 1);
  }
  return avg;
}

Fixed version (ground truth):
public static double average(double[] xs){
}
Program: 39314
Project: 39314
Buggy source:
/** 
 * Compute "TOTAL instantaneous error energy" as described on page 161 of Neural Networks by Haykin. COULD BE SLIGHTLY OPTIMIZED
 * @param pairs each pair is desired/actual values for one output neuron
 * @return total error across whole output layer
 */
public static double instantaneousTotalErrorEnergy(ArrayList<Pair<Double,Double>> pairs){
  double sum=0;
  for (  Pair<Double,Double> p : pairs) {
    sum+=instantaneousErrorEnergy(p.t1,p.t2);
  }
  return sum;
}

Fixed version (ground truth):
/** 
 * Compute "TOTAL instantaneous error energy" as described on page 161 of Neural Networks by Haykin. COULD BE SLIGHTLY OPTIMIZED
 * @param pairs each pair is desired/actual values for one output neuron
 * @return total error across whole output layer
 */
public static double instantaneousTotalErrorEnergy(ArrayList<Pair<Double,Double>> pairs){
}
Program: 39315
Project: 39315
Buggy source:
/** 
 * Compute "average squared error energy" as described on page 161 of Neural Networks by Haykin.
 * @param samples each member corresponds to a collection of desired/actual outputs for a network
 * @return 
 */
public static double averageSquaredErrorEnergy(ArrayList<ArrayList<Pair<Double,Double>>> samples){
  double[] totalErrors=new double[samples.size()];
  for (int i=0; i < totalErrors.length; i++) {
    ArrayList<Pair<Double,Double>> pairs=samples.get(i);
    totalErrors[i]=instantaneousTotalErrorEnergy(pairs);
  }
  return average(totalErrors);
}

Fixed version (ground truth):
/** 
 * Compute "average squared error energy" as described on page 161 of Neural Networks by Haykin.
 * @param samples each member corresponds to a collection of desired/actual outputs for a network
 * @return 
 */
public static double averageSquaredErrorEnergy(ArrayList<ArrayList<Pair<Double,Double>>> samples){
}
Program: 39316
Project: 39316
Buggy source:
/** 
 * Compute "instantaneous error energy" as described on page 161 of Neural Networks by Haykin.
 * @param desired what output should be
 * @param output actual output of one neuron
 * @return instantaneous error
 */
public static double instantaneousErrorEnergy(double desired,double output){
  double e=desired - output;
  if (CommonConstants.watch) {
    System.out.println("String_Node_Str" + e);
  }
  return (e * e) / 2.0;
}

Fixed version (ground truth):
/** 
 * Compute "instantaneous error energy" as described on page 161 of Neural Networks by Haykin.
 * @param desired what output should be
 * @param output actual output of one neuron
 * @return instantaneous error
 */
public static double instantaneousErrorEnergy(double desired,double output){
}
Program: 39317
Project: 39317
Buggy source:
@Override public double fitness(Organism<T> individual){
  TorusAgent[] prey=game.getPrey();
  double numCaught=0;
  for (  TorusAgent p : prey) {
    if (p == null) {
      numCaught++;
    }
  }
  if (numCaught == 0)   return ALL_PREY_SCORE;
  double fewPreyCaughtScore=(ALL_PREY_SCORE - (ALL_PREY_SCORE * (numCaught / prey.length)));
  if (numCaught == prey.length)   return (fewPreyCaughtScore * game.getTime()) / game.getTimeLimit();
  return fewPreyCaughtScore;
}

Fixed version (ground truth):
@Override public double fitness(Organism<T> individual){
  TorusAgent[] prey=game.getPrey();
  double numCaught=0;
  for (  TorusAgent p : prey) {
    if (p == null) {
      numCaught++;
    }
  }
  if (numCaught == 0)   return ALL_PREY_SCORE;
  double fewPreyCaughtScore=(ALL_PREY_SCORE - (ALL_PREY_SCORE * (numCaught / prey.length)));
  if (numCaught == prey.length)   return (fewPreyCaughtScore * (((double)game.getTime())) / ((double)game.getTimeLimit()));
  return fewPreyCaughtScore;
}
Program: 39318
Project: 39318
Buggy source:
/** 
 * creates an array list of links between substrates as dictated by connections parameter
 * @param cppn used to evolve link weight
 * @param connections list of different connections between substrates
 * @param subs list of substrates in question
 * @param sIMap hashmap that maps the substrate in question to its index in the substrate list
 * @return array list containing all the links between substrates
 */
public ArrayList<LinkGene> createNodeLinks(TWEANN cppn,List<Pair<String,String>> connections,List<Substrate> subs,HashMap<String,Integer> sIMap){
  ArrayList<LinkGene> result=new ArrayList<LinkGene>();
  for (int i=0; i < connections.size(); i++) {
    int s1Index=sIMap.get(connections.get(i).t1);
    int s2Index=sIMap.get(connections.get(i).t2);
    Substrate s1=subs.get(s1Index);
    Substrate s2=subs.get(s2Index);
    result.addAll(loopThroughLinks(cppn,i,s1,s2,s1Index,s2Index,subs));
  }
  return result;
}

Fixed version (ground truth):
/** 
 * creates an array list of links between substrates as dictated by connections parameter
 * @param cppn used to evolve link weight
 * @param connections list of different connections between substrates
 * @param subs list of substrates in question
 * @param sIMap hashmap that maps the substrate in question to its index inthe substrate list
 * @return array list containing all the links between substrates
 */
public ArrayList<LinkGene> createNodeLinks(TWEANN cppn,List<Pair<String,String>> connections,List<Substrate> subs,HashMap<String,Integer> sIMap){
  ArrayList<LinkGene> result=new ArrayList<LinkGene>();
  for (int i=0; i < connections.size(); i++) {
    int sourceSubstrateIndex=sIMap.get(connections.get(i).t1);
    int targetSubstrateIndex=sIMap.get(connections.get(i).t2);
    Substrate sourceSubstrate=subs.get(sourceSubstrateIndex);
    Substrate targetSubstrate=subs.get(targetSubstrateIndex);
    result.addAll(loopThroughLinks(cppn,i,sourceSubstrate,targetSubstrate,sourceSubstrateIndex,targetSubstrateIndex,subs));
  }
  return result;
}
Program: 39319
Project: 39319
Buggy source:
/** 
 * returns the innovation id of the node in question
 * @param x x-coordinate of node
 * @param y y-coordinate of node
 * @param sIndex index of substrate in question
 * @param subs list of substrates available
 * @return innovationID of link in question
 */
public long getInnovationID(int x,int y,int sIndex,List<Substrate> subs){
  long innovationID=0;
  int i=0;
  while (i < sIndex) {
    innovationID+=subs.get(i).size.t1 * subs.get(i).size.t2;
  }
  innovationID+=subs.get(sIndex).size.t1 * (y - 1) + x;
  return innovationID;
}

Fixed version (ground truth):
/** 
 * returns the innovation id of the node in question
 * @param x x-coordinate of node
 * @param y y-coordinate of node
 * @param sIndex index of substrate in question
 * @param subs list of substrates available
 * @return innovationID of link in question
 */
public long getInnovationID(int x,int y,int sIndex,List<Substrate> subs){
  long innovationIDAccumulator=0;
  for (int i=0; i < sIndex; i++) {
    Substrate s=subs.get(i);
    innovationIDAccumulator+=s.size.t1 * s.size.t2;
  }
  innovationIDAccumulator+=(subs.get(sIndex).size.t1 * y) + x;
  return innovationIDAccumulator;
}
Program: 39320
Project: 39320
Buggy source:
/** 
 * Uses another CPPN to create a TWEANN controller for the domain. This created TWEANN is unique only to the instance in which it is used. In a sense, it's a one-and-done network, which explains the lax use of innovation numbers
 */
public TWEANN getPhenotype(){
  TWEANN cppn=super.getPhenotype();
  HyperNEATTask hnt=(HyperNEATTask)MMNEAT.task;
  List<Substrate> subs=hnt.getSubstrateInformation();
  List<Pair<String,String>> connections=hnt.getSubstrateConnectivity();
  innovationID=0;
  ArrayList<NodeGene> nodes=createSubstrateNodes(subs);
  HashMap<String,Integer> substrateIndexMapping=new HashMap<String,Integer>();
  for (int i=0; i < subs.size(); i++) {
    substrateIndexMapping.put(subs.get(i).getName(),i);
  }
  ArrayList<LinkGene> links=createNodeLinks(cppn,connections,subs,substrateIndexMapping);
  TWEANNGenotype tg=new TWEANNGenotype(nodes,links,neuronsPerModule,false,false,-1);
  return tg.getPhenotype();
}

Fixed version (ground truth):
/** 
 * Uses another CPPN to create a TWEANN controller for the domain. This created TWEANN is unique only to the instance in which it is used. In a sense, it's a one-and-done network, which explains the lax use of innovation numbers
 * @return TWEANN generated by CPPN
 */
@Override public TWEANN getPhenotype(){
  TWEANN cppn=super.getPhenotype();
  HyperNEATTask hnt=(HyperNEATTask)MMNEAT.task;
  List<Substrate> subs=hnt.getSubstrateInformation();
  List<Pair<String,String>> connections=hnt.getSubstrateConnectivity();
  innovationID=0;
  ArrayList<NodeGene> newNodes=createSubstrateNodes(subs);
  HashMap<String,Integer> substrateIndexMapping=new HashMap<String,Integer>();
  for (int i=0; i < subs.size(); i++) {
    substrateIndexMapping.put(subs.get(i).getName(),i);
  }
  ArrayList<LinkGene> newLinks=createNodeLinks(cppn,connections,subs,substrateIndexMapping);
  TWEANNGenotype tg=new TWEANNGenotype(newNodes,newLinks,1,false,false,-1);
  return tg.getPhenotype();
}
Program: 39321
Project: 39321
Buggy source:
/** 
 * a method for looping through all nodes of two substrates to be linked
 * @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
 * @return array list containing the genes linked between the two substrates
 */
public ArrayList<LinkGene> loopThroughLinks(TWEANN cppn,int outputIndex,Substrate s1,Substrate s2,int s1Index,int s2Index,List<Substrate> subs){
  ArrayList<LinkGene> lg=new ArrayList<LinkGene>();
  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; Y1++) {
        for (int Y2=0; Y2 < s2.size.t2; Y2++) {
          double[] inputs={(double)X1,(double)X2,(double)Y1,(double)Y2,BIAS};
          lg.add(new LinkGene(getInnovationID(X1,Y1,s1Index,subs),getInnovationID(X2,Y2,s2Index,subs),cppn.process(inputs)[outputIndex],innovationID++,false));
        }
      }
    }
  }
  return lg;
}

Fixed version (ground truth):
/** 
 * a method for looping through all nodes of two substrates to be linked
 * @param cppn used to evolve link weight
 * @param outputIndex index from cppn outputs to be used as weight increating 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
 * @return array list containing the genes linked between the two substrates
 */
public ArrayList<LinkGene> loopThroughLinks(TWEANN cppn,int outputIndex,Substrate s1,Substrate s2,int s1Index,int s2Index,List<Substrate> subs){
  ArrayList<LinkGene> newLinks=new ArrayList<LinkGene>();
  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=CartesianGeometricUtilities.centerAndScale(new Tuple2D(X1,Y1),s1.size.t1,s1.size.t2);
          ILocated2D scaledTargetCoordinates=CartesianGeometricUtilities.centerAndScale(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);
          newLinks.add(new LinkGene(getInnovationID(X1,Y1,s1Index,subs),getInnovationID(X2,Y2,s2Index,subs),outputs[outputIndex],innovationID++,false));
        }
      }
    }
  }
  return newLinks;
}
Program: 39322
Project: 39322
Buggy source:
/** 
 * creates an array list containing all the nodes from all the substrates
 * @param subs list of substrates extracted from domain
 * @return array llist of NodeGenes from substrates
 */
public ArrayList<NodeGene> createSubstrateNodes(List<Substrate> subs){
  ArrayList<NodeGene> nodes=new ArrayList<NodeGene>();
  for (int i=0; i < subs.size(); i++) {
    for (int j=0; j < subs.get(i).size.t1; j++) {
      for (int k=0; k < subs.get(i).size.t2; k++) {
        nodes.add(new NodeGene(CommonConstants.ftype,subs.get(i).getStype(),innovationID++));
      }
    }
  }
  return nodes;
}

Fixed version (ground truth):
/** 
 * creates an array list containing all the nodes from all the substrates
 * @param subs list of substrates extracted from domain
 * @return array list of NodeGenes from substrates
 */
public ArrayList<NodeGene> createSubstrateNodes(List<Substrate> subs){
  ArrayList<NodeGene> newNodes=new ArrayList<NodeGene>();
  for (int i=0; i < subs.size(); i++) {
    for (int x=0; x < subs.get(i).size.t1; x++) {
      for (int y=0; y < subs.get(i).size.t2; y++) {
        newNodes.add(new NodeGene(CommonConstants.ftype,subs.get(i).getStype(),innovationID++));
      }
    }
  }
  return newNodes;
}
Program: 39323
Project: 39323
Buggy source:
public List<Substrate> getSubstrateInformation();

Fixed version (ground truth):
/** 
 * Method that returns a list of information about the substrate layers contained in the network.
 * @return List of Substrates in order from inputs to hidden to output layers
 */
public List<Substrate> getSubstrateInformation();
Program: 39324
Project: 39324
Buggy source:
public List<Pair<String,String>> getSubstrateConnectivity();

Fixed version (ground truth):
/** 
 * Each Substrate has a unique String name, and this method returns a list of String pairs indicating which Substrates are connected: The Substrate from the first in the pair has links leading into the neurons in the Substrate second in the pair.
 * @return Last of String pairs where all Strings are names of Substratesfor the domain.
 */
public List<Pair<String,String>> getSubstrateConnectivity();
Program: 39327
Project: 39327
Buggy source:
public static void main(String[] args){
  TetrisViewer testView=new TetrisViewer();
  TetrisState testState=new TetrisState();
  testState.worldState[160]=1;
  testState.worldState[170]=1;
  testState.worldState[180]=1;
  testState.worldState[181]=1;
  testState.worldState[182]=1;
  testState.worldState[183]=1;
  testState.worldState[189]=1;
  testState.worldState[190]=1;
  testState.worldState[191]=1;
  testState.worldState[192]=1;
  testState.worldState[193]=1;
  testState.worldState[194]=1;
  testState.worldState[195]=1;
  testState.worldState[197]=1;
  testState.worldState[198]=1;
  testState.worldState[199]=1;
  testView.update(testState);
  MiscUtil.waitForReadStringAndEnterKeyPress();
  ArrayList<Pair<TetrisState,ArrayList<Integer>>> holder=evaluateAfterStates(testState);
  for (  Pair<TetrisState,ArrayList<Integer>> p : holder) {
    testView.update(p.t1);
    MiscUtil.waitForReadStringAndEnterKeyPress();
  }
}

Fixed version (ground truth):
/** 
 * This is a testing environment for this after state evaluator, using two different worldStates to check the long piece
 * @param args
 */
public static void main(String[] args){
  TetrisViewer testView=new TetrisViewer();
  TetrisState testState=new TetrisState();
  testState.worldState[160]=1;
  testState.worldState[170]=1;
  testState.worldState[180]=1;
  testState.worldState[181]=1;
  testState.worldState[182]=1;
  testState.worldState[183]=1;
  testState.worldState[189]=1;
  testState.worldState[190]=1;
  testState.worldState[191]=1;
  testState.worldState[192]=1;
  testState.worldState[193]=1;
  testState.worldState[194]=1;
  testState.worldState[195]=1;
  testState.worldState[197]=1;
  testState.worldState[198]=1;
  testState.worldState[199]=1;
  testView.update(testState);
  MiscUtil.waitForReadStringAndEnterKeyPress();
  ArrayList<Pair<TetrisState,ArrayList<Integer>>> holder=evaluateAfterStates(testState);
  for (  Pair<TetrisState,ArrayList<Integer>> p : holder) {
    testView.update(p.t1);
    MiscUtil.waitForReadStringAndEnterKeyPress();
  }
}
Program: 39329
Project: 39329
Buggy source:
public void writeCurrentBlock(int[] game_world){
  int[][] thisPiece=possibleBlocks.get(currentBlockId).getShape(currentRotation);
  for (int y=0; y < thisPiece[0].length; ++y) {
    for (int x=0; x < thisPiece.length; ++x) {
      if (thisPiece[x][y] != 0) {
        int linearIndex=calculateLinearArrayPosition(currentX + x,currentY + y);
        if (linearIndex < 0) {
          System.err.printf("String_Node_Str",linearIndex,currentX,x,currentY,y);
          Thread.dumpStack();
          System.exit(1);
        }
        game_world[linearIndex]=currentBlockId + 1;
      }
    }
  }
}

Fixed version (ground truth):
public void writeCurrentBlock(int[] game_world){
  int[][] thisPiece=possibleBlocks.get(currentBlockId).getShape(currentRotation);
  for (int y=0; y < thisPiece[0].length; ++y) {
    for (int x=0; x < thisPiece.length; ++x) {
      if (thisPiece[x][y] != 0) {
        int linearIndex=calculateLinearArrayPosition(currentX + x,currentY + y);
        if (linearIndex < 0) {
          System.err.printf("String_Node_Str",linearIndex,currentX,x,currentY,y);
          Thread.dumpStack();
          System.exit(1);
        }
        game_world[linearIndex]=currentBlockId + 1;
        System.out.println((currentX + x) + "String_Node_Str" + (currentY + y)+ "String_Node_Str");
      }
    }
  }
}
Program: 39331
Project: 39331
Buggy source:
/** 
 * Calculates inputs for the neural network in order to figure what action to take in getAction.
 * @param all agents (me, world, preds, prey)
 * @return
 */
public double[] inputs(TorusAgent me,TorusWorld world,TorusAgent[] preds,TorusAgent[] prey){
  double[] inputs=new double[preds.length * 2];
  for (int i=0; i < preds.length; i++) {
    inputs[(2 * i)]=me.shortestXOffset(preds[i]) / (1.0 * world.width());
    inputs[(2 * i) + 1]=me.shortestYOffset(preds[i]) / (1.0 * world.height());
  }
  return inputs;
}

Fixed version (ground truth):
/** 
 * Calculates inputs for the neural network in order to figure what action to take in getAction.
 * @param all agents (me, world, preds, prey)
 * @return
 */
public double[] inputs(TorusAgent me,TorusWorld world,TorusAgent[] preds,TorusAgent[] prey){
  int numAgentsSensed=isPredator ? prey.length : preds.length;
  double[] inputs=new double[numAgentsSensed * 2];
  for (int i=0; i < numAgentsSensed; i++) {
    inputs[(2 * i)]=me.shortestXOffset(isPredator ? prey[i] : preds[i]) / (1.0 * world.width());
    inputs[(2 * i) + 1]=me.shortestYOffset(isPredator ? prey[i] : preds[i]) / (1.0 * world.height());
  }
  return inputs;
}
Program: 39332
Project: 39332
Buggy source:
/** 
 * Sets up the sensor labels for sensors to be used in network visualization.
 * @param numPreds
 * @return
 */
public static String[] sensorLabels(int numPreds){
  String[] result=new String[numPreds * 2];
  for (int i=0; i < numPreds; i++) {
    result[(2 * i)]="String_Node_Str" + i;
    result[(2 * i) + 1]="String_Node_Str" + i;
  }
  return result;
}

Fixed version (ground truth):
/** 
 * Sets up the sensor labels for sensors to be used in network visualization.
 * @param numAgents
 * @return
 */
public static String[] sensorLabels(int numAgents,String type){
  String[] result=new String[numAgents * 2];
  for (int i=0; i < numAgents; i++) {
    result[(2 * i)]="String_Node_Str" + type + "String_Node_Str"+ i;
    result[(2 * i) + 1]="String_Node_Str" + type + "String_Node_Str"+ i;
  }
  return result;
}