nus-yam/ex-repair huggingface dataset:
Program: 164298
Project: 164298
Buggy source:
@Override protected void decorate(){
  for (int i=0; i < LENGTH; i++) {
    if (map[i] == Terrain.EMPTY && Random.Int(10) == 0) {
      map[i]=Terrain.EMPTY_DECO;
    }
 else     if (map[i] == Terrain.WALL && Random.Int(8) == 0) {
      map[i]=Terrain.WALL_DECO;
    }
  }
  while (true) {
    int pos=roomEntrance.random();
    if (pos != entrance) {
      map[pos]=Terrain.SIGN;
      break;
    }
  }
}

Fixed version (ground truth):
@Override protected void decorate(){
  for (int i=0; i < LENGTH; i++) {
    if (map[i] == Terrain.EMPTY && Random.Int(10) == 0) {
      map[i]=Terrain.EMPTY_DECO;
    }
 else     if (map[i] == Terrain.WALL && Random.Int(8) == 0) {
      map[i]=Terrain.WALL_DECO;
    }
  }
  placeSign();
}
Program: 164299
Project: 164299
Buggy source:
@Override protected void decorate(){
  for (int i=WIDTH + 1; i < LENGTH - WIDTH - 1; i++) {
    if (map[i] == Terrain.EMPTY) {
      int count=0;
      for (int j=0; j < NEIGHBOURS8.length; j++) {
        if ((Terrain.flags[map[i + NEIGHBOURS8[j]]] & Terrain.PASSABLE) > 0) {
          count++;
        }
      }
      if (Random.Int(80) < count) {
        map[i]=Terrain.EMPTY_DECO;
      }
    }
 else     if (map[i] == Terrain.WALL && map[i - 1] != Terrain.WALL_DECO && map[i - WIDTH] != Terrain.WALL_DECO && Random.Int(20) == 0) {
      map[i]=Terrain.WALL_DECO;
    }
  }
  while (true) {
    int pos=roomEntrance.random();
    if (pos != entrance) {
      map[pos]=Terrain.SIGN;
      break;
    }
  }
}

Fixed version (ground truth):
@Override protected void decorate(){
  for (int i=WIDTH + 1; i < LENGTH - WIDTH - 1; i++) {
    if (map[i] == Terrain.EMPTY) {
      int count=0;
      for (int j=0; j < NEIGHBOURS8.length; j++) {
        if ((Terrain.flags[map[i + NEIGHBOURS8[j]]] & Terrain.PASSABLE) > 0) {
          count++;
        }
      }
      if (Random.Int(80) < count) {
        map[i]=Terrain.EMPTY_DECO;
      }
    }
 else     if (map[i] == Terrain.WALL && map[i - 1] != Terrain.WALL_DECO && map[i - WIDTH] != Terrain.WALL_DECO && Random.Int(20) == 0) {
      map[i]=Terrain.WALL_DECO;
    }
  }
  placeSign();
}
Program: 164300
Project: 164300
Buggy source:
@Override protected void decorate(){
  for (int i=0; i < LENGTH; i++) {
    if (map[i] == Terrain.EMPTY && Random.Int(10) == 0) {
      map[i]=Terrain.EMPTY_DECO;
    }
 else     if (map[i] == Terrain.WALL && Random.Int(8) == 0) {
      map[i]=Terrain.WALL_DECO;
    }
 else     if (map[i] == Terrain.SECRET_DOOR) {
      map[i]=Terrain.DOOR;
    }
  }
  if (Imp.Quest.isCompleted()) {
    while (true) {
      int pos=roomEntrance.random();
      if (pos != entrance) {
        map[pos]=Terrain.SIGN;
        break;
      }
    }
  }
}

Fixed version (ground truth):
@Override protected void decorate(){
  for (int i=0; i < LENGTH; i++) {
    if (map[i] == Terrain.EMPTY && Random.Int(10) == 0) {
      map[i]=Terrain.EMPTY_DECO;
    }
 else     if (map[i] == Terrain.WALL && Random.Int(8) == 0) {
      map[i]=Terrain.WALL_DECO;
    }
 else     if (map[i] == Terrain.SECRET_DOOR) {
      map[i]=Terrain.DOOR;
    }
  }
  if (Imp.Quest.isCompleted()) {
    placeSign();
  }
}
Program: 164301
Project: 164301
Buggy source:
@Override protected void decorate(){
  for (int i=WIDTH + 1; i < LENGTH - WIDTH - 1; i++) {
    if (map[i] == Terrain.EMPTY) {
      float c=0.15f;
      if (map[i + 1] == Terrain.WALL && map[i + WIDTH] == Terrain.WALL) {
        c+=0.2f;
      }
      if (map[i - 1] == Terrain.WALL && map[i + WIDTH] == Terrain.WALL) {
        c+=0.2f;
      }
      if (map[i + 1] == Terrain.WALL && map[i - WIDTH] == Terrain.WALL) {
        c+=0.2f;
      }
      if (map[i - 1] == Terrain.WALL && map[i - WIDTH] == Terrain.WALL) {
        c+=0.2f;
      }
      if (Random.Float() < c) {
        map[i]=Terrain.EMPTY_DECO;
      }
    }
  }
  for (int i=0; i < WIDTH; i++) {
    if (map[i] == Terrain.WALL && (map[i + WIDTH] == Terrain.EMPTY || map[i + WIDTH] == Terrain.EMPTY_SP) && Random.Int(4) == 0) {
      map[i]=Terrain.WALL_DECO;
    }
  }
  for (int i=WIDTH; i < LENGTH - WIDTH; i++) {
    if (map[i] == Terrain.WALL && map[i - WIDTH] == Terrain.WALL && (map[i + WIDTH] == Terrain.EMPTY || map[i + WIDTH] == Terrain.EMPTY_SP) && Random.Int(2) == 0) {
      map[i]=Terrain.WALL_DECO;
    }
  }
  while (true) {
    int pos=roomEntrance.random();
    if (pos != entrance) {
      map[pos]=Terrain.SIGN;
      break;
    }
  }
  Point door=roomExit.entrance();
  arenaDoor=door.x + door.y * WIDTH;
  Painter.set(this,arenaDoor,Terrain.LOCKED_DOOR);
  Painter.fill(this,roomExit.left + 2,roomExit.top + 2,roomExit.width() - 3,roomExit.height() - 3,Terrain.INACTIVE_TRAP);
}

Fixed version (ground truth):
@Override protected void decorate(){
  for (int i=WIDTH + 1; i < LENGTH - WIDTH - 1; i++) {
    if (map[i] == Terrain.EMPTY) {
      float c=0.15f;
      if (map[i + 1] == Terrain.WALL && map[i + WIDTH] == Terrain.WALL) {
        c+=0.2f;
      }
      if (map[i - 1] == Terrain.WALL && map[i + WIDTH] == Terrain.WALL) {
        c+=0.2f;
      }
      if (map[i + 1] == Terrain.WALL && map[i - WIDTH] == Terrain.WALL) {
        c+=0.2f;
      }
      if (map[i - 1] == Terrain.WALL && map[i - WIDTH] == Terrain.WALL) {
        c+=0.2f;
      }
      if (Random.Float() < c) {
        map[i]=Terrain.EMPTY_DECO;
      }
    }
  }
  for (int i=0; i < WIDTH; i++) {
    if (map[i] == Terrain.WALL && (map[i + WIDTH] == Terrain.EMPTY || map[i + WIDTH] == Terrain.EMPTY_SP) && Random.Int(4) == 0) {
      map[i]=Terrain.WALL_DECO;
    }
  }
  for (int i=WIDTH; i < LENGTH - WIDTH; i++) {
    if (map[i] == Terrain.WALL && map[i - WIDTH] == Terrain.WALL && (map[i + WIDTH] == Terrain.EMPTY || map[i + WIDTH] == Terrain.EMPTY_SP) && Random.Int(2) == 0) {
      map[i]=Terrain.WALL_DECO;
    }
  }
  placeSign();
  Point door=roomExit.entrance();
  arenaDoor=door.x + door.y * WIDTH;
  Painter.set(this,arenaDoor,Terrain.LOCKED_DOOR);
  Painter.fill(this,roomExit.left + 2,roomExit.top + 2,roomExit.width() - 3,roomExit.height() - 3,Terrain.INACTIVE_TRAP);
}
Program: 164302
Project: 164302
Buggy source:
@Override protected void decorate(){
  for (int i=WIDTH + 1; i < LENGTH - WIDTH - 1; i++) {
    if (map[i] == Terrain.EMPTY) {
      float c=0.05f;
      if (map[i + 1] == Terrain.WALL && map[i + WIDTH] == Terrain.WALL) {
        c+=0.2f;
      }
      if (map[i - 1] == Terrain.WALL && map[i + WIDTH] == Terrain.WALL) {
        c+=0.2f;
      }
      if (map[i + 1] == Terrain.WALL && map[i - WIDTH] == Terrain.WALL) {
        c+=0.2f;
      }
      if (map[i - 1] == Terrain.WALL && map[i - WIDTH] == Terrain.WALL) {
        c+=0.2f;
      }
      if (Random.Float() < c) {
        map[i]=Terrain.EMPTY_DECO;
      }
    }
  }
  for (int i=0; i < WIDTH; i++) {
    if (map[i] == Terrain.WALL && (map[i + WIDTH] == Terrain.EMPTY || map[i + WIDTH] == Terrain.EMPTY_SP) && Random.Int(6) == 0) {
      map[i]=Terrain.WALL_DECO;
    }
  }
  for (int i=WIDTH; i < LENGTH - WIDTH; i++) {
    if (map[i] == Terrain.WALL && map[i - WIDTH] == Terrain.WALL && (map[i + WIDTH] == Terrain.EMPTY || map[i + WIDTH] == Terrain.EMPTY_SP) && Random.Int(3) == 0) {
      map[i]=Terrain.WALL_DECO;
    }
  }
  while (true) {
    int pos=roomEntrance.random();
    if (pos != entrance) {
      map[pos]=Terrain.SIGN;
      break;
    }
  }
}

Fixed version (ground truth):
@Override protected void decorate(){
  for (int i=WIDTH + 1; i < LENGTH - WIDTH - 1; i++) {
    if (map[i] == Terrain.EMPTY) {
      float c=0.05f;
      if (map[i + 1] == Terrain.WALL && map[i + WIDTH] == Terrain.WALL) {
        c+=0.2f;
      }
      if (map[i - 1] == Terrain.WALL && map[i + WIDTH] == Terrain.WALL) {
        c+=0.2f;
      }
      if (map[i + 1] == Terrain.WALL && map[i - WIDTH] == Terrain.WALL) {
        c+=0.2f;
      }
      if (map[i - 1] == Terrain.WALL && map[i - WIDTH] == Terrain.WALL) {
        c+=0.2f;
      }
      if (Random.Float() < c) {
        map[i]=Terrain.EMPTY_DECO;
      }
    }
  }
  for (int i=0; i < WIDTH; i++) {
    if (map[i] == Terrain.WALL && (map[i + WIDTH] == Terrain.EMPTY || map[i + WIDTH] == Terrain.EMPTY_SP) && Random.Int(6) == 0) {
      map[i]=Terrain.WALL_DECO;
    }
  }
  for (int i=WIDTH; i < LENGTH - WIDTH; i++) {
    if (map[i] == Terrain.WALL && map[i - WIDTH] == Terrain.WALL && (map[i + WIDTH] == Terrain.EMPTY || map[i + WIDTH] == Terrain.EMPTY_SP) && Random.Int(3) == 0) {
      map[i]=Terrain.WALL_DECO;
    }
  }
  placeSign();
}
Program: 164303
Project: 164303
Buggy source:
@Override protected void decorate(){
  int start=roomExit.top * WIDTH + roomExit.left + 1;
  int end=start + roomExit.width() - 1;
  for (int i=start; i < end; i++) {
    if (i != exit && map[i] == Terrain.WALL) {
      map[i]=Terrain.WALL_DECO;
      map[i + WIDTH]=Terrain.WATER;
    }
 else {
      map[i + WIDTH]=Terrain.EMPTY;
    }
  }
  while (true) {
    int pos=roomEntrance.random();
    if (pos != entrance) {
      map[pos]=Terrain.SIGN;
      break;
    }
  }
}

Fixed version (ground truth):
@Override protected void decorate(){
  int start=roomExit.top * WIDTH + roomExit.left + 1;
  int end=start + roomExit.width() - 1;
  for (int i=start; i < end; i++) {
    if (i != exit && map[i] == Terrain.WALL) {
      map[i]=Terrain.WALL_DECO;
      map[i + WIDTH]=Terrain.WATER;
    }
 else {
      map[i + WIDTH]=Terrain.EMPTY;
    }
  }
  placeSign();
}
Program: 164304
Project: 164304
Buggy source:
@Override protected void decorate(){
  for (int i=0; i < WIDTH; i++) {
    if (map[i] == Terrain.WALL && map[i + WIDTH] == Terrain.WATER && Random.Int(4) == 0) {
      map[i]=Terrain.WALL_DECO;
    }
  }
  for (int i=WIDTH; i < LENGTH - WIDTH; i++) {
    if (map[i] == Terrain.WALL && map[i - WIDTH] == Terrain.WALL && map[i + WIDTH] == Terrain.WATER && Random.Int(2) == 0) {
      map[i]=Terrain.WALL_DECO;
    }
  }
  for (int i=WIDTH + 1; i < LENGTH - WIDTH - 1; i++) {
    if (map[i] == Terrain.EMPTY) {
      int count=(map[i + 1] == Terrain.WALL ? 1 : 0) + (map[i - 1] == Terrain.WALL ? 1 : 0) + (map[i + WIDTH] == Terrain.WALL ? 1 : 0)+ (map[i - WIDTH] == Terrain.WALL ? 1 : 0);
      if (Random.Int(16) < count * count) {
        map[i]=Terrain.EMPTY_DECO;
      }
    }
  }
  while (true) {
    int pos=roomEntrance.random();
    if (pos != entrance) {
      map[pos]=Terrain.SIGN;
      break;
    }
  }
}

Fixed version (ground truth):
@Override protected void decorate(){
  for (int i=0; i < WIDTH; i++) {
    if (map[i] == Terrain.WALL && map[i + WIDTH] == Terrain.WATER && Random.Int(4) == 0) {
      map[i]=Terrain.WALL_DECO;
    }
  }
  for (int i=WIDTH; i < LENGTH - WIDTH; i++) {
    if (map[i] == Terrain.WALL && map[i - WIDTH] == Terrain.WALL && map[i + WIDTH] == Terrain.WATER && Random.Int(2) == 0) {
      map[i]=Terrain.WALL_DECO;
    }
  }
  for (int i=WIDTH + 1; i < LENGTH - WIDTH - 1; i++) {
    if (map[i] == Terrain.EMPTY) {
      int count=(map[i + 1] == Terrain.WALL ? 1 : 0) + (map[i - 1] == Terrain.WALL ? 1 : 0) + (map[i + WIDTH] == Terrain.WALL ? 1 : 0)+ (map[i - WIDTH] == Terrain.WALL ? 1 : 0);
      if (Random.Int(16) < count * count) {
        map[i]=Terrain.EMPTY_DECO;
      }
    }
  }
  placeSign();
}
Program: 164305
Project: 164305
Buggy source:
private void placePlants(float numPlants,float numDews,float numPods,float numStars){
  Iterator<Integer> cells=affectedCells.iterator();
  Level floor=Dungeon.level;
  while (cells.hasNext() && Random.Float() <= numPlants) {
    Plant.Seed seed=(Plant.Seed)Generator.random(Generator.Category.SEED);
    if (seed instanceof BlandfruitBush.Seed) {
      if (Random.Int(15) - Dungeon.limitedDrops.blandfruitSeed.count >= 0) {
        floor.plant(seed,cells.next());
        Dungeon.limitedDrops.blandfruitSeed.count++;
      }
    }
 else     if (seed != null)     floor.plant(seed,cells.next());
    numPlants--;
  }
  while (cells.hasNext() && Random.Float() <= numDews) {
    floor.plant(new Dewcatcher.Seed(),cells.next());
    numDews--;
  }
  while (cells.hasNext() && Random.Float() <= numPods) {
    floor.plant(new Seedpod.Seed(),cells.next());
    numPods--;
  }
  while (cells.hasNext() && Random.Float() <= numStars) {
    floor.plant(new Starflower.Seed(),cells.next());
    numStars--;
  }
}

Fixed version (ground truth):
private void placePlants(float numPlants,float numDews,float numPods,float numStars){
  Iterator<Integer> cells=affectedCells.iterator();
  Level floor=Dungeon.level;
  while (cells.hasNext() && Random.Float() <= numPlants) {
    Plant.Seed seed=(Plant.Seed)Generator.random(Generator.Category.SEED);
    if (seed instanceof BlandfruitBush.Seed) {
      if (Random.Int(15) - Dungeon.limitedDrops.blandfruitSeed.count >= 0) {
        floor.plant(seed,cells.next());
        Dungeon.limitedDrops.blandfruitSeed.count++;
      }
    }
 else     floor.plant(seed,cells.next());
    numPlants--;
  }
  while (cells.hasNext() && Random.Float() <= numDews) {
    floor.plant(new Dewcatcher.Seed(),cells.next());
    numDews--;
  }
  while (cells.hasNext() && Random.Float() <= numPods) {
    floor.plant(new Seedpod.Seed(),cells.next());
    numPods--;
  }
  while (cells.hasNext() && Random.Float() <= numStars) {
    floor.plant(new Starflower.Seed(),cells.next());
    numStars--;
  }
}
Program: 164306
Project: 164306
Buggy source:
@Override public int defenseProc(Char enemy,int damage){
  if (HP >= damage + 2) {
    ArrayList<Integer> candidates=new ArrayList<Integer>();
    boolean[] passable=Level.passable;
    int[] neighbours={pos + 1,pos - 1,pos + Level.WIDTH,pos - Level.WIDTH};
    for (    int n : neighbours) {
      if (passable[n] && Actor.findChar(n) == null) {
        candidates.add(n);
      }
    }
    if (candidates.size() > 0) {
      Swarm clone=split();
      clone.HP=(HP - damage) / 2;
      clone.pos=Random.element(candidates);
      clone.state=clone.HUNTING;
      if (Dungeon.level.map[clone.pos] == Terrain.DOOR) {
        Door.enter(clone.pos);
      }
      GameScene.add(clone,SPLIT_DELAY);
      Actor.addDelayed(new Pushing(clone,pos,clone.pos),-1);
      HP-=clone.HP;
    }
  }
  return damage;
}

Fixed version (ground truth):
@Override public int defenseProc(Char enemy,int damage){
  if (HP >= damage + 2) {
    ArrayList<Integer> candidates=new ArrayList<Integer>();
    boolean[] passable=Level.passable;
    int[] neighbours={pos + 1,pos - 1,pos + Level.WIDTH,pos - Level.WIDTH};
    for (    int n : neighbours) {
      if (passable[n] && Actor.findChar(n) == null) {
        candidates.add(n);
      }
    }
    if (candidates.size() > 0) {
      Swarm clone=split();
      clone.HP=(HP - damage) / 2;
      clone.pos=Random.element(candidates);
      clone.state=clone.HUNTING;
      if (Dungeon.level.map[clone.pos] == Terrain.DOOR) {
        Door.enter(clone.pos);
      }
      GameScene.add(clone,SPLIT_DELAY);
      Actor.addDelayed(new Pushing(clone,pos,clone.pos),-1);
      HP-=clone.HP;
    }
  }
  return super.defenseProc(enemy,damage);
}
Program: 164307
Project: 164307
Buggy source:
@Override public int defenseProc(Char enemy,int damage){
  if (state == FLEEING) {
    Dungeon.level.drop(new Gold(),pos).sprite.drop();
  }
  return damage;
}

Fixed version (ground truth):
@Override public int defenseProc(Char enemy,int damage){
  if (state == FLEEING) {
    Dungeon.level.drop(new Gold(),pos).sprite.drop();
  }
  return super.defenseProc(enemy,damage);
}
Program: 164308
Project: 164308
Buggy source:
@Override public void die(Object cause){
  super.die(cause);
  if (item != null) {
    Dungeon.level.drop(item,pos).sprite.drop();
  }
}

Fixed version (ground truth):
@Override public void die(Object cause){
  super.die(cause);
  if (item != null) {
    Dungeon.level.drop(item,pos).sprite.drop();
    if (item instanceof Honeypot.ShatteredPot)     ((Honeypot.ShatteredPot)item).setHolder(this);
  }
}
Program: 164309
Project: 164309
Buggy source:
public void call(){
  ch.pos=newPos;
  if (ch.pos == trajectory.collisionPos) {
    ch.damage(Random.NormalIntRange((finalDist + 1) / 2,finalDist),this);
    Paralysis.prolong(ch,Paralysis.class,Random.NormalIntRange((finalDist + 1) / 2,finalDist));
    Dungeon.level.press(ch.pos,ch);
  }
}

Fixed version (ground truth):
public void call(){
  ch.pos=newPos;
  if (ch.pos == trajectory.collisionPos) {
    ch.damage(Random.NormalIntRange((finalDist + 1) / 2,finalDist),this);
    Paralysis.prolong(ch,Paralysis.class,Random.NormalIntRange((finalDist + 1) / 2,finalDist));
  }
  Dungeon.level.press(ch.pos,ch);
}
Program: 164310
Project: 164310
Buggy source:
private void throwChar(final Char ch,final Ballistica trajectory,int power){
  int dist=Math.min(trajectory.dist,power);
  if ((ch instanceof King) || (ch instanceof Golem) || (ch instanceof Yog.RottingFist))   dist/=2;
  if (dist == 0 || ch instanceof Yog)   return;
  if (Actor.findChar(trajectory.path.get(dist)) != null) {
    dist--;
  }
  final int newPos=trajectory.path.get(dist);
  if (newPos == ch.pos)   return;
  final int finalDist=dist;
  Actor.addDelayed(new Pushing(ch,ch.pos,newPos,new Callback(){
    public void call(){
      ch.pos=newPos;
      if (ch.pos == trajectory.collisionPos) {
        ch.damage(Random.NormalIntRange((finalDist + 1) / 2,finalDist),this);
        Paralysis.prolong(ch,Paralysis.class,Random.NormalIntRange((finalDist + 1) / 2,finalDist));
        Dungeon.level.press(ch.pos,ch);
      }
    }
  }
),-1);
}

Fixed version (ground truth):
private void throwChar(final Char ch,final Ballistica trajectory,int power){
  int dist=Math.min(trajectory.dist,power);
  if ((ch instanceof King) || (ch instanceof Golem) || (ch instanceof Yog.RottingFist))   dist/=2;
  if (dist == 0 || ch instanceof Yog)   return;
  if (Actor.findChar(trajectory.path.get(dist)) != null) {
    dist--;
  }
  final int newPos=trajectory.path.get(dist);
  if (newPos == ch.pos)   return;
  final int finalDist=dist;
  Actor.addDelayed(new Pushing(ch,ch.pos,newPos,new Callback(){
    public void call(){
      ch.pos=newPos;
      if (ch.pos == trajectory.collisionPos) {
        ch.damage(Random.NormalIntRange((finalDist + 1) / 2,finalDist),this);
        Paralysis.prolong(ch,Paralysis.class,Random.NormalIntRange((finalDist + 1) / 2,finalDist));
      }
      Dungeon.level.press(ch.pos,ch);
    }
  }
),-1);
}
Program: 164311
Project: 164311
Buggy source:
public static void paint(Level level,Room room){
  fill(level,room,Terrain.WALL);
  fill(level,room,1,Terrain.TRAP);
  fill(level,room,2,Terrain.EMPTY_SP);
  for (  int cell : room.getCells()) {
    if (level.map[cell] == Terrain.TRAP) {
      level.setTrap(new FireTrap().reveal(),cell);
    }
  }
  for (int i=0; i < 2; i++) {
    int pos;
    do {
      pos=room.random();
    }
 while (level.map[pos] != Terrain.EMPTY_SP);
    level.drop(Generator.random(Random.oneOf(Generator.Category.ARMOR,Generator.Category.WEAPON)),pos);
  }
  for (  Room.Door door : room.connected.values()) {
    door.set(Room.Door.Type.UNLOCKED);
    drawInside(level,room,door,1,Terrain.EMPTY);
  }
  Blacksmith npc=new Blacksmith();
  do {
    npc.pos=room.random(1);
  }
 while (level.heaps.get(npc.pos) != null);
  level.mobs.add(npc);
}

Fixed version (ground truth):
public static void paint(Level level,Room room){
  fill(level,room,Terrain.WALL);
  fill(level,room,1,Terrain.TRAP);
  fill(level,room,2,Terrain.EMPTY_SP);
  for (int i=0; i < 2; i++) {
    int pos;
    do {
      pos=room.random();
    }
 while (level.map[pos] != Terrain.EMPTY_SP);
    level.drop(Generator.random(Random.oneOf(Generator.Category.ARMOR,Generator.Category.WEAPON)),pos);
  }
  for (  Room.Door door : room.connected.values()) {
    door.set(Room.Door.Type.UNLOCKED);
    drawInside(level,room,door,1,Terrain.EMPTY);
  }
  Blacksmith npc=new Blacksmith();
  do {
    npc.pos=room.random(1);
  }
 while (level.heaps.get(npc.pos) != null);
  level.mobs.add(npc);
  for (  int cell : room.getCells()) {
    if (level.map[cell] == Terrain.TRAP) {
      level.setTrap(new FireTrap().reveal(),cell);
    }
  }
}
Program: 164312
Project: 164312
Buggy source:
public MagesStaff(Wand wand){
  this();
  wand.identify();
  wand.cursed=false;
  this.wand=wand;
  wand.maxCharges=Math.min(wand.maxCharges + 1,10);
}

Fixed version (ground truth):
public MagesStaff(Wand wand){
  this();
  wand.identify();
  wand.cursed=false;
  this.wand=wand;
  wand.maxCharges=Math.min(wand.maxCharges + 1,10);
  wand.curCharges=wand.maxCharges;
}
Program: 164313
Project: 164313
Buggy source:
public Item imbueWand(Wand wand,Char owner){
  this.wand=null;
  GLog.p("String_Node_Str" + wand.name());
  if (enchantment != null) {
    GLog.w("String_Node_Str");
    enchant(null);
  }
  int targetLevel=Math.max(this.level,wand.level);
  int staffLevelDiff=targetLevel - this.level;
  if (staffLevelDiff > 0)   this.upgrade(staffLevelDiff);
 else   if (staffLevelDiff < 0)   this.degrade(Math.abs(staffLevelDiff));
  int wandLevelDiff=targetLevel - wand.level;
  if (wandLevelDiff > 0)   wand.upgrade(wandLevelDiff);
 else   if (wandLevelDiff < 0)   wand.degrade(Math.abs(wandLevelDiff));
  this.wand=wand;
  wand.maxCharges=Math.min(wand.maxCharges + 1,10);
  wand.identify();
  wand.cursed=false;
  wand.charge(owner);
  updateQuickslot();
  return this;
}

Fixed version (ground truth):
public Item imbueWand(Wand wand,Char owner){
  this.wand=null;
  GLog.p("String_Node_Str" + wand.name());
  if (enchantment != null) {
    GLog.w("String_Node_Str");
    enchant(null);
  }
  int targetLevel=Math.max(this.level,wand.level);
  int staffLevelDiff=targetLevel - this.level;
  if (staffLevelDiff > 0)   this.upgrade(staffLevelDiff);
 else   if (staffLevelDiff < 0)   this.degrade(Math.abs(staffLevelDiff));
  int wandLevelDiff=targetLevel - wand.level;
  if (wandLevelDiff > 0)   wand.upgrade(wandLevelDiff);
 else   if (wandLevelDiff < 0)   wand.degrade(Math.abs(wandLevelDiff));
  this.wand=wand;
  wand.maxCharges=Math.min(wand.maxCharges + 1,10);
  wand.curCharges=wand.maxCharges;
  wand.identify();
  wand.cursed=false;
  wand.charge(owner);
  updateQuickslot();
  return this;
}
Program: 164314
Project: 164314
Buggy source:
@Override public Item degrade(){
  super.degrade();
  STR=10;
  if (wand != null) {
    wand.degrade();
    wand.maxCharges=Math.min(wand.maxCharges + 1,10);
  }
  return this;
}

Fixed version (ground truth):
@Override public Item degrade(){
  super.degrade();
  STR=10;
  if (wand != null) {
    int curCharges=wand.curCharges;
    wand.degrade();
    wand.maxCharges=Math.min(wand.maxCharges + 1,10);
    wand.curCharges=curCharges - 1;
    updateQuickslot();
  }
  return this;
}
Program: 164315
Project: 164315
Buggy source:
@Override public Item upgrade(boolean enchant){
  super.upgrade(enchant);
  STR=10;
  if (wand != null) {
    wand.upgrade();
    wand.maxCharges=Math.min(wand.maxCharges + 1,10);
  }
  return this;
}

Fixed version (ground truth):
@Override public Item upgrade(boolean enchant){
  super.upgrade(enchant);
  STR=10;
  if (wand != null) {
    int curCharges=wand.curCharges;
    wand.upgrade();
    wand.maxCharges=Math.min(wand.maxCharges + 1,10);
    wand.curCharges=curCharges + 1;
    updateQuickslot();
  }
  return this;
}
Program: 164316
Project: 164316
Buggy source:
@Override protected void createMobs(){
  int mobsToSpawn=Dungeon.depth == 1 ? 10 : nMobs();
  HashSet<Room> stdRooms=new HashSet<>();
  for (  Room room : rooms) {
    if (room.type == Type.STANDARD)     stdRooms.add(room);
  }
  Iterator<Room> stdRoomIter=stdRooms.iterator();
  while (mobsToSpawn > 0) {
    if (!stdRoomIter.hasNext())     stdRoomIter=stdRooms.iterator();
    Room roomToSpawn=stdRoomIter.next();
    Mob mob=Bestiary.mob(Dungeon.depth);
    mob.pos=roomToSpawn.random();
    if (Actor.findChar(mob.pos) == null && Level.passable[mob.pos]) {
      mobsToSpawn--;
      mobs.add(mob);
      if (mobsToSpawn > 0 && Random.Int(4) == 0) {
        mob=Bestiary.mob(Dungeon.depth);
        mob.pos=roomToSpawn.random();
        if (Actor.findChar(mob.pos) == null && Level.passable[mob.pos]) {
          mobsToSpawn--;
          mobs.add(mob);
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override protected void createMobs(){
  int mobsToSpawn=Dungeon.depth == 1 ? 10 : nMobs();
  HashSet<Room> stdRooms=new HashSet<>();
  for (  Room room : rooms) {
    if (room.type == Type.STANDARD)     stdRooms.add(room);
  }
  Iterator<Room> stdRoomIter=stdRooms.iterator();
  while (mobsToSpawn > 0) {
    if (!stdRoomIter.hasNext())     stdRoomIter=stdRooms.iterator();
    Room roomToSpawn=stdRoomIter.next();
    Mob mob=Bestiary.mob(Dungeon.depth);
    mob.pos=roomToSpawn.random();
    if (findMob(mob.pos) == null && Level.passable[mob.pos]) {
      mobsToSpawn--;
      mobs.add(mob);
      if (mobsToSpawn > 0 && Random.Int(4) == 0) {
        mob=Bestiary.mob(Dungeon.depth);
        mob.pos=roomToSpawn.random();
        if (findMob(mob.pos) == null && Level.passable[mob.pos]) {
          mobsToSpawn--;
          mobs.add(mob);
        }
      }
    }
  }
}
Program: 164317
Project: 164317
Buggy source:
public static void paint(Level level,Room room){
  fill(level,room,Terrain.WALL);
  fill(level,room,1,Terrain.WATER);
  Room.Door door=room.entrance();
  door.set(Room.Door.Type.REGULAR);
  int x=-1;
  int y=-1;
  if (door.x == room.left) {
    x=room.right - 1;
    y=room.top + room.height() / 2;
  }
 else   if (door.x == room.right) {
    x=room.left + 1;
    y=room.top + room.height() / 2;
  }
 else   if (door.y == room.top) {
    x=room.left + room.width() / 2;
    y=room.bottom - 1;
  }
 else   if (door.y == room.bottom) {
    x=room.left + room.width() / 2;
    y=room.top + 1;
  }
  int pos=x + y * Level.WIDTH;
  level.drop(prize(level),pos).type=Random.Int(3) == 0 ? Heap.Type.CHEST : Heap.Type.HEAP;
  set(level,pos,Terrain.PEDESTAL);
  level.addItemToSpawn(new PotionOfInvisibility());
  for (int i=0; i < NPIRANHAS; i++) {
    Piranha piranha=new Piranha();
    do {
      piranha.pos=room.random();
    }
 while (level.map[piranha.pos] != Terrain.WATER || Actor.findChar(piranha.pos) != null);
    level.mobs.add(piranha);
  }
}

Fixed version (ground truth):
public static void paint(Level level,Room room){
  fill(level,room,Terrain.WALL);
  fill(level,room,1,Terrain.WATER);
  Room.Door door=room.entrance();
  door.set(Room.Door.Type.REGULAR);
  int x=-1;
  int y=-1;
  if (door.x == room.left) {
    x=room.right - 1;
    y=room.top + room.height() / 2;
  }
 else   if (door.x == room.right) {
    x=room.left + 1;
    y=room.top + room.height() / 2;
  }
 else   if (door.y == room.top) {
    x=room.left + room.width() / 2;
    y=room.bottom - 1;
  }
 else   if (door.y == room.bottom) {
    x=room.left + room.width() / 2;
    y=room.top + 1;
  }
  int pos=x + y * Level.WIDTH;
  level.drop(prize(level),pos).type=Random.Int(3) == 0 ? Heap.Type.CHEST : Heap.Type.HEAP;
  set(level,pos,Terrain.PEDESTAL);
  level.addItemToSpawn(new PotionOfInvisibility());
  for (int i=0; i < NPIRANHAS; i++) {
    Piranha piranha=new Piranha();
    do {
      piranha.pos=room.random();
    }
 while (level.map[piranha.pos] != Terrain.WATER || level.findMob(piranha.pos) != null);
    level.mobs.add(piranha);
  }
}
Program: 164318
Project: 164318
Buggy source:
public static void process(){
  if (current != null) {
    return;
  }
  boolean doNext;
  do {
    now=Float.MAX_VALUE;
    current=null;
    Arrays.fill(chars,null);
    for (    Actor actor : all) {
      if (actor.time < now || actor.time == now && actor.actPriority < current.actPriority) {
        now=actor.time;
        current=actor;
      }
      if (actor instanceof Char) {
        Char ch=(Char)actor;
        chars[ch.pos]=ch;
      }
    }
    if (current != null) {
      if (current instanceof Char && ((Char)current).sprite.isMoving) {
        current=null;
        break;
      }
      doNext=current.act();
      if (doNext && !Dungeon.hero.isAlive()) {
        doNext=false;
        current=null;
      }
    }
 else {
      doNext=false;
    }
  }
 while (doNext);
}

Fixed version (ground truth):
public static void process(){
  if (current != null) {
    return;
  }
  boolean doNext;
  do {
    now=Float.MAX_VALUE;
    current=null;
    Arrays.fill(chars,null);
    for (    Actor actor : all) {
      if (actor.time < now || actor.time == now && (current == null || actor.actPriority < current.actPriority)) {
        now=actor.time;
        current=actor;
      }
      if (actor instanceof Char) {
        Char ch=(Char)actor;
        chars[ch.pos]=ch;
      }
    }
    if (current != null) {
      if (current instanceof Char && ((Char)current).sprite.isMoving) {
        current=null;
        break;
      }
      doNext=current.act();
      if (doNext && !Dungeon.hero.isAlive()) {
        doNext=false;
        current=null;
      }
    }
 else {
      doNext=false;
    }
  }
 while (doNext);
}
Program: 164319
Project: 164319
Buggy source:
@Override public boolean act(){
  if (target.isAlive()) {
    if (target.HP < target.HT && !((Hero)target).isStarving()) {
      target.HP+=1;
    }
    ChaliceOfBlood.chaliceRegen regenBuff=Dungeon.hero.buff(ChaliceOfBlood.chaliceRegen.class);
    if (regenBuff != null)     if (regenBuff.isCursed())     spend(REGENERATION_DELAY * 1.5f);
 else     spend(regenBuff.level() * 0.9f);
 else     spend(REGENERATION_DELAY);
  }
 else {
    diactivate();
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean act(){
  if (target.isAlive()) {
    if (target.HP < target.HT && !((Hero)target).isStarving()) {
      target.HP+=1;
    }
    ChaliceOfBlood.chaliceRegen regenBuff=Dungeon.hero.buff(ChaliceOfBlood.chaliceRegen.class);
    if (regenBuff != null)     if (regenBuff.isCursed())     spend(REGENERATION_DELAY * 1.5f);
 else     spend(REGENERATION_DELAY - regenBuff.level() * 0.9f);
 else     spend(REGENERATION_DELAY);
  }
 else {
    diactivate();
  }
  return true;
}
Program: 164320
Project: 164320
Buggy source:
@Override protected boolean act(){
  if (!Level.water[pos]) {
    die(null);
    return true;
  }
 else {
    Dungeon.level.updateFieldOfView(this);
    enemy=chooseEnemy();
    if (state == this.HUNTING && !(enemy.isAlive() && Level.fieldOfView[enemy.pos] && enemy.invisible <= 0)) {
      state=this.WANDERING;
      int oldPos=pos;
      int i=0;
      do {
        i++;
        target=Dungeon.level.randomDestination();
        if (i == 100)         return true;
      }
 while (!getCloser(target));
      moveSprite(oldPos,pos);
      return true;
    }
    return super.act();
  }
}

Fixed version (ground truth):
@Override protected boolean act(){
  if (!Level.water[pos]) {
    die(null);
    return true;
  }
 else {
    Dungeon.level.updateFieldOfView(this);
    enemy=chooseEnemy();
    if (state == this.HUNTING && !(enemy != null && enemy.isAlive() && Level.fieldOfView[enemy.pos] && enemy.invisible <= 0)) {
      state=this.WANDERING;
      int oldPos=pos;
      int i=0;
      do {
        i++;
        target=Dungeon.level.randomDestination();
        if (i == 100)         return true;
      }
 while (!getCloser(target));
      moveSprite(oldPos,pos);
      return true;
    }
    return super.act();
  }
}
Program: 164321
Project: 164321
Buggy source:
@Override protected void onZap(Ballistica bolt){
  Sample.INSTANCE.play(Assets.SND_BLAST);
  BlastWave.blast(bolt.collisionPos);
  int damage=Random.NormalIntRange(1,6 + (int)(level * level / 4f));
  for (  int i : Level.NEIGHBOURS9) {
    Dungeon.level.press(bolt.collisionPos + i,Actor.findChar(bolt.collisionPos + i));
  }
  for (  int i : Level.NEIGHBOURS8) {
    Char ch=Actor.findChar(bolt.collisionPos + i);
    if (ch != null) {
      ch.damage(damage,this);
      if (ch.isAlive()) {
        Ballistica trajectory=new Ballistica(ch.pos,ch.pos + i,Ballistica.MAGIC_BOLT);
        int strength=1 + ((level + 1) / 3);
        throwChar(ch,trajectory,strength);
      }
    }
  }
  Char ch=Actor.findChar(bolt.collisionPos);
  if (ch != null) {
    ch.damage(damage,this);
    if (ch.isAlive() && bolt.path.size() > bolt.dist) {
      Ballistica trajectory=new Ballistica(ch.pos,bolt.path.get(bolt.dist + 1),Ballistica.MAGIC_BOLT);
      int strength=level + 3;
      throwChar(ch,trajectory,strength);
    }
  }
  if (!curUser.isAlive()) {
    Dungeon.fail(Utils.format(ResultDescriptions.ITEM,name));
    GLog.n("String_Node_Str");
  }
}

Fixed version (ground truth):
@Override protected void onZap(Ballistica bolt){
  Sample.INSTANCE.play(Assets.SND_BLAST);
  BlastWave.blast(bolt.collisionPos);
  int damage=Random.NormalIntRange(1,6 + (int)(level * level / 4f));
  for (  int i : Level.NEIGHBOURS9) {
    Dungeon.level.press(bolt.collisionPos + i,Actor.findChar(bolt.collisionPos + i));
  }
  for (  int i : Level.NEIGHBOURS8) {
    Char ch=Actor.findChar(bolt.collisionPos + i);
    if (ch != null) {
      ch.damage(damage,this);
      if (ch.isAlive()) {
        Ballistica trajectory=new Ballistica(ch.pos,ch.pos + i,Ballistica.MAGIC_BOLT);
        int strength=1 + ((level + 1) / 3);
        throwChar(ch,trajectory,strength);
      }
    }
  }
  Char ch=Actor.findChar(bolt.collisionPos);
  if (ch != null) {
    ch.damage(damage,this);
    if (ch.isAlive() && bolt.path.size() > bolt.dist + 1) {
      Ballistica trajectory=new Ballistica(ch.pos,bolt.path.get(bolt.dist + 1),Ballistica.MAGIC_BOLT);
      int strength=level + 3;
      throwChar(ch,trajectory,strength);
    }
  }
  if (!curUser.isAlive()) {
    Dungeon.fail(Utils.format(ResultDescriptions.ITEM,name));
    GLog.n("String_Node_Str");
  }
}
Program: 164323
Project: 164323
Buggy source:
@Override public String desc(){
  return "String_Node_Str" + ((Char)Actor.findById(object)).name + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
}

Fixed version (ground truth):
@Override public String desc(){
  Char ch=(Char)Actor.findById(object);
  return "String_Node_Str" + ((ch == null) ? "String_Node_Str" : "String_Node_Str" + ch.name) + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
}
Program: 164324
Project: 164324
Buggy source:
private void placePlants(float numPlants,float numDews,float numPods,float numStars){
  Iterator<Integer> cells=affectedCells.iterator();
  Level floor=Dungeon.level;
  while (cells.hasNext() && Random.Float() <= numPlants) {
    floor.plant((Plant.Seed)Generator.random(Generator.Category.SEED),cells.next());
    numPlants--;
  }
  while (cells.hasNext() && Random.Float() <= numDews) {
    floor.plant(new Dewcatcher.Seed(),cells.next());
    numDews--;
  }
  while (cells.hasNext() && Random.Float() <= numPods) {
    floor.plant(new Seedpod.Seed(),cells.next());
    numPods--;
  }
  while (cells.hasNext() && Random.Float() <= numStars) {
    floor.plant(new Starflower.Seed(),cells.next());
    numStars--;
  }
}

Fixed version (ground truth):
private void placePlants(float numPlants,float numDews,float numPods,float numStars){
  Iterator<Integer> cells=affectedCells.iterator();
  Level floor=Dungeon.level;
  while (cells.hasNext() && Random.Float() <= numPlants) {
    Plant.Seed seed=(Plant.Seed)Generator.random(Generator.Category.SEED);
    if (seed instanceof BlandfruitBush.Seed) {
      if (Random.Int(15) - Dungeon.limitedDrops.blandfruitSeed.count >= 0) {
        floor.plant(seed,cells.next());
        Dungeon.limitedDrops.blandfruitSeed.count++;
      }
    }
 else     if (seed != null)     floor.plant(seed,cells.next());
    numPlants--;
  }
  while (cells.hasNext() && Random.Float() <= numDews) {
    floor.plant(new Dewcatcher.Seed(),cells.next());
    numDews--;
  }
  while (cells.hasNext() && Random.Float() <= numPods) {
    floor.plant(new Seedpod.Seed(),cells.next());
    numPods--;
  }
  while (cells.hasNext() && Random.Float() <= numStars) {
    floor.plant(new Starflower.Seed(),cells.next());
    numStars--;
  }
}
Program: 164325
Project: 164325
Buggy source:
@Override public void damage(int dmg,Object src){
  if (fistsCount > 0) {
    for (    Mob mob : Dungeon.level.mobs) {
      if (mob instanceof BurningFist || mob instanceof RottingFist) {
        mob.beckon(pos);
      }
    }
    dmg>>=fistsCount;
  }
  super.damage(dmg,src);
}

Fixed version (ground truth):
@Override public void damage(int dmg,Object src){
  HashSet<Mob> fists=new HashSet<>();
  for (  Mob mob : Dungeon.level.mobs)   if (mob instanceof RottingFist || mob instanceof BurningFist)   fists.add(mob);
  for (  Mob fist : fists)   fist.beckon(pos);
  dmg>>=fists.size();
  super.damage(dmg,src);
}
Program: 164326
Project: 164326
Buggy source:
@Override public void die(Object cause){
  super.die(cause);
  fistsCount--;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Override public void die(Object cause){
  for (  Mob mob : (Iterable<Mob>)Dungeon.level.mobs.clone()) {
    if (mob instanceof BurningFist || mob instanceof RottingFist) {
      mob.die(cause);
    }
  }
  GameScene.bossSlain();
  Dungeon.level.drop(new SkeletonKey(Dungeon.depth),pos).sprite.drop();
  super.die(cause);
  yell("String_Node_Str");
}
Program: 164327
Project: 164327
Buggy source:
@SuppressWarnings("String_Node_Str") public static void switchLevel(final Level level,int pos){
  Dungeon.level=level;
  Actor.init();
  Actor respawner=level.respawner();
  if (respawner != null) {
    Actor.add(level.respawner());
  }
  hero.pos=pos != -1 ? pos : level.exit;
  Light light=hero.buff(Light.class);
  hero.viewDistance=light == null ? level.viewDistance : Math.max(Light.DISTANCE,level.viewDistance);
  observe();
  try {
    saveAll();
  }
 catch (  IOException e) {
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public static void switchLevel(final Level level,int pos){
  Dungeon.level=level;
  Actor.init();
  Actor respawner=level.respawner();
  if (respawner != null) {
    Actor.add(level.respawner());
  }
  hero.pos=pos != -1 ? pos : level.exit;
  Light light=hero.buff(Light.class);
  hero.viewDistance=light == null ? level.viewDistance : Math.max(Light.DISTANCE,level.viewDistance);
  if (Dungeon.version <= 38 && Dungeon.hero.heroClass == HeroClass.MAGE) {
    MagesStaff staff=new MagesStaff();
    staff.identify();
    if (!staff.collect(Dungeon.hero.belongings.backpack)) {
      Dungeon.level.drop(staff,Dungeon.hero.pos);
    }
  }
  observe();
  try {
    saveAll();
  }
 catch (  IOException e) {
  }
}
Program: 164328
Project: 164328
Buggy source:
@Override public String desc(){
  String result="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str";
  if (wand instanceof WandOfMagicMissile) {
    result+="String_Node_Str";
  }
 else   if (wand instanceof WandOfFireblast) {
    result+="String_Node_Str";
  }
 else   if (wand instanceof WandOfLightning) {
    result+="String_Node_Str";
  }
 else   if (wand instanceof WandOfDisintegration) {
    result+="String_Node_Str";
  }
 else   if (wand instanceof WandOfVenom) {
    result+="String_Node_Str";
  }
 else   if (wand instanceof WandOfPrismaticLight) {
    result+="String_Node_Str";
  }
 else   if (wand instanceof WandOfFrost) {
    result+="String_Node_Str";
  }
 else   if (wand instanceof WandOfBlastWave) {
    result+="String_Node_Str";
  }
 else   if (wand instanceof WandOfRegrowth) {
    result+="String_Node_Str";
  }
 else   if (wand instanceof WandOfTransfusion) {
    result+="String_Node_Str";
  }
  return result;
}

Fixed version (ground truth):
@Override public String desc(){
  String result="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str";
  if (wand == null) {
    result+="String_Node_Str";
  }
 else   if (wand instanceof WandOfMagicMissile) {
    result+="String_Node_Str";
  }
 else   if (wand instanceof WandOfFireblast) {
    result+="String_Node_Str";
  }
 else   if (wand instanceof WandOfLightning) {
    result+="String_Node_Str";
  }
 else   if (wand instanceof WandOfDisintegration) {
    result+="String_Node_Str";
  }
 else   if (wand instanceof WandOfVenom) {
    result+="String_Node_Str";
  }
 else   if (wand instanceof WandOfPrismaticLight) {
    result+="String_Node_Str";
  }
 else   if (wand instanceof WandOfFrost) {
    result+="String_Node_Str";
  }
 else   if (wand instanceof WandOfBlastWave) {
    result+="String_Node_Str";
  }
 else   if (wand instanceof WandOfRegrowth) {
    result+="String_Node_Str";
  }
 else   if (wand instanceof WandOfTransfusion) {
    result+="String_Node_Str";
  }
  return result;
}
Program: 164330
Project: 164330
Buggy source:
@Override public boolean attachTo(Char target){
  if (super.attachTo(target)) {
    CellEmitter.center(target.pos).burst(PoisonParticle.SPLASH,5);
    return true;
  }
 else   return false;
}

Fixed version (ground truth):
@Override public boolean attachTo(Char target){
  if (super.attachTo(target) && target.sprite != null) {
    CellEmitter.center(target.pos).burst(PoisonParticle.SPLASH,5);
    return true;
  }
 else   return false;
}
Program: 164332
Project: 164332
Buggy source:
public List<Integer> subPath(int start,int end){
  try {
    end=Math.max(end,path.size() - 1);
    return path.subList(start,end + 1);
  }
 catch (  Exception e) {
    return new ArrayList<>();
  }
}

Fixed version (ground truth):
public List<Integer> subPath(int start,int end){
  try {
    end=Math.min(end,path.size() - 1);
    return path.subList(start,end + 1);
  }
 catch (  Exception e) {
    return new ArrayList<>();
  }
}
Program: 164333
Project: 164333
Buggy source:
@Override public void onDetach(){
  this.owner=null;
  for (  Item item : items)   Dungeon.quickslot.clearItem(item);
}

Fixed version (ground truth):
@Override public void onDetach(){
  this.owner=null;
  for (  Item item : items)   Dungeon.quickslot.clearItem(item);
  updateQuickslot();
}
Program: 164334
Project: 164334
Buggy source:
@Override public void onDetach(){
  for (  Item item : items) {
    ((Wand)item).stopCharging();
  }
}

Fixed version (ground truth):
@Override public void onDetach(){
  super.onDetach();
  for (  Item item : items) {
    ((Wand)item).stopCharging();
  }
}
Program: 164335
Project: 164335
Buggy source:
@Override protected boolean canAttack(Char enemy){
  return Ballistica.cast(pos,enemy.pos,false,true) == enemy.pos;
}

Fixed version (ground truth):
@Override protected boolean canAttack(Char enemy){
  return Ballistica.cast(pos,enemy.pos,false,true) == enemy.pos && !isCharmedBy(enemy);
}
Program: 164336
Project: 164336
Buggy source:
@Override public void storeInBundle(Bundle bundle){
  super.storeInBundle(bundle);
  bundle.put(CHARGECAP,chargeCap);
  bundle.put(STEALTHED,stealthed);
  bundle.put(COOLDOWN,cooldown);
}

Fixed version (ground truth):
@Override public void storeInBundle(Bundle bundle){
  super.storeInBundle(bundle);
  bundle.put(STEALTHED,stealthed);
  bundle.put(COOLDOWN,cooldown);
}
Program: 164337
Project: 164337
Buggy source:
@Override public void restoreFromBundle(Bundle bundle){
  super.restoreFromBundle(bundle);
  chargeCap=bundle.getInt(CHARGECAP);
  stealthed=bundle.getBoolean(STEALTHED);
  cooldown=bundle.getInt(COOLDOWN);
}

Fixed version (ground truth):
@Override public void restoreFromBundle(Bundle bundle){
  super.restoreFromBundle(bundle);
  stealthed=bundle.getBoolean(STEALTHED);
  cooldown=bundle.getInt(COOLDOWN);
}
Program: 164338
Project: 164338
Buggy source:
@Override public Item upgrade(){
  chargeCap=(((level + 1) / 2) + 1);
  while (scrolls.size() > (levelCap - 1 - level))   scrolls.remove(0);
  return super.upgrade();
}

Fixed version (ground truth):
@Override public Item upgrade(){
  chargeCap=(((level + 1) / 2) + 3);
  while (scrolls.size() > (levelCap - 1 - level))   scrolls.remove(0);
  return super.upgrade();
}
Program: 164339
Project: 164339
Buggy source:
@Override public void storeInBundle(Bundle bundle){
  super.storeInBundle(bundle);
  bundle.put(CHARGECAP,chargeCap);
  bundle.put(SCROLLS,scrolls.toArray(new String[scrolls.size()]));
}

Fixed version (ground truth):
@Override public void storeInBundle(Bundle bundle){
  super.storeInBundle(bundle);
  bundle.put(SCROLLS,scrolls.toArray(new String[scrolls.size()]));
}
Program: 164340
Project: 164340
Buggy source:
@Override public void restoreFromBundle(Bundle bundle){
  super.restoreFromBundle(bundle);
  chargeCap=bundle.getInt(CHARGECAP);
  scrolls.clear();
  Collections.addAll(scrolls,bundle.getStringArray(SCROLLS));
}

Fixed version (ground truth):
@Override public void restoreFromBundle(Bundle bundle){
  super.restoreFromBundle(bundle);
  scrolls.clear();
  Collections.addAll(scrolls,bundle.getStringArray(SCROLLS));
}
Program: 164341
Project: 164341
Buggy source:
@Override public int attackProc(Char enemy,int damage){
  KindOfWeapon wep=rangedWeapon != null ? rangedWeapon : belongings.weapon;
  if (wep != null)   wep.proc(this,enemy,damage);
switch (subClass) {
case GLADIATOR:
    if (wep instanceof MeleeWeapon || wep == null) {
      damage+=Buff.affect(this,Combo.class).hit(enemy,damage);
    }
  break;
case BATTLEMAGE:
if (wep instanceof Wand) {
  Wand wand=(Wand)wep;
  if (wand.curCharges < wand.maxCharges && damage > 0) {
    wand.curCharges++;
    if (Dungeon.quickslot.contains(wand)) {
      QuickSlotButton.refresh();
    }
    ScrollOfRecharging.charge(this);
  }
  damage+=wand.curCharges;
}
case SNIPER:
if (rangedWeapon != null) {
Buff.prolong(this,SnipersMark.class,attackDelay() * 1.1f).object=enemy.id();
}
break;
default :
}
return damage;
}

Fixed version (ground truth):
@Override public int attackProc(Char enemy,int damage){
  KindOfWeapon wep=rangedWeapon != null ? rangedWeapon : belongings.weapon;
  if (wep != null)   wep.proc(this,enemy,damage);
switch (subClass) {
case GLADIATOR:
    if (wep instanceof MeleeWeapon || wep == null) {
      damage+=Buff.affect(this,Combo.class).hit(enemy,damage);
    }
  break;
case BATTLEMAGE:
if (wep instanceof Wand) {
  Wand wand=(Wand)wep;
  if (wand.curCharges < wand.maxCharges && damage > 0) {
    wand.curCharges++;
    if (Dungeon.quickslot.contains(wand)) {
      QuickSlotButton.refresh();
    }
    ScrollOfRecharging.charge(this);
  }
  damage+=wand.curCharges;
}
break;
case SNIPER:
if (rangedWeapon != null) {
Buff.prolong(this,SnipersMark.class,attackDelay() * 1.1f).object=enemy.id();
}
break;
default :
}
return damage;
}
Program: 164342
Project: 164342
Buggy source:
@Override public void onSelect(Item item){
  if (item != null) {
    Sample.INSTANCE.play(Assets.SND_EVOKE);
    ScrollOfUpgrade.upgrade(curUser);
    evoke(curUser);
    GLog.w(TXT_DISENCHANTED,item.name());
    item.upgrade();
    curUser.spendAndNext(TIME_TO_DISENCHANT);
    Badges.validateItemLevelAquired(item);
  }
 else {
    if (disenchantEquipped) {
      curUser.belongings.weapon=WandOfMagicMissile.this;
      WandOfMagicMissile.this.updateQuickslot();
    }
 else {
      collect(curUser.belongings.backpack);
    }
  }
}

Fixed version (ground truth):
@Override public void onSelect(Item item){
  if (item != null) {
    Sample.INSTANCE.play(Assets.SND_EVOKE);
    ScrollOfUpgrade.upgrade(curUser);
    evoke(curUser);
    GLog.w(TXT_DISENCHANTED,item.name());
    Dungeon.quickslot.clearItem(WandOfMagicMissile.this);
    WandOfMagicMissile.this.updateQuickslot();
    item.upgrade();
    curUser.spendAndNext(TIME_TO_DISENCHANT);
    Badges.validateItemLevelAquired(item);
  }
 else {
    if (disenchantEquipped) {
      curUser.belongings.weapon=WandOfMagicMissile.this;
      WandOfMagicMissile.this.updateQuickslot();
    }
 else {
      collect(curUser.belongings.backpack);
    }
  }
}
Program: 164344
Project: 164344
Buggy source:
@Override public void onDetach(){
  this.owner=null;
}

Fixed version (ground truth):
@Override public void onDetach(){
  this.owner=null;
  for (  Item item : items)   Dungeon.quickslot.clearItem(item);
}
Program: 164345
Project: 164345
Buggy source:
@Override public void onSelect(Item item){
  if (item != null) {
    ((InventoryScroll)curItem).onItemSelected(item);
    curUser.spendAndNext(TIME_TO_READ);
    Sample.INSTANCE.play(Assets.SND_READ);
    Invisibility.dispel();
  }
 else   if (identifiedByUse && !((Scroll)curItem).ownedByBook) {
    ((InventoryScroll)curItem).confirmCancelation();
  }
 else {
    curItem.collect(curUser.belongings.backpack);
  }
}

Fixed version (ground truth):
@Override public void onSelect(Item item){
  if (item != null) {
    ((InventoryScroll)curItem).onItemSelected(item);
    curUser.spendAndNext(TIME_TO_READ);
    Sample.INSTANCE.play(Assets.SND_READ);
    Invisibility.dispel();
  }
 else   if (identifiedByUse && !((Scroll)curItem).ownedByBook) {
    ((InventoryScroll)curItem).confirmCancelation();
  }
 else   if (!((Scroll)curItem).ownedByBook) {
    curItem.collect(curUser.belongings.backpack);
  }
}