nus-yam/ex-repair huggingface dataset:
Program: 164346
Project: 164346
Buggy source:
@Override protected void layout(){
  health.visible=!Float.isNaN(healthLvl);
  imIcon.x=x;
  imIcon.y=y;
  tfLabel.x=PixelScene.align(PixelScene.uiCamera,imIcon.x + imIcon.width() + GAP);
  tfLabel.maxWidth=(int)(width - tfLabel.x);
  tfLabel.measure();
  tfLabel.y=PixelScene.align(PixelScene.uiCamera,imIcon.height > tfLabel.height() ? imIcon.y + (imIcon.height() - tfLabel.baseLine()) / 2 : imIcon.y);
  if (health.visible) {
    health.setRect(tfLabel.x,Math.max(tfLabel.y + tfLabel.height(),imIcon.y + imIcon.height() - health.height()),tfLabel.maxWidth,0);
    height=health.bottom();
  }
 else {
    height=Math.max(imIcon.y + imIcon.height(),tfLabel.y + tfLabel.height());
  }
}

Fixed version (ground truth):
@Override protected void layout(){
  health.visible=!Float.isNaN(healthLvl);
  imIcon.x=x;
  imIcon.y=y;
  tfLabel.x=PixelScene.align(PixelScene.uiCamera,imIcon.x + imIcon.width() + GAP);
  tfLabel.maxWidth=(int)(width - tfLabel.x);
  tfLabel.measure();
  tfLabel.y=PixelScene.align(PixelScene.uiCamera,imIcon.height > tfLabel.height() ? imIcon.y + (imIcon.height() - tfLabel.baseLine()) / 2 : imIcon.y);
  if (health.visible) {
    health.setRect(tfLabel.x,Math.max(tfLabel.y + tfLabel.height(),imIcon.y + imIcon.height() - health.height()),tfLabel.maxWidth,0);
    height=health.bottom();
  }
 else {
    height=Math.max(imIcon.height(),tfLabel.height());
  }
}
Program: 164347
Project: 164347
Buggy source:
private Wand changeWand(Wand w){
  Wand n;
  do {
    n=(Wand)Generator.random(Category.WAND);
  }
 while (n.getClass() == w.getClass());
  n.level=0;
  n.upgrade(w.level);
  n.levelKnown=w.levelKnown;
  n.cursedKnown=w.cursedKnown;
  n.cursed=w.cursed;
  return n;
}

Fixed version (ground truth):
private Wand changeWand(Wand w){
  Wand n;
  do {
    n=(Wand)Generator.random(Category.WAND);
  }
 while (n.getClass() == w.getClass());
  n.level=0;
  n.updateLevel();
  n.upgrade(w.level);
  n.levelKnown=w.levelKnown;
  n.cursedKnown=w.cursedKnown;
  n.cursed=w.cursed;
  return n;
}
Program: 164348
Project: 164348
Buggy source:
protected void updateLevel(){
  maxCharges=Math.min(initialCharges() + level,9);
  curCharges=Math.min(curCharges,maxCharges);
  calculateDamage();
}

Fixed version (ground truth):
public void updateLevel(){
  maxCharges=Math.min(initialCharges() + level,9);
  curCharges=Math.min(curCharges,maxCharges);
  calculateDamage();
}
Program: 164349
Project: 164349
Buggy source:
public static void read(int pos){
  if (Dungeon.level instanceof DeadEndLevel) {
    GameScene.show(new WndMessage(TXT_DEAD_END));
  }
 else {
    int index=Dungeon.depth - 1;
    if (index < TIPS.length) {
      GameScene.show(new WndMessage(TIPS[index]));
      if (index >= 21)       Level.set(pos,Terrain.EMBERS);
      GameScene.updateMap(pos);
      GameScene.discoverTile(pos,Terrain.SIGN);
      GLog.w(TXT_BURN);
      CellEmitter.get(pos).burst(ElmoParticle.FACTORY,6);
      Sample.INSTANCE.play(Assets.SND_BURNING);
    }
  }
}

Fixed version (ground truth):
public static void read(int pos){
  if (Dungeon.level instanceof DeadEndLevel) {
    GameScene.show(new WndMessage(TXT_DEAD_END));
  }
 else {
    int index=Dungeon.depth - 1;
    if (index < TIPS.length) {
      GameScene.show(new WndMessage(TIPS[index]));
      if (index >= 21) {
        Level.set(pos,Terrain.EMBERS);
        GameScene.updateMap(pos);
        GameScene.discoverTile(pos,Terrain.SIGN);
        GLog.w(TXT_BURN);
        CellEmitter.get(pos).burst(ElmoParticle.FACTORY,6);
        Sample.INSTANCE.play(Assets.SND_BURNING);
      }
    }
  }
}
Program: 164350
Project: 164350
Buggy source:
@Override protected void onTouchDown(Touch t){
  if (t != touch && another == null) {
    if (!touch.down) {
      touch=t;
      onTouchDown(t);
      return;
    }
    pinching=true;
    another=t;
    startSpan=PointF.distance(touch.current,another.current);
    startZoom=camera.zoom;
    dragging=false;
  }
}

Fixed version (ground truth):
@Override protected void onTouchDown(Touch t){
  if (t != touch && another == null) {
    if (!touch.down) {
      touch=t;
      onTouchDown(t);
      return;
    }
    pinching=true;
    another=t;
    startSpan=PointF.distance(touch.current,another.current);
    startZoom=camera.zoom;
    dragging=false;
  }
 else   if (t != touch) {
    reset();
  }
}
Program: 164351
Project: 164351
Buggy source:
@Override public synchronized void update(){
  if (Dungeon.hero == null) {
    return;
  }
  super.update();
  if (!freezeEmitters)   water.offset(0,-5 * Game.elapsed);
  Actor.process();
  if (Dungeon.hero.ready && !Dungeon.hero.paralysed) {
    log.newLine();
  }
  if (tagAttack != attack.active || tagLoot != loot.visible || tagResume != resume.visible) {
    tagAttack=attack.active;
    tagLoot=loot.visible;
    tagResume=resume.visible;
    layoutTags();
  }
  cellSelector.enabled=Dungeon.hero.ready;
}

Fixed version (ground truth):
@Override public synchronized void update(){
  if (Dungeon.hero == null) {
    return;
  }
  super.update();
  if (!freezeEmitters)   water.offset(0,-5 * Game.elapsed);
  Actor.process();
  if (Dungeon.hero.ready && !Dungeon.hero.paralysed) {
    log.newLine();
  }
  if (tagAttack != attack.active || tagLoot != loot.visible || tagResume != resume.visible) {
    tagAttack=attack.active;
    tagLoot=loot.visible;
    tagResume=resume.visible;
    layoutTags();
  }
  cellSelector.enable(Dungeon.hero.ready);
}
Program: 164352
Project: 164352
Buggy source:
@Override public ArrayList<String> actions(Hero hero){
  ArrayList<String> actions=super.actions(hero);
  if (isEquipped(hero) && charge > 0 && !cursed)   actions.add(AC_READ);
  if (level < levelCap && !cursed)   actions.add(AC_ADD);
  return actions;
}

Fixed version (ground truth):
@Override public ArrayList<String> actions(Hero hero){
  ArrayList<String> actions=super.actions(hero);
  if (isEquipped(hero) && charge > 0 && !cursed)   actions.add(AC_READ);
  if (isEquipped(hero) && level < levelCap && !cursed)   actions.add(AC_ADD);
  return actions;
}
Program: 164353
Project: 164353
Buggy source:
@Override public void use(BlobEmitter emitter){
  super.use(emitter);
  emitter.start(GooWarnParticle.FACTORY,0.05f,0);
}

Fixed version (ground truth):
@Override public void use(BlobEmitter emitter){
  super.use(emitter);
  emitter.pour(GooSprite.GooParticle.FACTORY,0.03f);
}
Program: 164354
Project: 164354
Buggy source:
@Override public void play(Animation anim,boolean force){
  super.play(anim,force);
  if (anim == pump) {
    spray=centerEmitter();
    spray.pour(GooParticle.FACTORY,0.04f);
  }
 else   if (spray != null) {
    spray.on=false;
    spray=null;
  }
}

Fixed version (ground truth):
@Override public void play(Animation anim,boolean force){
  super.play(anim,force);
}
Program: 164355
Project: 164355
Buggy source:
public GooSprite(){
  super();
  texture(Assets.GOO);
  TextureFilm frames=new TextureFilm(texture,20,14);
  idle=new Animation(10,true);
  idle.frames(frames,2,1,0,0,1);
  run=new Animation(15,true);
  run.frames(frames,3,2,1,2);
  pump=new Animation(20,true);
  pump.frames(frames,4,3,2,1,0);
  pumpAttack=new Animation(20,false);
  pumpAttack.frames(frames,4,3,2,1,0,7);
  jump=new Animation(1,true);
  jump.frames(frames,6);
  attack=new Animation(10,false);
  attack.frames(frames,8,9,10);
  die=new Animation(10,false);
  die.frames(frames,5,6,7);
  play(idle);
}

Fixed version (ground truth):
public GooSprite(){
  super();
  texture(Assets.GOO);
  TextureFilm frames=new TextureFilm(texture,20,14);
  idle=new Animation(10,true);
  idle.frames(frames,2,1,0,0,1);
  run=new Animation(15,true);
  run.frames(frames,3,2,1,2);
  pump=new Animation(20,true);
  pump.frames(frames,4,3,2,1,0);
  pumpAttack=new Animation(20,false);
  pumpAttack.frames(frames,4,3,2,1,0,7);
  attack=new Animation(10,false);
  attack.frames(frames,8,9,10);
  die=new Animation(10,false);
  die.frames(frames,5,6,7);
  play(idle);
}
Program: 164356
Project: 164356
Buggy source:
@Override public void update(){
  super.update();
  if (visible) {
    if (growing) {
      scale.set(scale.x + Game.elapsed * timeScale);
      if (scale.x > maxSize) {
        growing=false;
      }
    }
 else {
      scale.set(scale.x - Game.elapsed * timeScale);
      if (scale.x < 1) {
        growing=true;
      }
    }
    x=owner.x + owner.width - width / 2;
    y=owner.y - height;
  }
}

Fixed version (ground truth):
@Override public void update(){
  super.update();
  if (visible) {
    if (growing) {
      scale.set(Math.min(scale.x + Game.elapsed * timeScale,maxSize));
      if (scale.x >= maxSize) {
        growing=false;
      }
    }
 else {
      scale.set(Math.max(scale.x - Game.elapsed * timeScale,1f));
      if (scale.x <= 1) {
        growing=true;
      }
    }
    x=owner.x + owner.width - width / 2;
    y=owner.y - height;
  }
}
Program: 164357
Project: 164357
Buggy source:
@SuppressWarnings("String_Node_Str") @Override public void restoreFromBundle(Bundle bundle){
  super.restoreFromBundle(bundle);
  items=new ArrayList<Item>((Collection<? extends Item>)bundle.getCollection(ITEMS));
  adjustStats(bundle.getInt(LEVEL));
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Override public void restoreFromBundle(Bundle bundle){
  super.restoreFromBundle(bundle);
  items=new ArrayList<Item>((Collection<Item>)((Collection<?>)bundle.getCollection(ITEMS)));
  adjustStats(bundle.getInt(LEVEL));
}
Program: 164358
Project: 164358
Buggy source:
@Override public boolean act(){
  target.invisible--;
  detach();
  return true;
}

Fixed version (ground truth):
@Override public boolean act(){
  detach();
  return true;
}
Program: 164359
Project: 164359
Buggy source:
@Override public void restoreFromBundle(Bundle bundle){
  super.restoreFromBundle(bundle);
  int[] values=bundle.getIntArray(PRESSES);
  for (int i=0; i < values.length; i++)   presses.add(values[i]);
  partialTime=bundle.getFloat(PARTIALTIME);
}

Fixed version (ground truth):
@Override public void restoreFromBundle(Bundle bundle){
  super.restoreFromBundle(bundle);
  int[] values=bundle.getIntArray(PRESSES);
  for (  int value : values)   presses.add(value);
  partialTime=bundle.getFloat(PARTIALTIME);
}
Program: 164362
Project: 164362
Buggy source:
@Override public void destroy(){
  super.destroy();
  instance=null;
  lastItem=null;
  lastTarget=null;
}

Fixed version (ground truth):
@Override public void destroy(){
  super.destroy();
  instance=new QuickSlotButton[4];
  lastItem=null;
  lastTarget=null;
}
Program: 164364
Project: 164364
Buggy source:
public final Item detach(Bag container){
  if (quantity <= 0) {
    return null;
  }
 else   if (quantity == 1) {
    if (stackable == true || this instanceof Boomerang) {
      Dungeon.quickslot.convertToPlaceholder(this);
    }
    return detachAll(container);
  }
 else {
    quantity--;
    updateQuickslot();
    try {
      Item detached=getClass().newInstance();
      Bundle copy=new Bundle();
      this.storeInBundle(copy);
      detached.restoreFromBundle(copy);
      detached.quantity(1);
      detached.onDetach();
      return detached;
    }
 catch (    Exception e) {
      return null;
    }
  }
}

Fixed version (ground truth):
public final Item detach(Bag container){
  if (quantity <= 0) {
    return null;
  }
 else   if (quantity == 1) {
    if (stackable || this instanceof Boomerang) {
      Dungeon.quickslot.convertToPlaceholder(this);
    }
    return detachAll(container);
  }
 else {
    quantity--;
    updateQuickslot();
    try {
      Item detached=getClass().newInstance();
      Bundle copy=new Bundle();
      this.storeInBundle(copy);
      detached.restoreFromBundle(copy);
      detached.quantity(1);
      detached.onDetach();
      return detached;
    }
 catch (    Exception e) {
      return null;
    }
  }
}
Program: 164365
Project: 164365
Buggy source:
private void circleBack(int from,Hero owner){
  ((MissileSprite)curUser.sprite.parent.recycle(MissileSprite.class)).reset(from,curUser.pos,curItem,null);
  if (throwEquiped) {
    owner.belongings.weapon=this;
    owner.spend(-TIME_TO_EQUIP);
  }
 else   if (!collect(curUser.belongings.backpack)) {
    Dungeon.level.drop(this,owner.pos).sprite.drop();
  }
}

Fixed version (ground truth):
private void circleBack(int from,Hero owner){
  ((MissileSprite)curUser.sprite.parent.recycle(MissileSprite.class)).reset(from,curUser.pos,curItem,null);
  if (throwEquiped) {
    owner.belongings.weapon=this;
    owner.spend(-TIME_TO_EQUIP);
    Dungeon.quickslot.replaceSimilar(this);
    updateQuickslot();
  }
 else   if (!collect(curUser.belongings.backpack)) {
    Dungeon.level.drop(this,owner.pos).sprite.drop();
  }
}
Program: 164366
Project: 164366
Buggy source:
@Override public void update(){
  if (visible != (Dungeon.hero.lastAction != null)) {
    visible=Dungeon.hero.lastAction != null;
    if (visible)     flash();
  }
  super.update();
}

Fixed version (ground truth):
@Override public void update(){
  if (!Dungeon.hero.isAlive())   visible=false;
 else   if (visible != (Dungeon.hero.lastAction != null)) {
    visible=Dungeon.hero.lastAction != null;
    if (visible)     flash();
  }
  super.update();
}
Program: 164367
Project: 164367
Buggy source:
public Effect(){
  super(0,0,0,0);
  point(sprite.worldToCamera(from));
  end=sprite.worldToCamera(to);
  speed.set(2 * (end.x - x) / DELAY,2 * (end.y - y) / DELAY);
  acc.set(-speed.x / DELAY,-speed.y / DELAY);
  delay=0;
  sprite.parent.add(this);
}

Fixed version (ground truth):
public Effect(){
  super(0,0,0,0);
  point(sprite.worldToCamera(from));
  end=sprite.worldToCamera(to);
  speed.set(2 * (end.x - x) / DELAY,2 * (end.y - y) / DELAY);
  acc.set(-speed.x / DELAY,-speed.y / DELAY);
  delay=0;
  if (sprite.parent != null)   sprite.parent.add(this);
}
Program: 164368
Project: 164368
Buggy source:
@Override public void restoreFromBundle(Bundle bundle){
  info=bundle.getString(REASON);
  win=bundle.getBoolean(WIN);
  score=bundle.getInt(SCORE);
  heroClass=HeroClass.restoreInBundle(bundle);
  armorTier=bundle.getInt(TIER);
  gameFile=bundle.getString(GAME);
  if (!bundle.contains(LEVEL)) {
    try {
      depth=Integer.parseInt(info.replaceAll("String_Node_Str","String_Node_Str"));
    }
 catch (    Exception e) {
      depth=0;
    }
    info=info.split("String_Node_Str")[0].trim();
    try {
      Dungeon.loadGame(gameFile);
      herolevel=Dungeon.hero.lvl;
    }
 catch (    Exception e) {
      herolevel=0;
    }
  }
 else {
    depth=bundle.getInt(DEPTH);
    herolevel=bundle.getInt(LEVEL);
  }
}

Fixed version (ground truth):
@Override public void restoreFromBundle(Bundle bundle){
  info=bundle.getString(REASON);
  win=bundle.getBoolean(WIN);
  score=bundle.getInt(SCORE);
  heroClass=HeroClass.restoreInBundle(bundle);
  armorTier=bundle.getInt(TIER);
  gameFile=bundle.getString(GAME);
  if (!bundle.contains(LEVEL)) {
    try {
      depth=Integer.parseInt(info.replaceAll("String_Node_Str","String_Node_Str"));
    }
 catch (    Exception e) {
      depth=0;
    }
    info=info.split("String_Node_Str")[0].trim();
    try {
      InputStream input=Game.instance.openFileInput(gameFile);
      Bundle gameBundle=Bundle.read(input);
      input.close();
      herolevel=((Hero)gameBundle.get("String_Node_Str")).lvl;
    }
 catch (    Exception e) {
      herolevel=0;
    }
  }
 else {
    depth=bundle.getInt(DEPTH);
    herolevel=bundle.getInt(LEVEL);
  }
}
Program: 164369
Project: 164369
Buggy source:
public void guessBrew(){
  if (curGuess.size() != 3)   return;
  int numWrongPlace=0;
  int numRight=0;
  for (  String potion : curGuess) {
    if (combination.contains(potion)) {
      if (curGuess.indexOf(potion) == combination.indexOf(potion)) {
        numRight++;
      }
 else {
        numWrongPlace++;
      }
    }
  }
  int score=(numRight * 3) + numWrongPlace;
  if (score == 9)   score++;
  if (score == 0) {
    GLog.i("String_Node_Str" + "String_Node_Str");
  }
 else   if (score > level) {
    level=score;
    bstGuess=curGuess;
    this.numRight=numRight;
    this.numWrongPlace=numWrongPlace;
    if (level == 10) {
      bstGuess=new ArrayList<String>();
      GLog.p("String_Node_Str");
    }
 else {
      GLog.w("String_Node_Str" + brewDesc(numWrongPlace,numRight) + "String_Node_Str");
    }
  }
 else {
    GLog.w("String_Node_Str" + brewDesc(numWrongPlace,numRight) + "String_Node_Str");
  }
  curGuess=new ArrayList<String>();
}

Fixed version (ground truth):
public void guessBrew(){
  if (curGuess.size() != 3)   return;
  int numWrongPlace=0;
  int numRight=0;
  for (  String potion : curGuess) {
    if (combination.contains(potion)) {
      if (curGuess.indexOf(potion) == combination.indexOf(potion)) {
        numRight++;
      }
 else {
        numWrongPlace++;
      }
    }
  }
  int score=(numRight * 3) + numWrongPlace;
  if (score == 9)   score++;
  if (score == 0) {
    GLog.i("String_Node_Str" + "String_Node_Str");
  }
 else   if (score > level) {
    level=score;
    seedsToPotion=0;
    bstGuess=curGuess;
    this.numRight=numRight;
    this.numWrongPlace=numWrongPlace;
    if (level == 10) {
      bstGuess=new ArrayList<String>();
      GLog.p("String_Node_Str");
    }
 else {
      GLog.w("String_Node_Str" + brewDesc(numWrongPlace,numRight) + "String_Node_Str");
    }
  }
 else {
    GLog.w("String_Node_Str" + brewDesc(numWrongPlace,numRight) + "String_Node_Str");
  }
  curGuess=new ArrayList<String>();
}
Program: 164370
Project: 164370
Buggy source:
public boolean tryCook(int count){
  if (seedsToPotion == 0) {
    if (Random.Int(30) < 10 + level) {
      if (Random.Int(30) < level) {
        seedsToPotion=1;
      }
 else       seedsToPotion=2;
    }
 else     seedsToPotion=3;
  }
  if (count >= seedsToPotion) {
    seedsToPotion=0;
    return true;
  }
 else   return false;
}

Fixed version (ground truth):
public boolean tryCook(int count){
  if (seedsToPotion == 0) {
    if (Random.Int(20) < 10 + level) {
      if (Random.Int(20) < level) {
        seedsToPotion=1;
      }
 else       seedsToPotion=2;
    }
 else     seedsToPotion=3;
  }
  if (count >= seedsToPotion) {
    seedsToPotion=0;
    return true;
  }
 else   return false;
}
Program: 164371
Project: 164371
Buggy source:
private static void store(Bundle bundle,HashSet<Badge> badges){
  int count=0;
  String names[]=new String[global.size()];
  for (  Badge badge : badges) {
    names[count++]=badge.toString();
  }
  bundle.put(BADGES,names);
}

Fixed version (ground truth):
private static void store(Bundle bundle,HashSet<Badge> badges){
  int count=0;
  String names[]=new String[badges.size()];
  for (  Badge badge : badges) {
    names[count++]=badge.toString();
  }
  bundle.put(BADGES,names);
}
Program: 164372
Project: 164372
Buggy source:
@Override protected void assignRoomType(){
  super.assignRoomType();
  for (  Room r : rooms) {
    if (r.type == Type.TUNNEL) {
      r.type=Type.PASSAGE;
    }
  }
}

Fixed version (ground truth):
@Override protected boolean assignRoomType(){
  super.assignRoomType();
  for (  Room r : rooms) {
    if (r.type == Type.TUNNEL) {
      r.type=Type.PASSAGE;
    }
  }
  return true;
}
Program: 164373
Project: 164373
Buggy source:
@Override protected void assignRoomType(){
  super.assignRoomType();
  for (  Room r : rooms) {
    if (r.type == Type.TUNNEL) {
      r.type=Type.PASSAGE;
    }
  }
}

Fixed version (ground truth):
@Override protected boolean assignRoomType(){
  super.assignRoomType();
  for (  Room r : rooms) {
    if (r.type == Type.TUNNEL) {
      r.type=Type.PASSAGE;
    }
  }
  return true;
}
Program: 164378
Project: 164378
Buggy source:
public static void paint(Level level,Room room){
  fill(level,room,Terrain.WALL);
  fill(level,room,1,Terrain.EMPTY_SP);
  pasWidth=room.width() - 2;
  pasHeight=room.height() - 2;
  int per=pasWidth * 2 + pasHeight * 2;
  Item[] range=range();
  int pos=xy2p(room,room.entrance()) + (per - range.length) / 2;
  for (int i=0; i < range.length; i++) {
    Point xy=p2xy(room,(pos + per) % per);
    int cell=xy.x + xy.y * Level.WIDTH;
    if (level.heaps.get(cell) != null) {
      do {
        cell=room.random();
      }
 while (level.heaps.get(cell) != null);
    }
    level.drop(range[i],cell).type=Heap.Type.FOR_SALE;
    pos++;
  }
  placeShopkeeper(level,room);
  for (  Room.Door door : room.connected.values()) {
    door.set(Room.Door.Type.REGULAR);
  }
}

Fixed version (ground truth):
public static void paint(Level level,Room room){
  fill(level,room,Terrain.WALL);
  fill(level,room,1,Terrain.EMPTY_SP);
  pasWidth=room.width() - 2;
  pasHeight=room.height() - 2;
  int per=pasWidth * 2 + pasHeight * 2;
  if (itemsToSpawn == null)   generateItems();
  int pos=xy2p(room,room.entrance()) + (per - itemsToSpawn.size()) / 2;
  for (  Item item : itemsToSpawn) {
    Point xy=p2xy(room,(pos + per) % per);
    int cell=xy.x + xy.y * Level.WIDTH;
    if (level.heaps.get(cell) != null) {
      do {
        cell=room.random();
      }
 while (level.heaps.get(cell) != null);
    }
    level.drop(item,cell).type=Heap.Type.FOR_SALE;
    pos++;
  }
  placeShopkeeper(level,room);
  for (  Room.Door door : room.connected.values()) {
    door.set(Room.Door.Type.REGULAR);
  }
  itemsToSpawn=null;
}
Program: 164379
Project: 164379
Buggy source:
@Override public void detach(){
  charge/=0.80;
  super.detach();
}

Fixed version (ground truth):
@Override public void detach(){
  charge*=0.80;
  super.detach();
}
Program: 164380
Project: 164380
Buggy source:
public static void dispel(){
  Invisibility buff=Dungeon.hero.buff(Invisibility.class);
  if (buff != null && Dungeon.hero.visibleEnemies() > 0) {
    buff.detach();
  }
  CloakOfShadows.cloakStealth cloakBuff=Dungeon.hero.buff(CloakOfShadows.cloakStealth.class);
  if (cloakBuff != null && Dungeon.hero.visibleEnemies() > 0) {
    cloakBuff.act();
    cloakBuff.detach();
  }
  TimekeepersHourglass.timeFreeze timeFreeze=Dungeon.hero.buff(TimekeepersHourglass.timeFreeze.class);
  if (timeFreeze != null && Dungeon.hero.visibleEnemies() > 0) {
    timeFreeze.detach();
  }
}

Fixed version (ground truth):
public static void dispel(){
  Invisibility buff=Dungeon.hero.buff(Invisibility.class);
  if (buff != null) {
    buff.detach();
  }
  CloakOfShadows.cloakStealth cloakBuff=Dungeon.hero.buff(CloakOfShadows.cloakStealth.class);
  if (cloakBuff != null) {
    cloakBuff.act();
    cloakBuff.detach();
  }
  TimekeepersHourglass.timeFreeze timeFreeze=Dungeon.hero.buff(TimekeepersHourglass.timeFreeze.class);
  if (timeFreeze != null) {
    timeFreeze.detach();
  }
}
Program: 164381
Project: 164381
Buggy source:
@Override public void execute(Hero hero,String action){
  if (action == special()) {
    if (hero.HP < 3) {
      GLog.w(TXT_LOW_HEALTH);
    }
 else     if (!isEquipped(hero)) {
      GLog.w(TXT_NOT_EQUIPPED);
    }
 else {
      curUser=hero;
      doSpecial();
    }
  }
 else {
    super.execute(hero,action);
  }
}

Fixed version (ground truth):
@Override public void execute(Hero hero,String action){
  if (action == special()) {
    if (hero.HP < 3) {
      GLog.w(TXT_LOW_HEALTH);
    }
 else     if (!isEquipped(hero)) {
      GLog.w(TXT_NOT_EQUIPPED);
    }
 else {
      curUser=hero;
      Invisibility.dispel();
      doSpecial();
    }
  }
 else {
    super.execute(hero,action);
  }
}
Program: 164382
Project: 164382
Buggy source:
@Override public void onSelect(Integer target){
  if (target != null && target != curUser.pos) {
    int cell=Ballistica.cast(curUser.pos,target,false,true);
    if (Actor.findChar(cell) != null && cell != curUser.pos) {
      cell=Ballistica.trace[Ballistica.distance - 2];
    }
    curUser.HP-=(curUser.HP / 3);
    if (curUser.subClass == HeroSubClass.BERSERKER && curUser.HP <= curUser.HT * Fury.LEVEL) {
      Buff.affect(curUser,Fury.class);
    }
    Invisibility.dispel();
    final int dest=cell;
    curUser.busy();
    ((HeroSprite)curUser.sprite).jump(curUser.pos,cell,new Callback(){
      @Override public void call(){
        curUser.move(dest);
        Dungeon.level.press(dest,curUser);
        Dungeon.observe();
        for (int i=0; i < Level.NEIGHBOURS8.length; i++) {
          Char mob=Actor.findChar(curUser.pos + Level.NEIGHBOURS8[i]);
          if (mob != null && mob != curUser) {
            Buff.prolong(mob,Paralysis.class,SHOCK_TIME);
          }
        }
        CellEmitter.center(dest).burst(Speck.factory(Speck.DUST),10);
        Camera.main.shake(2,0.5f);
        curUser.spendAndNext(LEAP_TIME);
      }
    }
);
  }
}

Fixed version (ground truth):
@Override public void onSelect(Integer target){
  if (target != null && target != curUser.pos) {
    int cell=Ballistica.cast(curUser.pos,target,false,true);
    if (Actor.findChar(cell) != null && cell != curUser.pos) {
      cell=Ballistica.trace[Ballistica.distance - 2];
    }
    curUser.HP-=(curUser.HP / 3);
    if (curUser.subClass == HeroSubClass.BERSERKER && curUser.HP <= curUser.HT * Fury.LEVEL) {
      Buff.affect(curUser,Fury.class);
    }
    final int dest=cell;
    curUser.busy();
    ((HeroSprite)curUser.sprite).jump(curUser.pos,cell,new Callback(){
      @Override public void call(){
        curUser.move(dest);
        Dungeon.level.press(dest,curUser);
        Dungeon.observe();
        for (int i=0; i < Level.NEIGHBOURS8.length; i++) {
          Char mob=Actor.findChar(curUser.pos + Level.NEIGHBOURS8[i]);
          if (mob != null && mob != curUser) {
            Buff.prolong(mob,Paralysis.class,SHOCK_TIME);
          }
        }
        CellEmitter.center(dest).burst(Speck.factory(Speck.DUST),10);
        Camera.main.shake(2,0.5f);
        curUser.spendAndNext(LEAP_TIME);
      }
    }
);
  }
}
Program: 164383
Project: 164383
Buggy source:
private void checkEnemies(){
  int heroPos=Dungeon.hero.pos;
  candidates.clear();
  int v=Dungeon.hero.visibleEnemies();
  for (int i=0; i < v; i++) {
    Mob mob=Dungeon.hero.visibleEnemy(i);
    if (Level.adjacent(heroPos,mob.pos)) {
      candidates.add(mob);
    }
  }
  if (!candidates.contains(lastTarget)) {
    if (candidates.isEmpty()) {
      lastTarget=null;
    }
 else {
      lastTarget=Random.element(candidates);
      updateImage();
      flash();
    }
  }
 else {
    if (!bg.visible) {
      flash();
    }
  }
  visible(lastTarget != null);
  enable(bg.visible);
}

Fixed version (ground truth):
private void checkEnemies(){
  int heroPos=Dungeon.hero.pos;
  candidates.clear();
  int v=Dungeon.hero.visibleEnemies();
  for (int i=0; i < v; i++) {
    Mob mob=Dungeon.hero.visibleEnemy(i);
    if (Level.adjacent(heroPos,mob.pos)) {
      candidates.add(mob);
    }
  }
  if (!candidates.contains(lastTarget)) {
    if (candidates.isEmpty()) {
      lastTarget=null;
    }
 else {
      active=true;
      lastTarget=Random.element(candidates);
      updateImage();
      flash();
    }
  }
 else {
    if (!bg.visible) {
      active=true;
      flash();
    }
  }
  visible(lastTarget != null);
  enable(bg.visible);
}
Program: 164384
Project: 164384
Buggy source:
@Override protected void onClick(){
  if (enabled && lastTarget != null) {
    Dungeon.hero.handle(lastTarget.pos);
  }
}

Fixed version (ground truth):
@Override protected void onClick(){
  if (enabled) {
    Dungeon.hero.handle(lastTarget.pos);
  }
}
Program: 164385
Project: 164385
Buggy source:
@Override public void update(){
  super.update();
  if (lastTarget == null) {
    if (delay > 0f)     delay-=Game.elapsed;
    if (delay <= 0f)     active=false;
  }
 else {
    delay=0.5f;
    active=true;
  }
  if (Dungeon.hero.isAlive()) {
    enable(Dungeon.hero.ready);
  }
 else {
    visible(false);
    enable(false);
  }
}

Fixed version (ground truth):
@Override public void update(){
  super.update();
  if (!bg.visible) {
    enable(false);
    if (delay > 0f)     delay-=Game.elapsed;
    if (delay <= 0f)     active=false;
  }
 else {
    delay=0.75f;
    active=true;
    if (Dungeon.hero.isAlive()) {
      enable(Dungeon.hero.ready);
    }
 else {
      visible(false);
      enable(false);
    }
  }
}
Program: 164387
Project: 164387
Buggy source:
@Override protected void onZap(int cell){
  boolean mapUpdated=false;
  int maxDistance=level() + 4;
  Ballistica.distance=Math.min(Ballistica.distance,maxDistance);
  Char ch;
  Heap heap=null;
  for (int i=1; i < Ballistica.distance; i++) {
    int c=Ballistica.trace[i];
    int before=Dungeon.level.map[c];
    if ((ch=Actor.findChar(c)) != null) {
      if (i == Ballistica.distance - 1) {
        ch.damage(maxDistance - 1 - i,this);
      }
 else {
        int next=Ballistica.trace[i + 1];
        if ((Level.passable[next] || Level.avoid[next]) && Actor.findChar(next) == null) {
          Actor.addDelayed(new Pushing(ch,ch.pos,next),-1);
          ch.pos=next;
          Actor.freeCell(next);
          if (ch instanceof Mob) {
            Dungeon.level.mobPress((Mob)ch);
          }
 else {
            Dungeon.level.press(ch.pos,ch);
          }
        }
 else {
          ch.damage(maxDistance - 1 - i,this);
        }
      }
    }
    if (heap == null && (heap=Dungeon.level.heaps.get(c)) != null) {
switch (heap.type) {
case HEAP:
        transport(heap);
      break;
case CHEST:
    open(heap);
  break;
default :
}
}
Dungeon.level.press(c,null);
if (before == Terrain.OPEN_DOOR && Actor.findChar(c) == null) {
Level.set(c,Terrain.DOOR);
GameScene.updateMap(c);
}
 else if (Level.water[c]) {
GameScene.ripple(c);
}
if (!mapUpdated && Dungeon.level.map[c] != before) {
mapUpdated=true;
}
}
if (mapUpdated) {
Dungeon.observe();
}
}

Fixed version (ground truth):
@Override protected void onZap(int cell){
  boolean mapUpdated=false;
  int maxDistance=level() + 4;
  Ballistica.distance=Math.min(Ballistica.distance,maxDistance);
  Char ch;
  Heap heap=null;
  for (int i=1; i < Ballistica.distance; i++) {
    int c=Ballistica.trace[i];
    int before=Dungeon.level.map[c];
    if ((ch=Actor.findChar(c)) != null) {
      if (i == Ballistica.distance - 1) {
        ch.damage(maxDistance - 1 - i,this);
      }
 else {
        int next=Ballistica.trace[i + 1];
        if ((Level.passable[next] || Level.avoid[next]) && Actor.findChar(next) == null) {
          Actor.addDelayed(new Pushing(ch,ch.pos,next),-1);
          ch.pos=next;
          Actor.freeCell(next);
          if (ch instanceof Shopkeeper)           ch.damage(0,this);
          if (ch instanceof Mob) {
            Dungeon.level.mobPress((Mob)ch);
          }
 else {
            Dungeon.level.press(ch.pos,ch);
          }
        }
 else {
          ch.damage(maxDistance - 1 - i,this);
        }
      }
    }
    if (heap == null && (heap=Dungeon.level.heaps.get(c)) != null) {
switch (heap.type) {
case HEAP:
        transport(heap);
      break;
case CHEST:
    open(heap);
  break;
default :
}
}
Dungeon.level.press(c,null);
if (before == Terrain.OPEN_DOOR && Actor.findChar(c) == null) {
Level.set(c,Terrain.DOOR);
GameScene.updateMap(c);
}
 else if (Level.water[c]) {
GameScene.ripple(c);
}
if (!mapUpdated && Dungeon.level.map[c] != before) {
mapUpdated=true;
}
}
if (mapUpdated) {
Dungeon.observe();
}
}
Program: 164388
Project: 164388
Buggy source:
public boolean attachTo(Char target){
  if (super.attachTo(target) && !target.immunities().contains(Sleep.class)) {
    if (cooldown() == 0)     spend(Random.Int(3,6));
    return true;
  }
  return false;
}

Fixed version (ground truth):
public boolean attachTo(Char target){
  if (!target.immunities().contains(Sleep.class) && super.attachTo(target)) {
    if (cooldown() == 0)     spend(Random.Int(3,6));
    return true;
  }
  return false;
}
Program: 164389
Project: 164389
Buggy source:
@Override public void detach(){
  triggerPresses();
  for (  Mob mob : Dungeon.level.mobs.toArray(new Mob[0]))   mob.sprite.remove(CharSprite.State.PARALYSED);
  GameScene.freezeEmitters=false;
  charge=0;
  QuickSlot.refresh();
  super.detach();
}

Fixed version (ground truth):
@Override public void detach(){
  triggerPresses();
  for (  Mob mob : Dungeon.level.mobs.toArray(new Mob[0]))   mob.sprite.remove(CharSprite.State.PARALYSED);
  GameScene.freezeEmitters=false;
  charge=0;
  QuickSlot.refresh();
  super.detach();
  activeBuff=null;
}
Program: 164390
Project: 164390
Buggy source:
@Override public boolean attack(Char enemy){
  if (!Level.adjacent(pos,enemy.pos)) {
    spend(attackDelay());
    if (hit(this,enemy,true)) {
      int dmg=damageRoll();
      enemy.damage(dmg,this);
      enemy.sprite.bloodBurstA(sprite.center(),dmg);
      enemy.sprite.flash();
      if (!enemy.isAlive() && enemy == Dungeon.hero) {
        Dungeon.fail(Utils.format(ResultDescriptions.BOSS,name,Dungeon.depth));
        GLog.n(TXT_KILL,name);
      }
      return true;
    }
 else {
      enemy.sprite.showStatus(CharSprite.NEUTRAL,enemy.defenseVerb());
      return false;
    }
  }
 else {
    return super.attack(enemy);
  }
}

Fixed version (ground truth):
@Override public boolean attack(Char enemy){
  if (!Level.adjacent(pos,enemy.pos)) {
    spend(attackDelay());
    if (hit(this,enemy,true)) {
      int dmg=damageRoll();
      enemy.damage(dmg,this);
      enemy.sprite.bloodBurstA(sprite.center(),dmg);
      enemy.sprite.flash();
      if (!enemy.isAlive() && enemy == Dungeon.hero) {
        Dungeon.fail(Utils.format(ResultDescriptions.UNIQUE,name,Dungeon.depth));
        GLog.n(TXT_KILL,name);
      }
      return true;
    }
 else {
      enemy.sprite.showStatus(CharSprite.NEUTRAL,enemy.defenseVerb());
      return false;
    }
  }
 else {
    return super.attack(enemy);
  }
}
Program: 164392
Project: 164392
Buggy source:
@Override public void die(Object cause){
  lootChance=1f / ((5 + Dungeon.limitedDrops.swarmHP.count) * generation);
  super.die(cause);
}

Fixed version (ground truth):
@Override public void die(Object cause){
  lootChance=1f / ((5 + Dungeon.limitedDrops.swarmHP.count) * generation + 1);
  super.die(cause);
}
Program: 164393
Project: 164393
Buggy source:
@Override public void onSelect(Item item){
  if (item != null && item instanceof Scroll && item.isIdentified()) {
    String scroll=convertName(item.getClass().getSimpleName());
    Hero hero=Dungeon.hero;
    for (int i=0; (i <= 1 && i < scrolls.size()); i++) {
      if (scrolls.get(i).equals(scroll)) {
        hero.sprite.operate(hero.pos);
        hero.busy();
        hero.spend(2f);
        Sample.INSTANCE.play(Assets.SND_BURNING);
        hero.sprite.emitter().burst(ElmoParticle.FACTORY,12);
        scrolls.remove(i);
        item.detach(hero.belongings.backpack);
        upgrade();
        GLog.i("String_Node_Str");
        return;
      }
    }
    if (item != null)     GLog.w("String_Node_Str");
  }
}

Fixed version (ground truth):
@Override public void onSelect(Item item){
  if (item != null && item instanceof Scroll && item.isIdentified()) {
    String scroll=convertName(item.getClass().getSimpleName());
    Hero hero=Dungeon.hero;
    for (int i=0; (i <= 1 && i < scrolls.size()); i++) {
      if (scrolls.get(i).equals(scroll)) {
        hero.sprite.operate(hero.pos);
        hero.busy();
        hero.spend(2f);
        Sample.INSTANCE.play(Assets.SND_BURNING);
        hero.sprite.emitter().burst(ElmoParticle.FACTORY,12);
        scrolls.remove(i);
        item.detach(hero.belongings.backpack);
        upgrade();
        GLog.i("String_Node_Str");
        return;
      }
    }
    if (item != null)     GLog.w("String_Node_Str");
  }
 else   if (item instanceof Scroll && !item.isIdentified())   GLog.w("String_Node_Str");
}
Program: 164394
Project: 164394
Buggy source:
protected String convertName(String className){
  className.replaceFirst("String_Node_Str","String_Node_Str");
  className.replaceAll("String_Node_Str","String_Node_Str");
  return className;
}

Fixed version (ground truth):
protected String convertName(String className){
  className=className.replaceFirst("String_Node_Str","String_Node_Str");
  className=className.replaceAll("String_Node_Str","String_Node_Str");
  return className;
}
Program: 164395
Project: 164395
Buggy source:
public Plant plant(Plant.Seed seed,int pos){
  Plant plant=plants.get(pos);
  if (plant != null) {
    plant.wither();
  }
  if (map[pos] == Terrain.HIGH_GRASS || map[pos] == Terrain.EMPTY || map[pos] == Terrain.EMBERS || map[pos] == Terrain.EMPTY_DECO) {
    set(pos,Terrain.GRASS);
    GameScene.updateMap(pos);
  }
  plant=seed.couch(pos);
  plants.put(pos,plant);
  GameScene.add(plant);
  return plant;
}

Fixed version (ground truth):
public Plant plant(Plant.Seed seed,int pos){
  Plant plant=plants.get(pos);
  if (plant != null) {
    plant.wither();
  }
  if (map[pos] == Terrain.HIGH_GRASS || map[pos] == Terrain.EMPTY || map[pos] == Terrain.EMBERS || map[pos] == Terrain.EMPTY_DECO) {
    map[pos]=Terrain.GRASS;
    GameScene.updateMap(pos);
  }
  plant=seed.couch(pos);
  plants.put(pos,plant);
  GameScene.add(plant);
  return plant;
}
Program: 164396
Project: 164396
Buggy source:
@Override public void detach(){
  for (  int cell : presses)   Dungeon.level.press(cell,null);
  for (  Mob mob : Dungeon.level.mobs.toArray(new Mob[0]))   mob.sprite.remove(CharSprite.State.PARALYSED);
  GameScene.freezeEmitters=false;
  charge=0;
  QuickSlot.refresh();
  super.detach();
}

Fixed version (ground truth):
@Override public void detach(){
  triggerPresses();
  for (  Mob mob : Dungeon.level.mobs.toArray(new Mob[0]))   mob.sprite.remove(CharSprite.State.PARALYSED);
  GameScene.freezeEmitters=false;
  charge=0;
  QuickSlot.refresh();
  super.detach();
}
Program: 164397
Project: 164397
Buggy source:
@Override public boolean attachTo(Char target){
  for (  Mob mob : Dungeon.level.mobs.toArray(new Mob[0]))   mob.sprite.add(CharSprite.State.PARALYSED);
  GameScene.freezeEmitters=true;
  return super.attachTo(target);
}

Fixed version (ground truth):
@Override public boolean attachTo(Char target){
  if (Dungeon.level != null)   for (  Mob mob : Dungeon.level.mobs.toArray(new Mob[0]))   mob.sprite.add(CharSprite.State.PARALYSED);
  GameScene.freezeEmitters=true;
  return super.attachTo(target);
}
Program: 164399
Project: 164399
Buggy source:
public void destroy(){
  scene=null;
  Badges.saveGlobal();
  super.destroy();
}

Fixed version (ground truth):
public void destroy(){
  freezeEmitters=false;
  scene=null;
  Badges.saveGlobal();
  super.destroy();
}
Program: 164400
Project: 164400
Buggy source:
@Override protected void onClick(){
  if (enabled) {
    Dungeon.hero.handle(lastTarget.pos);
  }
}

Fixed version (ground truth):
@Override protected void onClick(){
  if (Dungeon.hero.curAction != null)   Dungeon.hero.interrupt();
 else   Dungeon.hero.handle(lastTarget.pos);
}
Program: 164401
Project: 164401
Buggy source:
@Override public void update(){
  super.update();
  if (Dungeon.hero.isAlive()) {
    if (!Dungeon.hero.ready) {
      enable(false);
    }
  }
 else {
    visible(false);
    enable(false);
  }
}

Fixed version (ground truth):
@Override public void update(){
  super.update();
  if (!Dungeon.hero.isAlive()) {
    visible(false);
    enable(false);
  }
}
Program: 164404
Project: 164404
Buggy source:
private void ready(){
  sprite.idle();
  curAction=null;
  damageInterrupt=true;
  ready=true;
  GameScene.ready();
}

Fixed version (ground truth):
private void ready(){
  sprite.idle();
  curAction=null;
  damageInterrupt=true;
  ready=true;
  AttackIndicator.updateState();
  GameScene.ready();
}
Program: 164405
Project: 164405
Buggy source:
@Override protected void onClick(){
  if (Dungeon.hero.curAction != null)   Dungeon.hero.interrupt();
 else   Dungeon.hero.handle(lastTarget.pos);
}

Fixed version (ground truth):
@Override protected void onClick(){
  if (enabled) {
    Dungeon.hero.handle(lastTarget.pos);
  }
}
Program: 164406
Project: 164406
Buggy source:
private void enable(boolean value){
  enabled=value;
  if (sprite != null) {
    sprite.alpha(value ? ENABLED : DISABLED);
  }
}

Fixed version (ground truth):
private void enable(boolean value){
  enabled=value;
  active=value;
  if (sprite != null) {
    sprite.alpha(value ? ENABLED : DISABLED);
  }
}
Program: 164407
Project: 164407
Buggy source:
@Override public void update(){
  super.update();
  if (!Dungeon.hero.isAlive()) {
    visible(false);
    enable(false);
  }
}

Fixed version (ground truth):
@Override public void update(){
  super.update();
  if (Dungeon.hero.isAlive()) {
    enable(Dungeon.hero.ready);
  }
 else {
    visible(false);
    enable(false);
  }
}
Program: 164408
Project: 164408
Buggy source:
@Override protected void onClick(){
  Mob target=Dungeon.hero.visibleEnemy(enemyIndex++);
  HealthIndicator.instance.target(target == HealthIndicator.instance.target() ? null : target);
  Camera.main.target=null;
  Camera.main.focusOn(target.sprite);
}

Fixed version (ground truth):
@Override protected void onClick(){
  Mob target=Dungeon.hero.visibleEnemy(enemyIndex++);
  HealthIndicator.instance.target(target == HealthIndicator.instance.target() ? null : target);
  if (Dungeon.hero.curAction == null) {
    Camera.main.target=null;
    Camera.main.focusOn(target.sprite);
  }
}
Program: 164409
Project: 164409
Buggy source:
@Override public Item upgrade(){
  chargeCap=((level / 2) + 1);
  if (scrolls.size() > (levelCap - level))   scrolls.remove(0);
  return super.upgrade();
}

Fixed version (ground truth):
@Override public Item upgrade(){
  chargeCap=(((level + 1) / 2) + 1);
  while (scrolls.size() > (levelCap - 1 - level))   scrolls.remove(0);
  return super.upgrade();
}
Program: 164410
Project: 164410
Buggy source:
@Override public void add(Buff buff){
  if (buff instanceof Burning) {
    if (HP < HT) {
      HP++;
      sprite.emitter().burst(Speck.factory(Speck.HEALING),1);
    }
  }
 else {
    if (buff instanceof Frost) {
      if (Level.water[this.pos])       damage(Random.NormalIntRange(HT / 2,HT),buff);
 else       damage(Random.NormalIntRange(1,HT * 2 / 3),buff);
    }
    super.add(buff);
  }
}

Fixed version (ground truth):
@Override public void add(Buff buff){
  if (buff instanceof Burning) {
    if (HP < HT) {
      HP++;
      sprite.emitter().burst(Speck.factory(Speck.HEALING),1);
    }
  }
 else {
    if (buff instanceof Frost) {
      if (Level.water[this.pos])       damage(Random.NormalIntRange(HT / 2,HT),buff);
 else       damage(Random.NormalIntRange(1,HT * 2 / 3),buff);
    }
    if (isAlive())     super.add(buff);
  }
}
Program: 164411
Project: 164411
Buggy source:
@Override public void execute(Hero hero,String action){
  if (action.equals(AC_STEALTH)) {
    if (!stealthed) {
      if (cooldown <= 0 && charge > 0 && isEquipped(hero)) {
        stealthed=true;
        hero.spend(1f);
        Sample.INSTANCE.play(Assets.SND_MELD);
        activeBuff=activeBuff();
        activeBuff.attachTo(hero);
        if (hero.sprite.parent != null) {
          hero.sprite.parent.add(new AlphaTweener(hero.sprite,0.4f,0.4f));
        }
 else {
          hero.sprite.alpha(0.4f);
        }
        hero.sprite.operate(hero.pos);
        GLog.i("String_Node_Str");
      }
 else       if (!isEquipped(hero)) {
        GLog.i("String_Node_Str");
      }
 else       if (cooldown > 0) {
        GLog.i("String_Node_Str" + cooldown + "String_Node_Str");
      }
 else       if (charge == 0) {
        GLog.i("String_Node_Str");
      }
    }
 else {
      stealthed=false;
      activeBuff.detach();
      activeBuff=null;
      hero.sprite.operate(hero.pos);
      GLog.i("String_Node_Str");
    }
  }
 else {
    if (stealthed) {
      stealthed=false;
      activeBuff.detach();
      activeBuff=null;
      GLog.i("String_Node_Str");
    }
    super.execute(hero,action);
  }
}

Fixed version (ground truth):
@Override public void execute(Hero hero,String action){
  if (action.equals(AC_STEALTH)) {
    if (!stealthed) {
      if (cooldown <= 0 && charge >= 2 && isEquipped(hero)) {
        stealthed=true;
        hero.spend(1f);
        hero.busy();
        Sample.INSTANCE.play(Assets.SND_MELD);
        activeBuff=activeBuff();
        activeBuff.attachTo(hero);
        if (hero.sprite.parent != null) {
          hero.sprite.parent.add(new AlphaTweener(hero.sprite,0.4f,0.4f));
        }
 else {
          hero.sprite.alpha(0.4f);
        }
        hero.sprite.operate(hero.pos);
        GLog.i("String_Node_Str");
      }
 else       if (!isEquipped(hero)) {
        GLog.i("String_Node_Str");
      }
 else       if (cooldown > 0) {
        GLog.i("String_Node_Str" + cooldown + "String_Node_Str");
      }
 else       if (charge <= 1) {
        GLog.i("String_Node_Str");
      }
    }
 else {
      stealthed=false;
      activeBuff.detach();
      activeBuff=null;
      hero.sprite.operate(hero.pos);
      GLog.i("String_Node_Str");
    }
  }
 else {
    if (stealthed) {
      stealthed=false;
      activeBuff.detach();
      activeBuff=null;
      GLog.i("String_Node_Str");
    }
    super.execute(hero,action);
  }
}
Program: 164412
Project: 164412
Buggy source:
@Override public ArrayList<String> actions(Hero hero){
  ArrayList<String> actions=super.actions(hero);
  if (isEquipped(hero))   actions.add(AC_STEALTH);
  return actions;
}

Fixed version (ground truth):
@Override public ArrayList<String> actions(Hero hero){
  ArrayList<String> actions=super.actions(hero);
  if (isEquipped(hero) && charge > 1)   actions.add(AC_STEALTH);
  return actions;
}
Program: 164413
Project: 164413
Buggy source:
@Override public void storeInBundle(Bundle bundle){
  super.storeInBundle(bundle);
  if (state == SLEEPING) {
    bundle.put(STATE,Sleeping.TAG);
  }
 else   if (state == WANDERING) {
    bundle.put(STATE,Wandering.TAG);
  }
 else   if (state == HUNTING) {
    bundle.put(STATE,Hunting.TAG);
  }
 else   if (state == FLEEING) {
    bundle.put(STATE,Fleeing.TAG);
  }
 else   if (state == PASSIVE) {
    bundle.put(STATE,Passive.TAG);
  }
  bundle.put(TARGET,target);
}

Fixed version (ground truth):
@Override public void storeInBundle(Bundle bundle){
  super.storeInBundle(bundle);
  if (state == SLEEPING) {
    bundle.put(STATE,Sleeping.TAG);
  }
 else   if (state == WANDERING) {
    bundle.put(STATE,Wandering.TAG);
  }
 else   if (state == HUNTING) {
    bundle.put(STATE,Hunting.TAG);
  }
 else   if (state == FLEEING) {
    bundle.put(STATE,Fleeing.TAG);
  }
 else   if (state == PASSIVE) {
    bundle.put(STATE,Passive.TAG);
  }
  bundle.put(SEEN,enemySeen);
  bundle.put(TARGET,target);
}
Program: 164414
Project: 164414
Buggy source:
@Override public void restoreFromBundle(Bundle bundle){
  super.restoreFromBundle(bundle);
  String state=bundle.getString(STATE);
  if (state.equals(Sleeping.TAG)) {
    this.state=SLEEPING;
  }
 else   if (state.equals(Wandering.TAG)) {
    this.state=WANDERING;
  }
 else   if (state.equals(Hunting.TAG)) {
    this.state=HUNTING;
  }
 else   if (state.equals(Fleeing.TAG)) {
    this.state=FLEEING;
  }
 else   if (state.equals(Passive.TAG)) {
    this.state=PASSIVE;
  }
  target=bundle.getInt(TARGET);
}

Fixed version (ground truth):
@Override public void restoreFromBundle(Bundle bundle){
  super.restoreFromBundle(bundle);
  String state=bundle.getString(STATE);
  if (state.equals(Sleeping.TAG)) {
    this.state=SLEEPING;
  }
 else   if (state.equals(Wandering.TAG)) {
    this.state=WANDERING;
  }
 else   if (state.equals(Hunting.TAG)) {
    this.state=HUNTING;
  }
 else   if (state.equals(Fleeing.TAG)) {
    this.state=FLEEING;
  }
 else   if (state.equals(Passive.TAG)) {
    this.state=PASSIVE;
  }
  enemySeen=bundle.getBoolean(SEEN);
  target=bundle.getInt(TARGET);
}
Program: 164415
Project: 164415
Buggy source:
private Artifact changeArtifact(Artifact a){
  Artifact n=Generator.randomArtifact();
  if (n != null) {
    n.cursedKnown=a.cursedKnown;
    n.cursed=a.cursed;
    n.transferUpgrade(a.visiblyUpgraded());
    Journal.remove(Feature.WELL_OF_TRANSMUTATION);
  }
  return n;
}

Fixed version (ground truth):
private Artifact changeArtifact(Artifact a){
  Artifact n=Generator.randomArtifact();
  if (n != null) {
    n.cursedKnown=a.cursedKnown;
    n.cursed=a.cursed;
    n.levelKnown=a.levelKnown;
    n.transferUpgrade(a.visiblyUpgraded());
    Journal.remove(Feature.WELL_OF_TRANSMUTATION);
  }
  return n;
}