nus-yam/ex-repair huggingface dataset:
Program: 164252
Project: 164252
Buggy source:
private boolean chain(int target){
  if (chainsUsed)   return false;
  Ballistica chain=new Ballistica(pos,target,Ballistica.PROJECTILE);
  if (chain.collisionPos != Dungeon.hero.pos || Level.pit[chain.path.get(1)])   return false;
 else {
    int newPos=-1;
    for (    int i : chain.subPath(1,chain.dist)) {
      if (!Level.solid[i] && Actor.findChar(i) == null) {
        newPos=i;
        break;
      }
    }
    if (newPos == -1) {
      return false;
    }
 else {
      final int newHeroPos=newPos;
      yell("String_Node_Str");
      sprite.parent.add(new Chains(pos,Dungeon.hero.pos,new Callback(){
        public void call(){
          Actor.addDelayed(new Pushing(Dungeon.hero,Dungeon.hero.pos,newHeroPos),-1);
          Dungeon.hero.pos=newHeroPos;
          Dungeon.observe();
          Dungeon.level.press(newHeroPos,Dungeon.hero);
          Cripple.prolong(Dungeon.hero,Cripple.class,4f);
          Dungeon.hero.interrupt();
          next();
        }
      }
));
    }
  }
  chainsUsed=true;
  return true;
}

Fixed version (ground truth):
private boolean chain(int target){
  if (chainsUsed)   return false;
  Ballistica chain=new Ballistica(pos,target,Ballistica.PROJECTILE);
  if (chain.collisionPos != enemy.pos || Level.pit[chain.path.get(1)])   return false;
 else {
    int newPos=-1;
    for (    int i : chain.subPath(1,chain.dist)) {
      if (!Level.solid[i] && Actor.findChar(i) == null) {
        newPos=i;
        break;
      }
    }
    if (newPos == -1) {
      return false;
    }
 else {
      final int newPosFinal=newPos;
      yell("String_Node_Str");
      sprite.parent.add(new Chains(pos,enemy.pos,new Callback(){
        public void call(){
          Actor.addDelayed(new Pushing(enemy,enemy.pos,newPosFinal),-1);
          enemy.pos=newPosFinal;
          Dungeon.level.press(newPosFinal,enemy);
          Cripple.prolong(enemy,Cripple.class,4f);
          if (enemy == Dungeon.hero) {
            Dungeon.hero.interrupt();
            Dungeon.observe();
          }
          next();
        }
      }
));
    }
  }
  chainsUsed=true;
  return true;
}
Program: 164253
Project: 164253
Buggy source:
@Override protected boolean act(){
  Dungeon.level.updateFieldOfView(this);
  if (state == HUNTING && Level.fieldOfView[enemy.pos] && Level.distance(pos,enemy.pos) < 5 && !Level.adjacent(pos,enemy.pos) && Random.Int(3) == 0 && chain(enemy.pos)) {
    return false;
  }
 else {
    return super.act();
  }
}

Fixed version (ground truth):
@Override protected boolean act(){
  Dungeon.level.updateFieldOfView(this);
  if (state == HUNTING && enemy != null && Level.fieldOfView[enemy.pos] && Level.distance(pos,enemy.pos) < 5 && !Level.adjacent(pos,enemy.pos) && Random.Int(3) == 0 && chain(enemy.pos)) {
    return false;
  }
 else {
    return super.act();
  }
}
Program: 164254
Project: 164254
Buggy source:
public static void restoreFromBundle(Bundle bundle){
  Bundle node=bundle.getBundle(NODE);
  if (!node.isNull() && (spawned=node.getBoolean(SPAWNED))) {
    if (bundle.contains(TYPE)) {
      type=node.getInt(TYPE);
    }
 else {
      type=node.getBoolean("String_Node_Str") ? 1 : 3;
    }
    given=node.getBoolean(GIVEN);
    wand1=(Wand)node.get(WAND1);
    wand2=(Wand)node.get(WAND2);
    if (type == 2) {
      CeremonialCandle.ritualPos=bundle.getInt(RITUALPOS);
    }
  }
 else {
    reset();
  }
}

Fixed version (ground truth):
public static void restoreFromBundle(Bundle bundle){
  Bundle node=bundle.getBundle(NODE);
  if (!node.isNull() && (spawned=node.getBoolean(SPAWNED))) {
    if (node.contains(TYPE)) {
      type=node.getInt(TYPE);
    }
 else {
      type=node.getBoolean("String_Node_Str") ? 1 : 3;
    }
    given=node.getBoolean(GIVEN);
    wand1=(Wand)node.get(WAND1);
    wand2=(Wand)node.get(WAND2);
    if (type == 2) {
      CeremonialCandle.ritualPos=node.getInt(RITUALPOS);
    }
  }
 else {
    reset();
  }
}
Program: 164255
Project: 164255
Buggy source:
public static void paint(Level level,Room room){
  for (  Room.Door door : room.connected.values()) {
    door.set(Room.Door.Type.REGULAR);
  }
  fill(level,room,Terrain.WALL);
  fill(level,room,1,Terrain.EMPTY);
  RitualMarker vis=new RitualMarker();
  Point c=room.center();
  vis.pos(c.x - 1,c.y - 1);
  level.customTiles.add(vis);
  level.addItemToSpawn(new CeremonialCandle());
  level.addItemToSpawn(new CeremonialCandle());
  level.addItemToSpawn(new CeremonialCandle());
  level.addItemToSpawn(new CeremonialCandle());
  CeremonialCandle.ritualPos=c.x + (Level.WIDTH * c.y);
}

Fixed version (ground truth):
public static void paint(Level level,Room room){
  for (  Room.Door door : room.connected.values()) {
    door.set(Room.Door.Type.REGULAR);
  }
  fill(level,room,Terrain.WALL);
  fill(level,room,1,Terrain.EMPTY);
  RitualMarker vis=new RitualMarker();
  Point c=room.center();
  vis.pos(c.x - 1,c.y - 1);
  level.customTiles.add(vis);
  fill(level,c.x - 1,c.y - 1,3,3,Terrain.EMPTY_DECO);
  level.addItemToSpawn(new CeremonialCandle());
  level.addItemToSpawn(new CeremonialCandle());
  level.addItemToSpawn(new CeremonialCandle());
  level.addItemToSpawn(new CeremonialCandle());
  CeremonialCandle.ritualPos=c.x + (Level.WIDTH * c.y);
}
Program: 164256
Project: 164256
Buggy source:
public static boolean spawn(PrisonLevel level,Room room,Collection<Room> rooms){
  if (!spawned && Dungeon.depth > 6 && Random.Int(10 - Dungeon.depth) == 0 || type != 0) {
    if (type == 0)     type=Random.Int(Dungeon.isChallenged(Challenges.NO_HERBALISM) ? 2 : 3) + 1;
    if (setRoom(rooms)) {
      Wandmaker npc=new Wandmaker();
      do {
        npc.pos=room.random();
      }
 while (level.map[npc.pos] == Terrain.ENTRANCE || level.map[npc.pos] == Terrain.SIGN);
      level.mobs.add(npc);
      spawned=true;
      given=false;
      wand1=(Wand)Generator.random(Generator.Category.WAND);
      wand1.upgrade();
      do {
        wand2=(Wand)Generator.random(Generator.Category.WAND);
      }
 while (wand2.getClass().equals(wand1.getClass()));
      wand2.upgrade();
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
public static boolean spawn(PrisonLevel level,Room room,Collection<Room> rooms){
  if (!spawned && Dungeon.depth > 6 && Random.Int(10 - Dungeon.depth) == 0 || type != 0) {
    if (type == 0)     type=Random.Int(Dungeon.isChallenged(Challenges.NO_HERBALISM) ? 2 : 3) + 1;
    if (setRoom(rooms)) {
      Wandmaker npc=new Wandmaker();
      do {
        npc.pos=room.random();
      }
 while (level.map[npc.pos] == Terrain.ENTRANCE || level.map[npc.pos] == Terrain.SIGN);
      level.mobs.add(npc);
      spawned=true;
      given=false;
      wand1=(Wand)Generator.random(Generator.Category.WAND);
      wand1.upgrade();
      do {
        wand2=(Wand)Generator.random(Generator.Category.WAND);
      }
 while (wand2.getClass().equals(wand1.getClass()));
      wand2.upgrade();
      return true;
    }
 else {
      return false;
    }
  }
 else {
    return true;
  }
}
Program: 164257
Project: 164257
Buggy source:
@Override protected void updateMatrix(){
  float sx=scroll.x + shakeX;
  float sy=scroll.y + shakeY;
  matrix[0]=+zoom * invW2;
  matrix[5]=-zoom * invH2;
  matrix[12]=-1 + x * invW2 - sx * matrix[0];
  matrix[13]=+1 - y * invH2 - sy * matrix[5];
}

Fixed version (ground truth):
@Override protected void updateMatrix(){
  float sx=Math.round(scroll.x + shakeX);
  float sy=Math.round(scroll.y + shakeY);
  matrix[0]=+zoom * invW2;
  matrix[5]=-zoom * invH2;
  matrix[12]=-1 + x * invW2 - sx * matrix[0];
  matrix[13]=+1 - y * invH2 - sy * matrix[5];
}
Program: 164258
Project: 164258
Buggy source:
@Override public int randomRespawnCell(){
  int cell=entrance + NEIGHBOURS8[Random.Int(8)];
  while (!passable[cell]) {
    cell=entrance + NEIGHBOURS8[Random.Int(8)];
  }
  return cell;
}

Fixed version (ground truth):
@Override public int randomRespawnCell(){
  if (entrance == -1)   return entrance;
  int cell=entrance + NEIGHBOURS8[Random.Int(8)];
  while (!passable[cell]) {
    cell=entrance + NEIGHBOURS8[Random.Int(8)];
  }
  return cell;
}
Program: 164259
Project: 164259
Buggy source:
public static void init(){
  version=Game.versionCode;
  challenges=ShatteredPixelDungeon.challenges();
  Generator.initArtifacts();
  Actor.clear();
  Actor.resetNextID();
  PathFinder.setMapSize(Level.WIDTH,Level.HEIGHT);
  Scroll.initLabels();
  Potion.initColors();
  Ring.initGems();
  Statistics.reset();
  Journal.reset();
  quickslot.reset();
  QuickSlotButton.reset();
  depth=0;
  gold=0;
  droppedItems=new SparseArray<ArrayList<Item>>();
  for (  limitedDrops a : limitedDrops.values())   a.count=0;
  transmutation=Random.IntRange(6,14);
  chapters=new HashSet<Integer>();
  Ghost.Quest.reset();
  Wandmaker.Quest.reset();
  Blacksmith.Quest.reset();
  Imp.Quest.reset();
  Room.shuffleTypes();
  hero=new Hero();
  hero.live();
  Badges.reset();
  StartScene.curClass.initHero(hero);
}

Fixed version (ground truth):
public static void init(){
  version=Game.versionCode;
  challenges=ShatteredPixelDungeon.challenges();
  Actor.clear();
  Actor.resetNextID();
  PathFinder.setMapSize(Level.WIDTH,Level.HEIGHT);
  Scroll.initLabels();
  Potion.initColors();
  Ring.initGems();
  Statistics.reset();
  Journal.reset();
  quickslot.reset();
  QuickSlotButton.reset();
  depth=0;
  gold=0;
  droppedItems=new SparseArray<ArrayList<Item>>();
  for (  limitedDrops a : limitedDrops.values())   a.count=0;
  transmutation=Random.IntRange(6,14);
  chapters=new HashSet<Integer>();
  Ghost.Quest.reset();
  Wandmaker.Quest.reset();
  Blacksmith.Quest.reset();
  Imp.Quest.reset();
  Room.shuffleTypes();
  Generator.initArtifacts();
  hero=new Hero();
  hero.live();
  Badges.reset();
  StartScene.curClass.initHero(hero);
}
Program: 164260
Project: 164260
Buggy source:
public static void initArtifacts(){
  Category.ARTIFACT.probs=INITIAL_ARTIFACT_PROBS;
  if (Ghost.Quest.processed)   Category.ARTIFACT.probs[10]=1;
  spawnedArtifacts=new ArrayList<String>();
}

Fixed version (ground truth):
public static void initArtifacts(){
  Category.ARTIFACT.probs=INITIAL_ARTIFACT_PROBS.clone();
  if (Ghost.Quest.completed())   Category.ARTIFACT.probs[10]=1;
  spawnedArtifacts=new ArrayList<String>();
}
Program: 164261
Project: 164261
Buggy source:
@Override protected void doRead(){
  new Flare(5,32).color(0xFF0000,true).show(curUser.sprite,2f);
  Sample.INSTANCE.play(Assets.SND_READ);
  Invisibility.dispel();
  int count=0;
  Mob affected=null;
  for (  Mob mob : Dungeon.level.mobs.toArray(new Mob[0])) {
    if (Level.fieldOfView[mob.pos]) {
      Buff.affect(mob,Terror.class,Terror.DURATION).object=curUser.id();
      count++;
      affected=mob;
    }
  }
switch (count) {
case 0:
    GLog.i("String_Node_Str");
  break;
case 1:
GLog.i("String_Node_Str" + affected.name + "String_Node_Str");
break;
default :
GLog.i("String_Node_Str");
}
setKnown();
curUser.spendAndNext(TIME_TO_READ);
}

Fixed version (ground truth):
@Override protected void doRead(){
  new Flare(5,32).color(0xFF0000,true).show(curUser.sprite,2f);
  Sample.INSTANCE.play(Assets.SND_READ);
  Invisibility.dispel();
  int count=0;
  Mob affected=null;
  for (  Mob mob : Dungeon.level.mobs.toArray(new Mob[0])) {
    if (Level.fieldOfView[mob.pos]) {
      Buff.affect(mob,Terror.class,Terror.DURATION).object=curUser.id();
      if (mob.buff(Terror.class) != null) {
        count++;
        affected=mob;
      }
    }
  }
switch (count) {
case 0:
    GLog.i("String_Node_Str");
  break;
case 1:
GLog.i("String_Node_Str" + affected.name + "String_Node_Str");
break;
default :
GLog.i("String_Node_Str");
}
setKnown();
curUser.spendAndNext(TIME_TO_READ);
}
Program: 164262
Project: 164262
Buggy source:
@Override public void trigger(){
  if (Dungeon.visible[pos]) {
    Sample.INSTANCE.play(Assets.SND_TRAP);
  }
  activate();
}

Fixed version (ground truth):
@Override public void trigger(){
  if (Dungeon.visible[pos]) {
    Sample.INSTANCE.play(Assets.SND_TRAP);
  }
  reveal();
  activate();
}
Program: 164263
Project: 164263
Buggy source:
public void trigger(){
  if (active) {
    if (Dungeon.visible[pos]) {
      Sample.INSTANCE.play(Assets.SND_TRAP);
    }
    disarm();
    activate();
  }
}

Fixed version (ground truth):
public void trigger(){
  if (active) {
    if (Dungeon.visible[pos]) {
      Sample.INSTANCE.play(Assets.SND_TRAP);
    }
    disarm();
    reveal();
    activate();
  }
}
Program: 164264
Project: 164264
Buggy source:
protected void disarm(){
  Dungeon.level.disarmTrap(pos);
  active=false;
  if (sprite != null) {
    sprite.visible=true;
    sprite.reset(this);
  }
}

Fixed version (ground truth):
protected void disarm(){
  Dungeon.level.disarmTrap(pos);
  active=false;
  if (sprite != null) {
    sprite.reset(this);
  }
}
Program: 164265
Project: 164265
Buggy source:
@Override public void activate(){
  InterlevelScene.returnDepth=Dungeon.depth;
  for (  Item item : Dungeon.hero.belongings.backpack.items) {
    if (item instanceof Key && ((Key)item).depth == Dungeon.depth) {
      item.detachAll(Dungeon.hero.belongings.backpack);
    }
  }
  Dungeon.depth--;
  Level level=Dungeon.newLevel();
  Dungeon.switchLevel(level,level.entrance);
  InterlevelScene.returnPos=level.entrance;
  InterlevelScene.mode=InterlevelScene.Mode.RETURN;
  Game.switchScene(InterlevelScene.class);
}

Fixed version (ground truth):
@Override public void activate(){
  InterlevelScene.returnDepth=Dungeon.depth;
  for (  Item item : Dungeon.hero.belongings.backpack.items) {
    if (item instanceof Key && ((Key)item).depth == Dungeon.depth) {
      item.detachAll(Dungeon.hero.belongings.backpack);
    }
  }
  InterlevelScene.mode=InterlevelScene.Mode.RESET;
  Game.switchScene(InterlevelScene.class);
}
Program: 164266
Project: 164266
Buggy source:
@Override public void create(){
  super.create();
  String text="String_Node_Str";
switch (mode) {
case DESCEND:
    text=TXT_DESCENDING;
  break;
case ASCEND:
text=TXT_ASCENDING;
break;
case CONTINUE:
text=TXT_LOADING;
break;
case RESURRECT:
text=TXT_RESURRECTING;
break;
case RETURN:
text=TXT_RETURNING;
break;
case FALL:
text=TXT_FALLING;
break;
}
message=PixelScene.createText(text,9);
message.measure();
message.x=(Camera.main.width - message.width()) / 2;
message.y=(Camera.main.height - message.height()) / 2;
add(message);
phase=Phase.FADE_IN;
timeLeft=TIME_TO_FADE;
thread=new Thread(){
@Override public void run(){
try {
Generator.reset();
switch (mode) {
case DESCEND:
descend();
break;
case ASCEND:
ascend();
break;
case CONTINUE:
restore();
break;
case RESURRECT:
resurrect();
break;
case RETURN:
returnTo();
break;
case FALL:
fall();
break;
}
if ((Dungeon.depth % 5) == 0) {
Sample.INSTANCE.load(Assets.SND_BOSS);
}
}
 catch (Exception e) {
error=e;
}
if (phase == Phase.STATIC && error == null) {
phase=Phase.FADE_OUT;
timeLeft=TIME_TO_FADE;
}
}
}
;
thread.start();
}

Fixed version (ground truth):
@Override public void create(){
  super.create();
  String text="String_Node_Str";
switch (mode) {
case DESCEND:
    text=TXT_DESCENDING;
  break;
case ASCEND:
text=TXT_ASCENDING;
break;
case CONTINUE:
text=TXT_LOADING;
break;
case RESURRECT:
text=TXT_RESURRECTING;
break;
case RETURN:
text=TXT_RETURNING;
break;
case FALL:
text=TXT_FALLING;
break;
case RESET:
text=TXT_RESETTING;
break;
}
message=PixelScene.createText(text,9);
message.measure();
message.x=(Camera.main.width - message.width()) / 2;
message.y=(Camera.main.height - message.height()) / 2;
add(message);
phase=Phase.FADE_IN;
timeLeft=TIME_TO_FADE;
thread=new Thread(){
@Override public void run(){
try {
Generator.reset();
switch (mode) {
case DESCEND:
descend();
break;
case ASCEND:
ascend();
break;
case CONTINUE:
restore();
break;
case RESURRECT:
resurrect();
break;
case RETURN:
returnTo();
break;
case FALL:
fall();
break;
case RESET:
reset();
break;
}
if ((Dungeon.depth % 5) == 0) {
Sample.INSTANCE.load(Assets.SND_BOSS);
}
}
 catch (Exception e) {
error=e;
}
if (phase == Phase.STATIC && error == null) {
phase=Phase.FADE_OUT;
timeLeft=TIME_TO_FADE;
}
}
}
;
thread.start();
}
Program: 164267
Project: 164267
Buggy source:
@Override public void run(){
  try {
    Generator.reset();
switch (mode) {
case DESCEND:
      descend();
    break;
case ASCEND:
  ascend();
break;
case CONTINUE:
restore();
break;
case RESURRECT:
resurrect();
break;
case RETURN:
returnTo();
break;
case FALL:
fall();
break;
}
if ((Dungeon.depth % 5) == 0) {
Sample.INSTANCE.load(Assets.SND_BOSS);
}
}
 catch (Exception e) {
error=e;
}
if (phase == Phase.STATIC && error == null) {
phase=Phase.FADE_OUT;
timeLeft=TIME_TO_FADE;
}
}

Fixed version (ground truth):
@Override public void run(){
  try {
    Generator.reset();
switch (mode) {
case DESCEND:
      descend();
    break;
case ASCEND:
  ascend();
break;
case CONTINUE:
restore();
break;
case RESURRECT:
resurrect();
break;
case RETURN:
returnTo();
break;
case FALL:
fall();
break;
case RESET:
reset();
break;
}
if ((Dungeon.depth % 5) == 0) {
Sample.INSTANCE.load(Assets.SND_BOSS);
}
}
 catch (Exception e) {
error=e;
}
if (phase == Phase.STATIC && error == null) {
phase=Phase.FADE_OUT;
timeLeft=TIME_TO_FADE;
}
}
Program: 164268
Project: 164268
Buggy source:
@Override public void onSelect(Integer target){
  if (target == null)   return;
  Invisibility.dispel();
  charge-=Dungeon.depth > 20 ? 2 : 1;
  updateQuickslot();
  if (Actor.findChar(target) == curUser) {
    ScrollOfTeleportation.teleportHero(curUser);
    Sample.INSTANCE.play(Assets.SND_TELEPORT);
    curUser.spendAndNext(1f);
  }
 else {
    final Ballistica bolt=new Ballistica(curUser.pos,target,Ballistica.MAGIC_BOLT);
    final Char ch=Actor.findChar(bolt.collisionPos);
    if (ch == curUser) {
      ScrollOfTeleportation.teleportHero(curUser);
      Sample.INSTANCE.play(Assets.SND_TELEPORT);
      curUser.spendAndNext(1f);
    }
 else {
      Sample.INSTANCE.play(Assets.SND_ZAP);
      curUser.sprite.zap(bolt.collisionPos);
      curUser.busy();
      MagicMissile.force(curUser.sprite.parent,bolt.sourcePos,bolt.collisionPos,new Callback(){
        @Override public void call(){
          if (ch != null) {
            int count=10;
            int pos;
            do {
              pos=Dungeon.level.randomRespawnCell();
              if (count-- <= 0) {
                break;
              }
            }
 while (pos == -1);
            if (pos == -1) {
              GLog.w(ScrollOfTeleportation.TXT_NO_TELEPORT);
            }
 else {
              ch.pos=pos;
              ch.sprite.place(ch.pos);
              ch.sprite.visible=Dungeon.visible[pos];
            }
          }
          curUser.spendAndNext(1f);
        }
      }
);
    }
  }
}

Fixed version (ground truth):
@Override public void onSelect(Integer target){
  if (target == null)   return;
  Invisibility.dispel();
  charge-=Dungeon.depth > 20 ? 2 : 1;
  updateQuickslot();
  if (Actor.findChar(target) == curUser) {
    ScrollOfTeleportation.teleportHero(curUser);
    curUser.spendAndNext(1f);
  }
 else {
    final Ballistica bolt=new Ballistica(curUser.pos,target,Ballistica.MAGIC_BOLT);
    final Char ch=Actor.findChar(bolt.collisionPos);
    if (ch == curUser) {
      ScrollOfTeleportation.teleportHero(curUser);
      curUser.spendAndNext(1f);
    }
 else {
      Sample.INSTANCE.play(Assets.SND_ZAP);
      curUser.sprite.zap(bolt.collisionPos);
      curUser.busy();
      MagicMissile.force(curUser.sprite.parent,bolt.sourcePos,bolt.collisionPos,new Callback(){
        @Override public void call(){
          if (ch != null) {
            int count=10;
            int pos;
            do {
              pos=Dungeon.level.randomRespawnCell();
              if (count-- <= 0) {
                break;
              }
            }
 while (pos == -1);
            if (pos == -1 || Dungeon.bossLevel()) {
              GLog.w(ScrollOfTeleportation.TXT_NO_TELEPORT);
            }
 else {
              ch.pos=pos;
              ch.sprite.place(ch.pos);
              ch.sprite.visible=Dungeon.visible[pos];
            }
          }
          curUser.spendAndNext(1f);
        }
      }
);
    }
  }
}
Program: 164269
Project: 164269
Buggy source:
@Override public void call(){
  if (ch != null) {
    int count=10;
    int pos;
    do {
      pos=Dungeon.level.randomRespawnCell();
      if (count-- <= 0) {
        break;
      }
    }
 while (pos == -1);
    if (pos == -1) {
      GLog.w(ScrollOfTeleportation.TXT_NO_TELEPORT);
    }
 else {
      ch.pos=pos;
      ch.sprite.place(ch.pos);
      ch.sprite.visible=Dungeon.visible[pos];
    }
  }
  curUser.spendAndNext(1f);
}

Fixed version (ground truth):
@Override public void call(){
  if (ch != null) {
    int count=10;
    int pos;
    do {
      pos=Dungeon.level.randomRespawnCell();
      if (count-- <= 0) {
        break;
      }
    }
 while (pos == -1);
    if (pos == -1 || Dungeon.bossLevel()) {
      GLog.w(ScrollOfTeleportation.TXT_NO_TELEPORT);
    }
 else {
      ch.pos=pos;
      ch.sprite.place(ch.pos);
      ch.sprite.visible=Dungeon.visible[pos];
    }
  }
  curUser.spendAndNext(1f);
}
Program: 164270
Project: 164270
Buggy source:
public static void teleportHero(Hero hero){
  int count=10;
  int pos;
  do {
    pos=Dungeon.level.randomRespawnCell();
    if (count-- <= 0) {
      break;
    }
  }
 while (pos == -1);
  if (pos == -1) {
    GLog.w(TXT_NO_TELEPORT);
  }
 else {
    appear(hero,pos);
    Dungeon.level.press(pos,hero);
    Dungeon.observe();
    GLog.i(TXT_TELEPORTED);
  }
}

Fixed version (ground truth):
public static void teleportHero(Hero hero){
  int count=10;
  int pos;
  do {
    pos=Dungeon.level.randomRespawnCell();
    if (count-- <= 0) {
      break;
    }
  }
 while (pos == -1);
  if (pos == -1 || Dungeon.bossLevel()) {
    GLog.w(TXT_NO_TELEPORT);
  }
 else {
    appear(hero,pos);
    Dungeon.level.press(pos,hero);
    Dungeon.observe();
    GLog.i(TXT_TELEPORTED);
  }
}
Program: 164272
Project: 164272
Buggy source:
@Override public void activate(){
  CellEmitter.get(pos).start(Speck.factory(Speck.LIGHT),0.2f,3);
  Sample.INSTANCE.play(Assets.SND_TELEPORT);
  Char ch=Actor.findChar(pos);
  if (ch instanceof Hero) {
    ScrollOfTeleportation.teleportHero((Hero)ch);
  }
 else   if (ch != null) {
    int count=10;
    int pos;
    do {
      pos=Dungeon.level.randomRespawnCell();
      if (count-- <= 0) {
        break;
      }
    }
 while (pos == -1);
    if (pos == -1) {
      GLog.w(ScrollOfTeleportation.TXT_NO_TELEPORT);
    }
 else {
      ch.pos=pos;
      ch.sprite.place(ch.pos);
      ch.sprite.visible=Dungeon.visible[pos];
    }
  }
  Heap heap=Dungeon.level.heaps.get(pos);
  if (heap != null) {
    int cell=Dungeon.level.randomRespawnCell();
    Item item=heap.pickUp();
    if (cell != -1) {
      Dungeon.level.drop(item,cell);
    }
  }
}

Fixed version (ground truth):
@Override public void activate(){
  CellEmitter.get(pos).start(Speck.factory(Speck.LIGHT),0.2f,3);
  Sample.INSTANCE.play(Assets.SND_TELEPORT);
  Char ch=Actor.findChar(pos);
  if (ch instanceof Hero) {
    ScrollOfTeleportation.teleportHero((Hero)ch);
  }
 else   if (ch != null) {
    int count=10;
    int pos;
    do {
      pos=Dungeon.level.randomRespawnCell();
      if (count-- <= 0) {
        break;
      }
    }
 while (pos == -1);
    if (pos == -1 || Dungeon.bossLevel()) {
      GLog.w(ScrollOfTeleportation.TXT_NO_TELEPORT);
    }
 else {
      ch.pos=pos;
      ch.sprite.place(ch.pos);
      ch.sprite.visible=Dungeon.visible[pos];
    }
  }
  Heap heap=Dungeon.level.heaps.get(pos);
  if (heap != null) {
    int cell=Dungeon.level.randomRespawnCell();
    Item item=heap.pickUp();
    if (cell != -1) {
      Dungeon.level.drop(item,cell);
    }
  }
}
Program: 164273
Project: 164273
Buggy source:
@Override public void activate(){
  Char ch=Actor.findChar(pos);
  if (ch instanceof Hero) {
    ScrollOfTeleportation.teleportHero((Hero)ch);
    ((Hero)ch).curAction=null;
  }
 else   if (ch instanceof Mob) {
    int count=10;
    int newPos;
    do {
      newPos=Dungeon.level.randomRespawnCell();
      if (count-- <= 0) {
        break;
      }
    }
 while (newPos == -1);
    if (newPos != -1) {
      ch.pos=newPos;
      ch.sprite.place(ch.pos);
      ch.sprite.visible=Dungeon.visible[pos];
    }
  }
  if (Dungeon.visible[pos]) {
    CellEmitter.get(pos).start(Speck.factory(Speck.LIGHT),0.2f,3);
  }
}

Fixed version (ground truth):
@Override public void activate(){
  Char ch=Actor.findChar(pos);
  if (ch instanceof Hero) {
    ScrollOfTeleportation.teleportHero((Hero)ch);
    ((Hero)ch).curAction=null;
  }
 else   if (ch instanceof Mob) {
    int count=10;
    int newPos;
    do {
      newPos=Dungeon.level.randomRespawnCell();
      if (count-- <= 0) {
        break;
      }
    }
 while (newPos == -1);
    if (newPos != -1 && !Dungeon.bossLevel()) {
      ch.pos=newPos;
      ch.sprite.place(ch.pos);
      ch.sprite.visible=Dungeon.visible[pos];
    }
  }
  if (Dungeon.visible[pos]) {
    CellEmitter.get(pos).start(Speck.factory(Speck.LIGHT),0.2f,3);
  }
}
Program: 164274
Project: 164274
Buggy source:
private boolean getCloser(final int target){
  if (rooted) {
    Camera.main.shake(1,1f);
    return false;
  }
  int step=-1;
  if (Level.adjacent(pos,target)) {
    if (Actor.findChar(target) == null) {
      if (Level.pit[target] && !flying && !Chasm.jumpConfirmed) {
        if (!Level.solid[target]) {
          Chasm.heroJump(this);
          interrupt();
        }
        return false;
      }
      if (Level.passable[target] || Level.avoid[target]) {
        step=target;
      }
    }
  }
 else {
    int len=Level.LENGTH;
    boolean[] p=Level.passable;
    boolean[] v=Dungeon.level.visited;
    boolean[] m=Dungeon.level.mapped;
    boolean[] passable=new boolean[len];
    for (int i=0; i < len; i++) {
      passable[i]=p[i] && (v[i] || m[i]);
    }
    step=Dungeon.findPath(this,pos,target,passable,Level.fieldOfView);
  }
  if (step != -1) {
    sprite.move(pos,step);
    move(step);
    spend(1 / speed());
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
private boolean getCloser(final int target){
  if (rooted) {
    Camera.main.shake(1,1f);
    return false;
  }
  int step=-1;
  if (Level.adjacent(pos,target)) {
    if (Actor.findChar(target) == null) {
      if (Level.pit[target] && !flying && !Level.solid[target]) {
        if (!Chasm.jumpConfirmed) {
          Chasm.heroJump(this);
          interrupt();
        }
 else {
          Chasm.heroFall(target);
        }
        return false;
      }
      if (Level.passable[target] || Level.avoid[target]) {
        step=target;
      }
    }
  }
 else {
    int len=Level.LENGTH;
    boolean[] p=Level.passable;
    boolean[] v=Dungeon.level.visited;
    boolean[] m=Dungeon.level.mapped;
    boolean[] passable=new boolean[len];
    for (int i=0; i < len; i++) {
      passable[i]=p[i] && (v[i] || m[i]);
    }
    step=Dungeon.findPath(this,pos,target,passable,Level.fieldOfView);
  }
  if (step != -1) {
    sprite.move(pos,step);
    move(step);
    spend(1 / speed());
    return true;
  }
 else {
    return false;
  }
}
Program: 164275
Project: 164275
Buggy source:
public void move(int step){
  if (Level.adjacent(step,pos) && buff(Vertigo.class) != null) {
    step=pos + Level.NEIGHBOURS8[Random.Int(8)];
    if (!(Level.passable[step] || Level.avoid[step]) || Actor.findChar(step) != null)     return;
  }
  if (Dungeon.level.map[pos] == Terrain.OPEN_DOOR) {
    Door.leave(pos);
  }
  pos=step;
  if (flying && Dungeon.level.map[pos] == Terrain.DOOR) {
    Door.enter(pos);
  }
  if (this != Dungeon.hero) {
    sprite.visible=Dungeon.visible[pos];
  }
}

Fixed version (ground truth):
public void move(int step){
  if (Level.adjacent(step,pos) && buff(Vertigo.class) != null) {
    sprite.interruptMotion();
    int newPos=pos + Level.NEIGHBOURS8[Random.Int(8)];
    if (!(Level.passable[newPos] || Level.avoid[newPos]) || Actor.findChar(newPos) != null)     return;
 else {
      sprite.move(pos,newPos);
      step=newPos;
    }
  }
  if (Dungeon.level.map[pos] == Terrain.OPEN_DOOR) {
    Door.leave(pos);
  }
  pos=step;
  if (flying && Dungeon.level.map[pos] == Terrain.DOOR) {
    Door.enter(pos);
  }
  if (this != Dungeon.hero) {
    sprite.visible=Dungeon.visible[pos];
  }
}
Program: 164278
Project: 164278
Buggy source:
@Override protected void disarm(){
  super.disarm();
  if (!(Dungeon.level.map[pos - Level.WIDTH] == Terrain.WALL && Dungeon.level.map[pos + Level.WIDTH] == Terrain.WALL) && !(Dungeon.level.map[pos - 1] == Terrain.WALL && Dungeon.level.map[pos + 1] == Terrain.WALL)) {
    int c=Dungeon.level.map[pos - Level.WIDTH];
    if (c == Terrain.WALL || c == Terrain.WALL_DECO) {
      Level.set(pos,Terrain.CHASM_WALL);
    }
 else {
      Level.set(pos,Terrain.CHASM_FLOOR);
    }
    sprite.parent.add(new WindParticle.Wind(pos));
    GameScene.updateMap(pos);
  }
}

Fixed version (ground truth):
@Override protected void disarm(){
  super.disarm();
  if (!(Dungeon.level.map[pos - Level.WIDTH] == Terrain.WALL && Dungeon.level.map[pos + Level.WIDTH] == Terrain.WALL) && !(Dungeon.level.map[pos - 1] == Terrain.WALL && Dungeon.level.map[pos + 1] == Terrain.WALL)) {
    int c=Dungeon.level.map[pos - Level.WIDTH];
    if (c == Terrain.WALL || c == Terrain.WALL_DECO) {
      Level.set(pos,Terrain.CHASM_WALL);
    }
 else {
      Level.set(pos,Terrain.CHASM_FLOOR);
    }
    sprite.parent.add(new WindParticle.Wind(pos));
    sprite.killAndErase();
    GameScene.updateMap(pos);
  }
}
Program: 164279
Project: 164279
Buggy source:
public void remove(State state){
switch (state) {
case BURNING:
    if (burning != null) {
      burning.on=false;
      burning=null;
    }
  break;
case LEVITATING:
if (levitation != null) {
  levitation.on=false;
  levitation=null;
}
break;
case INVISIBLE:
alpha(1f);
break;
case PARALYSED:
paused=false;
break;
case FROZEN:
if (iceBlock != null) {
iceBlock.melt();
iceBlock=null;
}
paused=false;
break;
case ILLUMINATED:
if (halo != null) {
halo.putOut();
}
break;
case CHILLED:
if (chilled != null) {
chilled.on=false;
chilled=null;
}
case DARKENED:
if (darkBlock != null) {
darkBlock.lighten();
darkBlock=null;
}
break;
}
}

Fixed version (ground truth):
public void remove(State state){
switch (state) {
case BURNING:
    if (burning != null) {
      burning.on=false;
      burning=null;
    }
  break;
case LEVITATING:
if (levitation != null) {
  levitation.on=false;
  levitation=null;
}
break;
case INVISIBLE:
alpha(1f);
break;
case PARALYSED:
paused=false;
break;
case FROZEN:
if (iceBlock != null) {
iceBlock.melt();
iceBlock=null;
}
paused=false;
break;
case ILLUMINATED:
if (halo != null) {
halo.putOut();
}
break;
case CHILLED:
if (chilled != null) {
chilled.on=false;
chilled=null;
}
break;
case DARKENED:
if (darkBlock != null) {
darkBlock.lighten();
darkBlock=null;
}
break;
}
}
Program: 164280
Project: 164280
Buggy source:
public static void layoutTags(){
  float tagLeft=ShatteredPixelDungeon.flipTags() ? 0 : uiCamera.width - scene.attack.width();
  if (ShatteredPixelDungeon.flipTags()) {
    scene.log.setRect(scene.attack.width(),scene.toolbar.top(),uiCamera.width - scene.attack.width(),0);
  }
 else {
    scene.log.setRect(0,scene.toolbar.top(),scene.attack.left(),0);
  }
  float pos=scene.toolbar.top();
  if (scene.tagAttack) {
    scene.attack.setPos(tagLeft,pos - scene.attack.height());
    scene.attack.flip(tagLeft == 0);
    pos=scene.attack.top();
  }
  if (scene.tagLoot) {
    scene.loot.setPos(tagLeft,pos - scene.loot.height());
    scene.loot.flip(tagLeft == 0);
    pos=scene.loot.top();
  }
  if (scene.tagResume) {
    scene.resume.setPos(tagLeft,pos - scene.resume.height());
    scene.resume.flip(tagLeft == 0);
  }
}

Fixed version (ground truth):
public static void layoutTags(){
  float tagLeft=ShatteredPixelDungeon.flipTags() ? 0 : uiCamera.width - scene.attack.width();
  if (ShatteredPixelDungeon.flipTags()) {
    scene.log.setRect(scene.attack.width(),scene.toolbar.top(),uiCamera.width - scene.attack.width(),0);
  }
 else {
    scene.log.setRect(0,scene.toolbar.top(),uiCamera.width - scene.attack.width(),0);
  }
  float pos=scene.toolbar.top();
  if (scene.tagAttack) {
    scene.attack.setPos(tagLeft,pos - scene.attack.height());
    scene.attack.flip(tagLeft == 0);
    pos=scene.attack.top();
  }
  if (scene.tagLoot) {
    scene.loot.setPos(tagLeft,pos - scene.loot.height());
    scene.loot.flip(tagLeft == 0);
    pos=scene.loot.top();
  }
  if (scene.tagResume) {
    scene.resume.setPos(tagLeft,pos - scene.resume.height());
    scene.resume.flip(tagLeft == 0);
  }
}
Program: 164281
Project: 164281
Buggy source:
public static void layoutTags(){
  float tagLeft=ShatteredPixelDungeon.flipTags() ? 0 : uiCamera.width - scene.attack.width();
  if (ShatteredPixelDungeon.flipTags()) {
    scene.log.setRect(scene.attack.width(),scene.toolbar.top(),uiCamera.width - scene.attack.width(),0);
  }
 else {
    scene.log.setRect(0,scene.toolbar.top(),uiCamera.width - scene.attack.width(),0);
  }
  float pos=scene.toolbar.top();
  if (scene.tagAttack) {
    scene.attack.setPos(tagLeft,pos - scene.attack.height());
    scene.attack.flip(tagLeft == 0);
    pos=scene.attack.top();
  }
  if (scene.tagLoot) {
    scene.loot.setPos(tagLeft,pos - scene.loot.height());
    scene.loot.flip(tagLeft == 0);
    pos=scene.loot.top();
  }
  if (scene.tagResume) {
    scene.resume.setPos(tagLeft,pos - scene.resume.height());
    scene.resume.flip(tagLeft == 0);
  }
}

Fixed version (ground truth):
public static void layoutTags(){
  if (scene == null)   return;
  float tagLeft=ShatteredPixelDungeon.flipTags() ? 0 : uiCamera.width - scene.attack.width();
  if (ShatteredPixelDungeon.flipTags()) {
    scene.log.setRect(scene.attack.width(),scene.toolbar.top(),uiCamera.width - scene.attack.width(),0);
  }
 else {
    scene.log.setRect(0,scene.toolbar.top(),uiCamera.width - scene.attack.width(),0);
  }
  float pos=scene.toolbar.top();
  if (scene.tagAttack) {
    scene.attack.setPos(tagLeft,pos - scene.attack.height());
    scene.attack.flip(tagLeft == 0);
    pos=scene.attack.top();
  }
  if (scene.tagLoot) {
    scene.loot.setPos(tagLeft,pos - scene.loot.height());
    scene.loot.flip(tagLeft == 0);
    pos=scene.loot.top();
  }
  if (scene.tagResume) {
    scene.resume.setPos(tagLeft,pos - scene.resume.height());
    scene.resume.flip(tagLeft == 0);
  }
}
Program: 164283
Project: 164283
Buggy source:
public static void initArtifacts(){
  Category.ARTIFACT.probs=new float[]{0,1,0,1,0,1,1,1,1,0,0,0,1};
  spawnedArtifacts=new ArrayList<String>();
}

Fixed version (ground truth):
public static void initArtifacts(){
  Category.ARTIFACT.probs=INITIAL_ARTIFACT_PROBS;
  if (Ghost.Quest.processed)   Category.ARTIFACT.probs[10]=1;
  spawnedArtifacts=new ArrayList<String>();
}
Program: 164284
Project: 164284
Buggy source:
public OptionSlider(String title,String minTxt,String maxTxt,int minVal,int maxVal){
  super();
  this.title.text(title);
  this.title.measure();
  this.minTxt.text(minTxt);
  this.minTxt.measure();
  this.maxTxt.text(maxTxt);
  this.maxTxt.measure();
  this.minVal=minVal;
  this.maxVal=maxVal;
  if (minVal > maxVal)   throw new IllegalArgumentException();
  sliderTicks=new ColorBlock[(maxVal - minVal) + 1];
  for (int i=0; i < sliderTicks.length; i++) {
    add(sliderTicks[i]=new ColorBlock(1,11,0xFF222222));
  }
  add(sliderNode);
}

Fixed version (ground truth):
public OptionSlider(String title,String minTxt,String maxTxt,int minVal,int maxVal){
  super();
  this.title.text(title);
  this.title.measure();
  this.minTxt.text(minTxt);
  this.minTxt.measure();
  this.maxTxt.text(maxTxt);
  this.maxTxt.measure();
  this.minVal=minVal;
  this.maxVal=maxVal;
  if (minVal > maxVal) {
    active=false;
    visible=false;
  }
  sliderTicks=new ColorBlock[(maxVal - minVal) + 1];
  for (int i=0; i < sliderTicks.length; i++) {
    add(sliderTicks[i]=new ColorBlock(1,11,0xFF222222));
  }
  add(sliderNode);
}
Program: 164286
Project: 164286
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;
      }
    }
  }
  if (Dungeon.depth == 2)   for (  Room r : roomEntrance.connected.keySet()) {
    Room.Door d=roomEntrance.connected.get(r);
    map[d.x + d.y * WIDTH]=Terrain.SECRET_DOOR;
  }
  placeSign();
}

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;
      }
    }
  }
  if (Dungeon.depth == 2)   for (  Room r : roomEntrance.connected.keySet()) {
    Room.Door d=roomEntrance.connected.get(r);
    if (d.type == Room.Door.Type.REGULAR)     map[d.x + d.y * WIDTH]=Terrain.SECRET_DOOR;
  }
  placeSign();
}
Program: 164287
Project: 164287
Buggy source:
@Override public void onHit(MagesStaff staff,Char attacker,Char defender,int damage){
  int level=Math.max(0,0);
  int maxValue=damage * (level + 2) / (level + 6);
  int effValue=Math.min(Random.IntRange(0,maxValue),attacker.HT - attacker.HP);
  Buff.affect(attacker,Sungrass.Health.class).boost(effValue);
}

Fixed version (ground truth):
@Override public void onHit(MagesStaff staff,Char attacker,Char defender,int damage){
  int level=Math.max(0,staff.level);
  int maxValue=damage * (level + 2) / (level + 6);
  int effValue=Math.min(Random.IntRange(0,maxValue),attacker.HT - attacker.HP);
  Buff.affect(attacker,Sungrass.Health.class).boost(effValue);
}
Program: 164289
Project: 164289
Buggy source:
@Override public String desc(){
  return "String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ (count <= 2 ? "String_Node_Str" : "String_Node_Str" + ((count - 2) / 5f) + "String_Node_Str");
}

Fixed version (ground truth):
@Override public String desc(){
  return "String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ (count <= 2 ? "String_Node_Str" : "String_Node_Str" + ((count - 2) * 20f) + "String_Node_Str");
}
Program: 164290
Project: 164290
Buggy source:
private boolean getCloser(final int target){
  if (rooted) {
    Camera.main.shake(1,1f);
    return false;
  }
  int step=-1;
  if (Level.adjacent(pos,target)) {
    if (Actor.findChar(target) == null) {
      if (Level.pit[target] && !flying && !Chasm.jumpConfirmed) {
        if (!Level.solid[target]) {
          Chasm.heroJump(this);
          interrupt();
        }
        return false;
      }
      if (Level.passable[target] || Level.avoid[target]) {
        step=target;
      }
    }
  }
 else {
    int len=Level.LENGTH;
    boolean[] p=Level.passable;
    boolean[] v=Dungeon.level.visited;
    boolean[] m=Dungeon.level.mapped;
    boolean[] passable=new boolean[len];
    for (int i=0; i < len; i++) {
      passable[i]=p[i] && (v[i] || m[i]);
    }
    step=Dungeon.findPath(this,pos,target,passable,Level.fieldOfView);
  }
  if (step != -1) {
    int oldPos=pos;
    move(step);
    sprite.move(oldPos,pos);
    spend(1 / speed());
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
private boolean getCloser(final int target){
  if (rooted) {
    Camera.main.shake(1,1f);
    return false;
  }
  int step=-1;
  if (Level.adjacent(pos,target)) {
    if (Actor.findChar(target) == null) {
      if (Level.pit[target] && !flying && !Chasm.jumpConfirmed) {
        if (!Level.solid[target]) {
          Chasm.heroJump(this);
          interrupt();
        }
        return false;
      }
      if (Level.passable[target] || Level.avoid[target]) {
        step=target;
      }
    }
  }
 else {
    int len=Level.LENGTH;
    boolean[] p=Level.passable;
    boolean[] v=Dungeon.level.visited;
    boolean[] m=Dungeon.level.mapped;
    boolean[] passable=new boolean[len];
    for (int i=0; i < len; i++) {
      passable[i]=p[i] && (v[i] || m[i]);
    }
    step=Dungeon.findPath(this,pos,target,passable,Level.fieldOfView);
  }
  if (step != -1) {
    sprite.move(pos,step);
    move(step);
    spend(1 / speed());
    return true;
  }
 else {
    return false;
  }
}
Program: 164291
Project: 164291
Buggy source:
@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;
}

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=Math.min(wand.curCharges + 1,10);
    updateQuickslot();
  }
  return this;
}
Program: 164292
Project: 164292
Buggy source:
@Override public void activate(){
  if (Dungeon.bossLevel()) {
    return;
  }
  int nMobs=1;
  if (Random.Int(2) == 0) {
    nMobs++;
    if (Random.Int(2) == 0) {
      nMobs++;
    }
  }
  ArrayList<Integer> candidates=new ArrayList<>();
  for (int i=0; i < Level.NEIGHBOURS8.length; i++) {
    int p=pos + Level.NEIGHBOURS8[i];
    if (Actor.findChar(p) == null && (Level.passable[p] || Level.avoid[p])) {
      candidates.add(p);
    }
  }
  ArrayList<Integer> respawnPoints=new ArrayList<>();
  while (nMobs > 0 && candidates.size() > 0) {
    int index=Random.index(candidates);
    DUMMY.pos=candidates.get(index);
    respawnPoints.add(candidates.remove(index));
    nMobs--;
  }
  for (  Integer point : respawnPoints) {
    Mob mob=Bestiary.mob(Dungeon.depth);
    mob.state=mob.WANDERING;
    GameScene.add(mob,DELAY);
    ScrollOfTeleportation.appear(mob,point);
  }
}

Fixed version (ground truth):
@Override public void activate(){
  if (Dungeon.bossLevel()) {
    return;
  }
  int nMobs=1;
  if (Random.Int(2) == 0) {
    nMobs++;
    if (Random.Int(2) == 0) {
      nMobs++;
    }
  }
  ArrayList<Integer> candidates=new ArrayList<>();
  for (int i=0; i < Level.NEIGHBOURS8.length; i++) {
    int p=pos + Level.NEIGHBOURS8[i];
    if (Actor.findChar(p) == null && (Level.passable[p] || Level.avoid[p])) {
      candidates.add(p);
    }
  }
  ArrayList<Integer> respawnPoints=new ArrayList<>();
  while (nMobs > 0 && candidates.size() > 0) {
    int index=Random.index(candidates);
    respawnPoints.add(candidates.remove(index));
    nMobs--;
  }
  ArrayList<Mob> mobs=new ArrayList<>();
  for (  Integer point : respawnPoints) {
    Mob mob=Bestiary.mob(Dungeon.depth);
    mob.state=mob.WANDERING;
    mob.pos=point;
    GameScene.add(mob,DELAY);
    mobs.add(mob);
  }
  for (  Mob mob : mobs) {
    ScrollOfTeleportation.appear(mob,mob.pos);
  }
}
Program: 164294
Project: 164294
Buggy source:
@Override public void proc(Char attacker,Char defender,int damage){
  if (wand != null && Dungeon.hero.subClass == HeroSubClass.BATTLEMAGE) {
    wand.partialCharge+=0.33f;
    ScrollOfRecharging.charge((Hero)attacker);
    wand.onHit(this,attacker,defender,damage);
  }
  super.proc(attacker,defender,damage);
}

Fixed version (ground truth):
@Override public void proc(Char attacker,Char defender,int damage){
  if (wand != null && Dungeon.hero.subClass == HeroSubClass.BATTLEMAGE) {
    if (wand.curCharges < wand.maxCharges)     wand.partialCharge+=0.33f;
    ScrollOfRecharging.charge((Hero)attacker);
    wand.onHit(this,attacker,defender,damage);
  }
  super.proc(attacker,defender,damage);
}
Program: 164295
Project: 164295
Buggy source:
@Override public void activate(){
  Char ch=Actor.findChar(pos);
  if (ch != null) {
    ch.damage(Math.max(1,Random.Int(ch.HP / 3,2 * ch.HP / 3)),LIGHTNING);
    if (ch == Dungeon.hero) {
      Camera.main.shake(2,0.3f);
      if (!ch.isAlive()) {
        Dungeon.fail(Utils.format(ResultDescriptions.TRAP,name));
        GLog.n("String_Node_Str");
      }
    }
    ArrayList<Lightning.Arc> arcs=new ArrayList<>();
    arcs.add(new Lightning.Arc(pos - Level.WIDTH,pos + Level.WIDTH));
    arcs.add(new Lightning.Arc(pos - 1,pos + 1));
    ch.sprite.parent.add(new Lightning(arcs,null));
  }
  Heap heap=Dungeon.level.heaps.get(pos);
  if (heap != null) {
    Item item=heap.items.peek();
    if (item instanceof Wand) {
      Wand wand=(Wand)item;
      ((Wand)item).curCharges+=(int)Math.ceil((wand.curCharges - wand.maxCharges) / 2f);
    }
  }
  CellEmitter.center(pos).burst(SparkParticle.FACTORY,Random.IntRange(3,4));
}

Fixed version (ground truth):
@Override public void activate(){
  Char ch=Actor.findChar(pos);
  if (ch != null) {
    ch.damage(Math.max(1,Random.Int(ch.HP / 3,2 * ch.HP / 3)),LIGHTNING);
    if (ch == Dungeon.hero) {
      Camera.main.shake(2,0.3f);
      if (!ch.isAlive()) {
        Dungeon.fail(Utils.format(ResultDescriptions.TRAP,name));
        GLog.n("String_Node_Str");
      }
    }
    ArrayList<Lightning.Arc> arcs=new ArrayList<>();
    arcs.add(new Lightning.Arc(pos - Level.WIDTH,pos + Level.WIDTH));
    arcs.add(new Lightning.Arc(pos - 1,pos + 1));
    ch.sprite.parent.add(new Lightning(arcs,null));
  }
  Heap heap=Dungeon.level.heaps.get(pos);
  if (heap != null) {
    Item item=heap.items.peek();
    if (item instanceof Wand) {
      Wand wand=(Wand)item;
      ((Wand)item).curCharges+=(int)Math.ceil((wand.maxCharges - wand.curCharges) / 2f);
    }
  }
  CellEmitter.center(pos).burst(SparkParticle.FACTORY,Random.IntRange(3,4));
}
Program: 164296
Project: 164296
Buggy source:
private void build(int from,int to,boolean stopTarget,boolean stopChars,boolean stopTerrain){
  int w=Level.WIDTH;
  int x0=from % w;
  int x1=to % w;
  int y0=from / w;
  int y1=to / w;
  int dx=x1 - x0;
  int dy=y1 - y0;
  int stepX=dx > 0 ? +1 : -1;
  int stepY=dy > 0 ? +1 : -1;
  dx=Math.abs(dx);
  dy=Math.abs(dy);
  int stepA;
  int stepB;
  int dA;
  int dB;
  if (dx > dy) {
    stepA=stepX;
    stepB=stepY * w;
    dA=dx;
    dB=dy;
  }
 else {
    stepA=stepY * w;
    stepB=stepX;
    dA=dy;
    dB=dx;
  }
  int cell=from;
  int err=dA / 2;
  while (Level.insideMap(cell)) {
    if (stopTerrain && !Level.passable[cell] && !Level.avoid[cell]) {
      collide(path.get(path.size() - 1));
    }
    path.add(cell);
    if ((stopTerrain && Level.losBlocking[cell]) || (cell != sourcePos && stopChars && Actor.findChar(cell) != null) || (cell == to && stopTarget)) {
      collide(cell);
    }
    cell+=stepA;
    err+=dB;
    if (err >= dA) {
      err=err - dA;
      cell=cell + stepB;
    }
  }
}

Fixed version (ground truth):
private void build(int from,int to,boolean stopTarget,boolean stopChars,boolean stopTerrain){
  int w=Level.WIDTH;
  int x0=from % w;
  int x1=to % w;
  int y0=from / w;
  int y1=to / w;
  int dx=x1 - x0;
  int dy=y1 - y0;
  int stepX=dx > 0 ? +1 : -1;
  int stepY=dy > 0 ? +1 : -1;
  dx=Math.abs(dx);
  dy=Math.abs(dy);
  int stepA;
  int stepB;
  int dA;
  int dB;
  if (dx > dy) {
    stepA=stepX;
    stepB=stepY * w;
    dA=dx;
    dB=dy;
  }
 else {
    stepA=stepY * w;
    stepB=stepX;
    dA=dy;
    dB=dx;
  }
  int cell=from;
  int err=dA / 2;
  while (Level.insideMap(cell)) {
    if (stopTerrain && cell != sourcePos && !Level.passable[cell] && !Level.avoid[cell]) {
      collide(path.get(path.size() - 1));
    }
    path.add(cell);
    if ((stopTerrain && cell != sourcePos && Level.losBlocking[cell]) || (cell != sourcePos && stopChars && Actor.findChar(cell) != null) || (cell == to && stopTarget)) {
      collide(cell);
    }
    cell+=stepA;
    err+=dB;
    if (err >= dA) {
      err=err - dA;
      cell=cell + stepB;
    }
  }
}