nus-yam/ex-repair huggingface dataset:
Program: 164105
Project: 164105
Buggy source:
private void updateTexture(boolean[] visible,boolean[] visited,boolean[] mapped){
  moveToUpdating();
  FogTexture fog=(FogTexture)texture;
  for (int i=updating.top; i < updating.bottom; i++) {
    int cell=(pWidth - 1) * i + updating.left;
    fog.pixels.position((width2) * i + updating.left);
    for (int j=updating.left; j < updating.right; j++) {
      if (cell < pWidth || cell >= Dungeon.level.length()) {
        fog.pixels.put(INVISIBLE);
      }
 else       if (visible[cell] && visible[cell - (pWidth - 1)] && visible[cell - 1]&& visible[cell - (pWidth - 1) - 1]) {
        fog.pixels.put(VISIBLE);
      }
 else       if (visited[cell] && visited[cell - (pWidth - 1)] && visited[cell - 1]&& visited[cell - (pWidth - 1) - 1]) {
        fog.pixels.put(VISITED);
      }
 else       if (mapped[cell] && mapped[cell - (pWidth - 1)] && mapped[cell - 1]&& mapped[cell - (pWidth - 1) - 1]) {
        fog.pixels.put(MAPPED);
      }
 else {
        fog.pixels.put(INVISIBLE);
      }
      cell++;
    }
  }
  if (updating.width() == pWidth && updating.height() == pHeight)   fog.update();
 else   fog.update(updating.top,updating.bottom);
}

Fixed version (ground truth):
private void updateTexture(boolean[] visible,boolean[] visited,boolean[] mapped){
  moveToUpdating();
  FogTexture fog=(FogTexture)texture;
  for (int i=updating.top; i < updating.bottom; i++) {
    int cell=(pWidth - 1) * i + updating.left;
    fog.pixels.position((width2) * i + updating.left);
    for (int j=updating.left; j < updating.right; j++) {
      if (cell < pWidth || cell >= Dungeon.level.length() || j == 0 || j == pWidth - 1) {
        fog.pixels.put(INVISIBLE);
      }
 else       if (visible[cell] && visible[cell - (pWidth - 1)] && visible[cell - 1]&& visible[cell - (pWidth - 1) - 1]) {
        fog.pixels.put(VISIBLE);
      }
 else       if (visited[cell] && visited[cell - (pWidth - 1)] && visited[cell - 1]&& visited[cell - (pWidth - 1) - 1]) {
        fog.pixels.put(VISITED);
      }
 else       if (mapped[cell] && mapped[cell - (pWidth - 1)] && mapped[cell - 1]&& mapped[cell - (pWidth - 1) - 1]) {
        fog.pixels.put(MAPPED);
      }
 else {
        fog.pixels.put(INVISIBLE);
      }
      cell++;
    }
  }
  if (updating.width() == pWidth && updating.height() == pHeight)   fog.update();
 else   fog.update(updating.top,updating.bottom);
}
Program: 164106
Project: 164106
Buggy source:
@Override public void draw(){
  if (needsRender)   render(this);
  super.draw();
}

Fixed version (ground truth):
@Override public void draw(){
  if (needsRender)   render(this);
  if (texture != null)   super.draw();
}
Program: 164107
Project: 164107
Buggy source:
public static void read(int pos){
  if (Dungeon.level instanceof DeadEndLevel) {
    GameScene.show(new WndMessage(Messages.get(Sign.class,"String_Node_Str")));
  }
 else {
    if (Dungeon.depth <= 21) {
      GameScene.show(new WndMessage(Messages.get(Sign.class,"String_Node_Str" + Dungeon.depth)));
    }
 else {
      if (Dungeon.depth - 21 < 3 && Messages.get(Sign.class,"String_Node_Str").equals("String_Node_Str")) {
        GameScene.show(new WndMessage(teaser_texts[Dungeon.depth - 21]));
      }
      Dungeon.level.destroy(pos);
      GameScene.updateMap(pos);
      GameScene.discoverTile(pos,Terrain.SIGN);
      GLog.w(Messages.get(Sign.class,"String_Node_Str"));
      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(Messages.get(Sign.class,"String_Node_Str")));
  }
 else {
    if (Dungeon.depth <= 21) {
      GameScene.show(new WndMessage(Messages.get(Sign.class,"String_Node_Str" + Dungeon.depth)));
    }
 else {
      if (Dungeon.depth - 21 <= 3 && Messages.lang() == Languages.ENGLISH) {
        GameScene.show(new WndMessage(teaser_texts[Dungeon.depth - 21]));
      }
      Dungeon.level.destroy(pos);
      GameScene.updateMap(pos);
      GameScene.discoverTile(pos,Terrain.SIGN);
      GLog.w(Messages.get(Sign.class,"String_Node_Str"));
      CellEmitter.get(pos).burst(ElmoParticle.FACTORY,6);
      Sample.INSTANCE.play(Assets.SND_BURNING);
    }
  }
}
Program: 164108
Project: 164108
Buggy source:
public static void afterObserve(){
  if (scene != null) {
    for (    Mob mob : Dungeon.level.mobs) {
      mob.sprite.visible=Dungeon.visible[mob.pos];
    }
  }
}

Fixed version (ground truth):
public static void afterObserve(){
  if (scene != null) {
    for (    Mob mob : Dungeon.level.mobs) {
      if (mob.sprite != null)       mob.sprite.visible=Dungeon.visible[mob.pos];
    }
  }
}
Program: 164111
Project: 164111
Buggy source:
public NoosaScript(){
  compile(shader());
  uCamera=uniform("String_Node_Str");
  uModel=uniform("String_Node_Str");
  uTex=uniform("String_Node_Str");
  uColorM=uniform("String_Node_Str");
  uColorA=uniform("String_Node_Str");
  aXY=attribute("String_Node_Str");
  aUV=attribute("String_Node_Str");
  Quad.setupIndices();
  Quad.bindIndices();
}

Fixed version (ground truth):
public NoosaScript(){
  super();
  compile(shader());
  uCamera=uniform("String_Node_Str");
  uModel=uniform("String_Node_Str");
  uTex=uniform("String_Node_Str");
  uColorM=uniform("String_Node_Str");
  uColorA=uniform("String_Node_Str");
  aXY=attribute("String_Node_Str");
  aUV=attribute("String_Node_Str");
  Quad.setupIndices();
  Quad.bindIndices();
}
Program: 164112
Project: 164112
Buggy source:
protected void step(){
  if (requestedReset) {
    requestedReset=false;
    try {
      requestedScene=sceneClass.newInstance();
      switchScene();
    }
 catch (    InstantiationException|IllegalAccessException e) {
      e.printStackTrace();
    }
  }
  update();
}

Fixed version (ground truth):
protected void step(){
  if (requestedReset) {
    requestedReset=false;
    try {
      requestedScene=sceneClass.newInstance();
      switchScene();
    }
 catch (    InstantiationException e) {
      e.printStackTrace();
    }
catch (    IllegalAccessException e) {
      e.printStackTrace();
    }
  }
  update();
}
Program: 164115
Project: 164115
Buggy source:
protected boolean getCloser(int target){
  if (rooted || target == pos) {
    return false;
  }
  boolean newPath=false;
  if (path == null || path.isEmpty())   newPath=true;
 else   if (path.getLast() != target) {
    if (Dungeon.level.adjacent(target,path.getLast())) {
      int last=path.removeLast();
      if (path.isEmpty()) {
        if (Dungeon.level.adjacent(target,pos)) {
          path.add(target);
        }
 else {
          path.add(last);
          path.add(target);
        }
      }
 else       if (!path.isEmpty()) {
        if (path.getLast() == target) {
        }
 else         if (Dungeon.level.adjacent(target,path.getLast())) {
          path.add(target);
        }
 else {
          path.add(last);
          path.add(target);
        }
      }
    }
 else {
      newPath=true;
    }
  }
  if (!newPath) {
    for (int i=0; i < Math.min(path.size(),4); i++) {
      int cell=path.get(i);
      if (!Level.passable[cell] || ((i != path.size() - 1) && Dungeon.visible[cell] && Actor.findChar(cell) != null)) {
        newPath=true;
        break;
      }
    }
  }
  if (newPath) {
    path=Dungeon.findPath(this,pos,target,Level.passable,Level.fieldOfView);
  }
  if (path == null)   return false;
  int step=path.removeFirst();
  if (step != -1) {
    move(step);
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
protected boolean getCloser(int target){
  if (rooted || target == pos) {
    return false;
  }
  int step=-1;
  if (Dungeon.level.adjacent(pos,target)) {
    path=null;
    if (Actor.findChar(target) == null && Level.passable[target]) {
      step=target;
    }
  }
 else {
    boolean newPath=false;
    if (path == null || path.isEmpty())     newPath=true;
 else     if (path.getLast() != target) {
      if (Dungeon.level.adjacent(target,path.getLast())) {
        int last=path.removeLast();
        if (path.isEmpty()) {
          if (Dungeon.level.adjacent(target,pos)) {
            path.add(target);
          }
 else {
            path.add(last);
            path.add(target);
          }
        }
 else         if (!path.isEmpty()) {
          if (path.getLast() == target) {
          }
 else           if (Dungeon.level.adjacent(target,path.getLast())) {
            path.add(target);
          }
 else {
            path.add(last);
            path.add(target);
          }
        }
      }
 else {
        newPath=true;
      }
    }
    if (!newPath) {
      for (int i=0; i < Math.min(path.size(),4); i++) {
        int cell=path.get(i);
        if (!Level.passable[cell] || ((i != path.size() - 1) && Dungeon.visible[cell] && Actor.findChar(cell) != null)) {
          newPath=true;
          break;
        }
      }
    }
    if (newPath) {
      path=Dungeon.findPath(this,pos,target,Level.passable,Level.fieldOfView);
    }
    if (path == null)     return false;
    step=path.removeFirst();
  }
  if (step != -1) {
    move(step);
    return true;
  }
 else {
    return false;
  }
}
Program: 164116
Project: 164116
Buggy source:
@Override protected boolean canAttack(Char enemy){
  if (beamCooldown == 0) {
    Ballistica aim=new Ballistica(pos,enemy.pos,Ballistica.STOP_TERRAIN);
    if (enemy.invisible == 0 && Level.fieldOfView[enemy.pos] && aim.subPath(1,aim.dist).contains(enemy.pos)) {
      beam=aim;
      return true;
    }
 else     return beamCharged;
  }
 else   return super.canAttack(enemy);
}

Fixed version (ground truth):
@Override protected boolean canAttack(Char enemy){
  if (beamCooldown == 0) {
    Ballistica aim=new Ballistica(pos,enemy.pos,Ballistica.STOP_TERRAIN);
    if (enemy.invisible == 0 && Level.fieldOfView[enemy.pos] && aim.subPath(1,aim.dist).contains(enemy.pos)) {
      beam=aim;
      beamTarget=aim.collisionPos;
      return true;
    }
 else     return beamCharged;
  }
 else   return super.canAttack(enemy);
}
Program: 164117
Project: 164117
Buggy source:
public void deathGaze(){
  if (!beamCharged || beamCooldown > 0 || beam == null)   return;
  beamCharged=false;
  beamCooldown=Random.IntRange(3,6);
  boolean terrainAffected=false;
  for (  int pos : beam.subPath(1,beam.dist)) {
    if (Level.flamable[pos]) {
      Dungeon.level.destroy(pos);
      GameScene.updateMap(pos);
      terrainAffected=true;
    }
    Char ch=Actor.findChar(pos);
    if (ch == null) {
      continue;
    }
    if (hit(this,ch,true)) {
      ch.damage(Random.NormalIntRange(30,50),this);
      if (Dungeon.visible[pos]) {
        ch.sprite.flash();
        CellEmitter.center(pos).burst(PurpleParticle.BURST,Random.IntRange(1,2));
      }
      if (!ch.isAlive() && ch == Dungeon.hero) {
        Dungeon.fail(getClass());
        GLog.n(Messages.get(this,"String_Node_Str"));
      }
    }
 else {
      ch.sprite.showStatus(CharSprite.NEUTRAL,ch.defenseVerb());
    }
  }
  if (terrainAffected) {
    Dungeon.observe();
  }
  beam=null;
  sprite.idle();
}

Fixed version (ground truth):
public void deathGaze(){
  if (!beamCharged || beamCooldown > 0 || beam == null)   return;
  beamCharged=false;
  beamCooldown=Random.IntRange(3,6);
  boolean terrainAffected=false;
  for (  int pos : beam.subPath(1,beam.dist)) {
    if (Level.flamable[pos]) {
      Dungeon.level.destroy(pos);
      GameScene.updateMap(pos);
      terrainAffected=true;
    }
    Char ch=Actor.findChar(pos);
    if (ch == null) {
      continue;
    }
    if (hit(this,ch,true)) {
      ch.damage(Random.NormalIntRange(30,50),this);
      if (Dungeon.visible[pos]) {
        ch.sprite.flash();
        CellEmitter.center(pos).burst(PurpleParticle.BURST,Random.IntRange(1,2));
      }
      if (!ch.isAlive() && ch == Dungeon.hero) {
        Dungeon.fail(getClass());
        GLog.n(Messages.get(this,"String_Node_Str"));
      }
    }
 else {
      ch.sprite.showStatus(CharSprite.NEUTRAL,ch.defenseVerb());
    }
  }
  if (terrainAffected) {
    Dungeon.observe();
  }
  beam=null;
  beamTarget=-1;
  sprite.idle();
}
Program: 164118
Project: 164118
Buggy source:
@Override public void storeInBundle(Bundle bundle){
  super.storeInBundle(bundle);
  if (beam != null)   bundle.put(BEAM_TARGET,beam.collisionPos);
  bundle.put(BEAM_COOLDOWN,beamCooldown);
  bundle.put(BEAM_CHARGED,beamCharged);
}

Fixed version (ground truth):
@Override public void storeInBundle(Bundle bundle){
  super.storeInBundle(bundle);
  bundle.put(BEAM_TARGET,beamTarget);
  bundle.put(BEAM_COOLDOWN,beamCooldown);
  bundle.put(BEAM_CHARGED,beamCharged);
}
Program: 164119
Project: 164119
Buggy source:
@Override public void restoreFromBundle(Bundle bundle){
  super.restoreFromBundle(bundle);
  if (bundle.contains(BEAM_TARGET))   beam=new Ballistica(pos,bundle.getInt(BEAM_TARGET),Ballistica.STOP_TERRAIN);
  beamCooldown=bundle.getInt(BEAM_COOLDOWN);
  beamCharged=bundle.getBoolean(BEAM_CHARGED);
}

Fixed version (ground truth):
@Override public void restoreFromBundle(Bundle bundle){
  super.restoreFromBundle(bundle);
  if (bundle.contains(BEAM_TARGET))   beamTarget=bundle.getInt(BEAM_TARGET);
  beamCooldown=bundle.getInt(BEAM_COOLDOWN);
  beamCharged=bundle.getBoolean(BEAM_CHARGED);
}
Program: 164120
Project: 164120
Buggy source:
public void measure(){
  width=0;
  height=0;
  if (text == null) {
    text="String_Node_Str";
  }
  int length=text.length();
  for (int i=0; i < length; i++) {
    RectF rect=font.get(text.charAt(i));
    float w=font.width(rect);
    float h=font.height(rect);
    width+=w + font.tracking;
    if (h > height) {
      height=h;
    }
  }
  if (length > 0) {
    width-=font.tracking;
  }
}

Fixed version (ground truth):
public synchronized void measure(){
  width=0;
  height=0;
  if (text == null) {
    text="String_Node_Str";
  }
  int length=text.length();
  for (int i=0; i < length; i++) {
    RectF rect=font.get(text.charAt(i));
    float w=font.width(rect);
    float h=font.height(rect);
    width+=w + font.tracking;
    if (h > height) {
      height=h;
    }
  }
  if (length > 0) {
    width-=font.tracking;
  }
}
Program: 164121
Project: 164121
Buggy source:
protected void updateVertices(){
  width=0;
  height=0;
  if (text == null) {
    text="String_Node_Str";
  }
  quads=Quad.createSet(text.length());
  realLength=0;
  int length=text.length();
  for (int i=0; i < length; i++) {
    RectF rect=font.get(text.charAt(i));
    if (rect == null) {
      rect=null;
    }
    float w=font.width(rect);
    float h=font.height(rect);
    vertices[0]=width;
    vertices[1]=0;
    vertices[2]=rect.left;
    vertices[3]=rect.top;
    vertices[4]=width + w;
    vertices[5]=0;
    vertices[6]=rect.right;
    vertices[7]=rect.top;
    vertices[8]=width + w;
    vertices[9]=h;
    vertices[10]=rect.right;
    vertices[11]=rect.bottom;
    vertices[12]=width;
    vertices[13]=h;
    vertices[14]=rect.left;
    vertices[15]=rect.bottom;
    quads.put(vertices);
    realLength++;
    width+=w + font.tracking;
    if (h > height) {
      height=h;
    }
  }
  if (length > 0) {
    width-=font.tracking;
  }
  dirty=false;
}

Fixed version (ground truth):
protected synchronized void updateVertices(){
  width=0;
  height=0;
  if (text == null) {
    text="String_Node_Str";
  }
  quads=Quad.createSet(text.length());
  realLength=0;
  int length=text.length();
  for (int i=0; i < length; i++) {
    RectF rect=font.get(text.charAt(i));
    if (rect == null) {
      rect=null;
    }
    float w=font.width(rect);
    float h=font.height(rect);
    vertices[0]=width;
    vertices[1]=0;
    vertices[2]=rect.left;
    vertices[3]=rect.top;
    vertices[4]=width + w;
    vertices[5]=0;
    vertices[6]=rect.right;
    vertices[7]=rect.top;
    vertices[8]=width + w;
    vertices[9]=h;
    vertices[10]=rect.right;
    vertices[11]=rect.bottom;
    vertices[12]=width;
    vertices[13]=h;
    vertices[14]=rect.left;
    vertices[15]=rect.bottom;
    quads.put(vertices);
    realLength++;
    width+=w + font.tracking;
    if (h > height) {
      height=h;
    }
  }
  if (length > 0) {
    width-=font.tracking;
  }
  dirty=false;
}
Program: 164122
Project: 164122
Buggy source:
public void text(String str){
  text=str;
  dirty=true;
}

Fixed version (ground truth):
public synchronized void text(String str){
  text=str;
  dirty=true;
}
Program: 164123
Project: 164123
Buggy source:
public void font(Font value){
  font=value;
}

Fixed version (ground truth):
public synchronized void font(Font value){
  font=value;
}
Program: 164124
Project: 164124
Buggy source:
public void place(int p){
  point(worldToCamera(p));
}

Fixed version (ground truth):
public void place(int p){
  if (Dungeon.level != null)   point(worldToCamera(p));
}
Program: 164125
Project: 164125
Buggy source:
public synchronized void updateMap(){
  updated.set(0,0,mapWidth,mapHeight);
}

Fixed version (ground truth):
public synchronized void updateMap(){
  updated.set(0,0,mapWidth,mapHeight);
  if (buffer != null) {
    buffer.delete();
  }
  buffer=null;
  camX=null;
}
Program: 164126
Project: 164126
Buggy source:
public void map(int[] data,int cols){
  this.data=data;
  mapWidth=cols;
  mapHeight=data.length / cols;
  size=mapWidth * mapHeight;
  bufferPositions=new short[size];
  for (int i=0; i < bufferPositions.length; i++)   bufferPositions[i]=-1;
  bufferLength=0;
  width=cellW * mapWidth;
  height=cellH * mapHeight;
  quads=Quad.createSet(size);
  updated.set(0,0,mapWidth,mapHeight);
}

Fixed version (ground truth):
public void map(int[] data,int cols){
  this.data=data;
  mapWidth=cols;
  mapHeight=data.length / cols;
  size=mapWidth * mapHeight;
  bufferPositions=new short[size];
  for (int i=0; i < bufferPositions.length; i++)   bufferPositions[i]=-1;
  bufferLength=0;
  width=cellW * mapWidth;
  height=cellH * mapHeight;
  quads=Quad.createSet(size);
  updateMap();
}
Program: 164127
Project: 164127
Buggy source:
private void changeMap(int[] map){
  this.map=map.clone();
  GameScene.resetMap();
  buildFlagMaps();
  cleanWalls();
  exit=entrance=0;
  for (int i=0; i < length(); i++)   if (map[i] == Terrain.ENTRANCE)   entrance=i;
 else   if (map[i] == Terrain.EXIT)   exit=i;
  visited=mapped=new boolean[length()];
  for (  Blob blob : blobs.values()) {
    blob.fullyClear();
  }
  addVisuals();
  resetTraps();
  Dungeon.observe();
}

Fixed version (ground truth):
private void changeMap(int[] map){
  this.map=map.clone();
  buildFlagMaps();
  cleanWalls();
  exit=entrance=0;
  for (int i=0; i < length(); i++)   if (map[i] == Terrain.ENTRANCE)   entrance=i;
 else   if (map[i] == Terrain.EXIT)   exit=i;
  visited=mapped=new boolean[length()];
  for (  Blob blob : blobs.values()) {
    blob.fullyClear();
  }
  addVisuals();
  resetTraps();
  GameScene.resetMap();
  Dungeon.observe();
}
Program: 164129
Project: 164129
Buggy source:
public void map(int[] data,int cols){
  this.data=data;
  mapWidth=cols;
  mapHeight=data.length / cols;
  size=mapWidth * mapHeight;
  bufferPositions=new short[size];
  for (int i=0; i < bufferPositions.length; i++)   bufferPositions[i]=-1;
  width=cellW * mapWidth;
  height=cellH * mapHeight;
  quads=Quad.createSet(size);
  updated.set(0,0,mapWidth,mapHeight);
}

Fixed version (ground truth):
public void map(int[] data,int cols){
  this.data=data;
  mapWidth=cols;
  mapHeight=data.length / cols;
  size=mapWidth * mapHeight;
  bufferPositions=new short[size];
  for (int i=0; i < bufferPositions.length; i++)   bufferPositions[i]=-1;
  bufferLength=0;
  width=cellW * mapWidth;
  height=cellH * mapHeight;
  quads=Quad.createSet(size);
  updated.set(0,0,mapWidth,mapHeight);
}
Program: 164130
Project: 164130
Buggy source:
public static boolean spawn(PrisonLevel level,Room room,Collection<Room> rooms){
  if (!spawned && (type != 0 || (Dungeon.depth > 6 && Random.Int(10 - Dungeon.depth) == 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=Dungeon.level.pointToCell(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.cursed=false;
      wand1.identify();
      wand1.upgrade();
      do {
        wand2=(Wand)Generator.random(Generator.Category.WAND);
      }
 while (wand2.getClass().equals(wand1.getClass()));
      wand2.cursed=false;
      wand2.identify();
      wand2.upgrade();
      return true;
    }
 else {
      return false;
    }
  }
 else {
    return true;
  }
}

Fixed version (ground truth):
public static boolean spawn(PrisonLevel level,Room room,Collection<Room> rooms){
  if (!spawned && (type != 0 || (Dungeon.depth > 6 && Random.Int(10 - Dungeon.depth) == 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=level.pointToCell(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.cursed=false;
      wand1.identify();
      wand1.upgrade();
      do {
        wand2=(Wand)Generator.random(Generator.Category.WAND);
      }
 while (wand2.getClass().equals(wand1.getClass()));
      wand2.cursed=false;
      wand2.identify();
      wand2.upgrade();
      return true;
    }
 else {
      return false;
    }
  }
 else {
    return true;
  }
}
Program: 164131
Project: 164131
Buggy source:
public void level(int value){
  if (level < value) {
    level=value;
  }
}

Fixed version (ground truth):
public void level(int value){
  if (level < value) {
    level=value;
    pos=target.pos;
  }
}
Program: 164132
Project: 164132
Buggy source:
@Override public void activate(){
  Char ch=Actor.findChar(pos);
  if (ch == Dungeon.hero) {
    Buff.affect(ch,Armor.class).level=ch.HT;
  }
  if (Dungeon.visible[pos]) {
    CellEmitter.bottom(pos).start(EarthParticle.FACTORY,0.05f,8);
    Camera.main.shake(1,0.4f);
  }
}

Fixed version (ground truth):
@Override public void activate(){
  Char ch=Actor.findChar(pos);
  if (ch == Dungeon.hero) {
    Buff.affect(ch,Armor.class).level(ch.HT);
  }
  if (Dungeon.visible[pos]) {
    CellEmitter.bottom(pos).start(EarthParticle.FACTORY,0.05f,8);
    Camera.main.shake(1,0.4f);
  }
}
Program: 164133
Project: 164133
Buggy source:
protected boolean act(){
  PathFinder.buildDistanceMap(pos,BArray.not(Level.solid,null),2);
  for (int i=0; i < PathFinder.distance.length; i++) {
    if (PathFinder.distance[i] < Integer.MAX_VALUE)     if (Dungeon.level.insideMap(i) && Actor.findChar(i) == null && !(Level.pit[i])) {
      Sheep sheep=new Sheep();
      sheep.lifespan=2 + Random.Int(Dungeon.depth + 10);
      sheep.pos=i;
      GameScene.add(sheep);
    }
    CellEmitter.get(i).burst(Speck.factory(Speck.WOOL),4);
  }
  Sample.INSTANCE.play(Assets.SND_PUFF);
  Actor.remove(this);
  return true;
}

Fixed version (ground truth):
protected boolean act(){
  PathFinder.buildDistanceMap(pos,BArray.not(Level.solid,null),2);
  for (int i=0; i < PathFinder.distance.length; i++) {
    if (PathFinder.distance[i] < Integer.MAX_VALUE)     if (Dungeon.level.insideMap(i) && Actor.findChar(i) == null && !(Level.pit[i])) {
      Sheep sheep=new Sheep();
      sheep.lifespan=2 + Random.Int(Dungeon.depth + 10);
      sheep.pos=i;
      GameScene.add(sheep);
      CellEmitter.get(i).burst(Speck.factory(Speck.WOOL),4);
    }
  }
  Sample.INSTANCE.play(Assets.SND_PUFF);
  Actor.remove(this);
  return true;
}
Program: 164134
Project: 164134
Buggy source:
@Override public void activate(){
  Actor.add(new Actor(){
{
      actPriority=3;
    }
    protected boolean act(){
      PathFinder.buildDistanceMap(pos,BArray.not(Level.solid,null),2);
      for (int i=0; i < PathFinder.distance.length; i++) {
        if (PathFinder.distance[i] < Integer.MAX_VALUE)         if (Dungeon.level.insideMap(i) && Actor.findChar(i) == null && !(Level.pit[i])) {
          Sheep sheep=new Sheep();
          sheep.lifespan=2 + Random.Int(Dungeon.depth + 10);
          sheep.pos=i;
          GameScene.add(sheep);
        }
        CellEmitter.get(i).burst(Speck.factory(Speck.WOOL),4);
      }
      Sample.INSTANCE.play(Assets.SND_PUFF);
      Actor.remove(this);
      return true;
    }
  }
);
}

Fixed version (ground truth):
@Override public void activate(){
  Actor.add(new Actor(){
{
      actPriority=3;
    }
    protected boolean act(){
      PathFinder.buildDistanceMap(pos,BArray.not(Level.solid,null),2);
      for (int i=0; i < PathFinder.distance.length; i++) {
        if (PathFinder.distance[i] < Integer.MAX_VALUE)         if (Dungeon.level.insideMap(i) && Actor.findChar(i) == null && !(Level.pit[i])) {
          Sheep sheep=new Sheep();
          sheep.lifespan=2 + Random.Int(Dungeon.depth + 10);
          sheep.pos=i;
          GameScene.add(sheep);
          CellEmitter.get(i).burst(Speck.factory(Speck.WOOL),4);
        }
      }
      Sample.INSTANCE.play(Assets.SND_PUFF);
      Actor.remove(this);
      return true;
    }
  }
);
}
Program: 164135
Project: 164135
Buggy source:
@Override protected Char chooseEnemy(){
  if (beamCharged)   return enemy;
  return super.chooseEnemy();
}

Fixed version (ground truth):
@Override protected Char chooseEnemy(){
  if (beamCharged && enemy != null)   return enemy;
  return super.chooseEnemy();
}
Program: 164136
Project: 164136
Buggy source:
@Override public boolean act(boolean enemyInFOV,boolean justAlerted){
  if (beamCharged)   enemyInFOV=true;
  return super.act(enemyInFOV,justAlerted);
}

Fixed version (ground truth):
@Override public boolean act(boolean enemyInFOV,boolean justAlerted){
  if (beamCharged && enemy != null)   enemyInFOV=true;
  return super.act(enemyInFOV,justAlerted);
}
Program: 164137
Project: 164137
Buggy source:
@Override public void activate(){
  InterlevelScene.returnDepth=Dungeon.depth;
  for (  Item item : Dungeon.hero.belongings.backpack.items.toArray(new Item[0])) {
    if (item instanceof Key && ((Key)item).depth == Dungeon.depth) {
      item.detachAll(Dungeon.hero.belongings.backpack);
    }
  }
  InterlevelScene.mode=InterlevelScene.Mode.RESET;
  Game.switchScene(InterlevelScene.class);
}

Fixed version (ground truth):
@Override public void activate(){
  InterlevelScene.returnDepth=Dungeon.depth;
  Belongings belongings=Dungeon.hero.belongings;
  belongings.ironKeys[Dungeon.depth]=0;
  belongings.specialKeys[Dungeon.depth]=0;
  for (  Item i : belongings) {
    if (i instanceof LloydsBeacon && ((LloydsBeacon)i).returnDepth == Dungeon.depth)     ((LloydsBeacon)i).returnDepth=-1;
  }
  InterlevelScene.mode=InterlevelScene.Mode.RESET;
  Game.switchScene(InterlevelScene.class);
}
Program: 164138
Project: 164138
Buggy source:
private void updateVersion(int previousVersion){
  if (previousVersion < 108) {
    Rankings.INSTANCE.load();
    for (    Rankings.Record rec : Rankings.INSTANCE.records) {
      try {
        Dungeon.loadGame(rec.gameFile,false);
        rec.gameID=rec.gameFile.replaceAll("String_Node_Str","String_Node_Str");
        Rankings.INSTANCE.saveGameData(rec);
      }
 catch (      Exception e) {
        rec.gameID=rec.gameFile.replaceAll("String_Node_Str","String_Node_Str");
        rec.gameData=null;
      }
      String file=rec.gameFile;
      rec.gameFile="String_Node_Str";
      Game.instance.deleteFile(file);
    }
    Rankings.INSTANCE.save();
  }
  ShatteredPixelDungeon.version(ShatteredPixelDungeon.versionCode);
}

Fixed version (ground truth):
private void updateVersion(int previousVersion){
  if (previousVersion <= 114) {
    Rankings.INSTANCE.load();
    for (    Rankings.Record rec : Rankings.INSTANCE.records) {
      if (rec.gameFile != null) {
        try {
          Dungeon.loadGame(rec.gameFile,false);
          rec.gameID=rec.gameFile.replaceAll("String_Node_Str","String_Node_Str");
          Rankings.INSTANCE.saveGameData(rec);
        }
 catch (        Exception e) {
          rec.gameID=rec.gameFile.replaceAll("String_Node_Str","String_Node_Str");
          rec.gameData=null;
        }
        String file=rec.gameFile;
        rec.gameFile="String_Node_Str";
        Game.instance.deleteFile(file);
      }
 else       if (rec.gameID == null) {
        rec.gameID=UUID.randomUUID().toString();
      }
    }
    Rankings.INSTANCE.save();
  }
  ShatteredPixelDungeon.version(ShatteredPixelDungeon.versionCode);
}
Program: 164139
Project: 164139
Buggy source:
public void item(Item item){
  if (this.item == item) {
    updateText();
    return;
  }
  this.item=item;
  if (item == null) {
    active=false;
    icon.visible(false);
    updateText();
  }
 else {
    active=true;
    icon.visible(true);
    icon.view(item);
    updateText();
  }
}

Fixed version (ground truth):
public void item(Item item){
  if (this.item == item) {
    updateText();
    return;
  }
  this.item=item;
  if (item == null) {
    enable(false);
    icon.visible(false);
    updateText();
  }
 else {
    enable(true);
    icon.visible(true);
    icon.view(item);
    updateText();
  }
}
Program: 164140
Project: 164140
Buggy source:
@Override public int defenseProc(Char enemy,int damage){
  if (!enemySeen && enemy == Dungeon.hero && Dungeon.hero.canSurpriseAttack()) {
    if (((Hero)enemy).subClass == HeroSubClass.ASSASSIN) {
      damage*=1.25f;
      Wound.hit(this);
    }
 else {
      Surprise.hit(this);
    }
  }
  if (enemy.buff(Corruption.class) != null) {
    aggro(enemy);
    target=enemy.pos;
    if (state == SLEEPING || state == WANDERING)     state=HUNTING;
  }
  if (buff(SoulMark.class) != null) {
    int restoration=Math.max(damage,HP);
    Dungeon.hero.buff(Hunger.class).satisfy(restoration * 0.5f);
    Dungeon.hero.HP=(int)Math.ceil(Math.min(Dungeon.hero.HT,Dungeon.hero.HP + (restoration * 0.25f)));
    Dungeon.hero.sprite.emitter().burst(Speck.factory(Speck.HEALING),1);
  }
  return damage;
}

Fixed version (ground truth):
@Override public int defenseProc(Char enemy,int damage){
  if (!enemySeen && enemy == Dungeon.hero && Dungeon.hero.canSurpriseAttack()) {
    if (((Hero)enemy).subClass == HeroSubClass.ASSASSIN) {
      damage*=1.25f;
      Wound.hit(this);
    }
 else {
      Surprise.hit(this);
    }
  }
  if (enemy.buff(Corruption.class) != null) {
    aggro(enemy);
    target=enemy.pos;
    if (state == SLEEPING || state == WANDERING)     state=HUNTING;
  }
  if (buff(SoulMark.class) != null) {
    int restoration=Math.min(damage,HP);
    Dungeon.hero.buff(Hunger.class).satisfy(restoration * 0.5f);
    Dungeon.hero.HP=(int)Math.ceil(Math.min(Dungeon.hero.HT,Dungeon.hero.HP + (restoration * 0.25f)));
    Dungeon.hero.sprite.emitter().burst(Speck.factory(Speck.HEALING),1);
  }
  return damage;
}
Program: 164141
Project: 164141
Buggy source:
@Override public int drRoll(){
  int dr=0;
  Barkskin bark=buff(Barkskin.class);
  if (belongings.armor != null) {
    dr+=Random.NormalIntRange(belongings.armor.DRMin(),belongings.armor.DRMax());
    if (STR() < belongings.armor.STRReq()) {
      dr-=2 * (belongings.armor.STRReq() - STR());
      dr=Math.max(dr,0);
    }
  }
  if (belongings.weapon != null)   dr+=Math.max(belongings.weapon.defenceFactor(this),0);
  if (bark != null)   dr+=bark.level();
  return dr;
}

Fixed version (ground truth):
@Override public int drRoll(){
  int dr=0;
  Barkskin bark=buff(Barkskin.class);
  if (belongings.armor != null) {
    dr+=Random.NormalIntRange(belongings.armor.DRMin(),belongings.armor.DRMax());
    if (STR() < belongings.armor.STRReq()) {
      dr-=2 * (belongings.armor.STRReq() - STR());
      dr=Math.max(dr,0);
    }
  }
  if (belongings.weapon != null)   dr+=Random.NormalIntRange(0,belongings.weapon.defenseFactor(this));
  if (bark != null)   dr+=Random.NormalIntRange(0,bark.level());
  return dr;
}
Program: 164142
Project: 164142
Buggy source:
@Override public int drRoll(){
  return Random.NormalIntRange(0,Dungeon.depth + weapon.defenceFactor(null));
}

Fixed version (ground truth):
@Override public int drRoll(){
  return Random.NormalIntRange(0,Dungeon.depth + weapon.defenseFactor(null));
}
Program: 164143
Project: 164143
Buggy source:
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();
}

Fixed version (ground truth):
public void call(){
  enemy.pos=newPosFinal;
  Dungeon.level.press(newPosFinal,enemy);
  Cripple.prolong(enemy,Cripple.class,4f);
  if (enemy == Dungeon.hero) {
    Dungeon.hero.interrupt();
    Dungeon.observe();
  }
}
Program: 164144
Project: 164144
Buggy source:
private boolean chain(int target){
  if (chainsUsed || enemy.properties().contains(Property.IMMOVABLE))   return false;
  Ballistica chain=new Ballistica(pos,target,Ballistica.PROJECTILE);
  if (chain.collisionPos != enemy.pos || chain.path.size() < 2 || 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(Messages.get(this,"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;
}

Fixed version (ground truth):
private boolean chain(int target){
  if (chainsUsed || enemy.properties().contains(Property.IMMOVABLE))   return false;
  Ballistica chain=new Ballistica(pos,target,Ballistica.PROJECTILE);
  if (chain.collisionPos != enemy.pos || chain.path.size() < 2 || 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(Messages.get(this,"String_Node_Str"));
      sprite.parent.add(new Chains(pos,enemy.pos,new Callback(){
        public void call(){
          Actor.addDelayed(new Pushing(enemy,enemy.pos,newPosFinal,new Callback(){
            public void call(){
              enemy.pos=newPosFinal;
              Dungeon.level.press(newPosFinal,enemy);
              Cripple.prolong(enemy,Cripple.class,4f);
              if (enemy == Dungeon.hero) {
                Dungeon.hero.interrupt();
                Dungeon.observe();
              }
            }
          }
),-1);
          next();
        }
      }
));
    }
  }
  chainsUsed=true;
  return true;
}
Program: 164145
Project: 164145
Buggy source:
public ItemSprite view(int image,Glowing glowing){
  if (this.emitter != null)   this.emitter.on=false;
  emitter=null;
  frame(film.get(image));
  if ((this.glowing=glowing) == null) {
    resetColor();
  }
  return this;
}

Fixed version (ground truth):
public ItemSprite view(int image,Glowing glowing){
  if (this.emitter != null)   this.emitter.killAndErase();
  emitter=null;
  frame(film.get(image));
  if ((this.glowing=glowing) == null) {
    resetColor();
  }
  return this;
}
Program: 164146
Project: 164146
Buggy source:
public void item(Item item){
  if (bottomRightIcon != null) {
    remove(bottomRightIcon);
    bottomRightIcon=null;
  }
  if (item == null) {
    active=false;
    topLeft.visible=topRight.visible=bottomRight.visible=false;
    icon.visible(false);
  }
 else {
    active=true;
    topLeft.visible=topRight.visible=bottomRight.visible=true;
    icon.visible(true);
    icon.view(item);
    topLeft.text(item.status());
    boolean isArmor=item instanceof Armor;
    boolean isWeapon=item instanceof Weapon;
    if (isArmor || isWeapon) {
      if (item.levelKnown || (isWeapon && !(item instanceof MeleeWeapon))) {
        int str=isArmor ? ((Armor)item).STRReq() : ((Weapon)item).STRReq();
        topRight.text(Messages.format(TXT_STRENGTH,str));
        if (str > Dungeon.hero.STR()) {
          topRight.hardlight(DEGRADED);
        }
 else {
          topRight.resetColor();
        }
      }
 else {
        topRight.text(Messages.format(TXT_TYPICAL_STR,isArmor ? ((Armor)item).STRReq(0) : ((Weapon)item).STRReq(0)));
        topRight.hardlight(WARNING);
      }
      topRight.measure();
    }
 else     if (item instanceof Key && !(item instanceof SkeletonKey)) {
      topRight.text(Messages.format(TXT_KEY_DEPTH,((Key)item).depth));
      topRight.measure();
    }
 else {
      topRight.text(null);
    }
    int level=item.visiblyUpgraded();
    if (level != 0) {
      bottomRight.text(item.levelKnown ? Messages.format(TXT_LEVEL,level) : TXT_CURSED);
      bottomRight.measure();
      bottomRight.hardlight(level > 0 ? UPGRADED : DEGRADED);
    }
 else     if (item instanceof Scroll || item instanceof Potion) {
      bottomRight.text(null);
      Integer iconInt;
      if (item instanceof Scroll) {
        iconInt=((Scroll)item).initials();
      }
 else {
        iconInt=((Potion)item).initials();
      }
      if (iconInt != null && iconVisible) {
        bottomRightIcon=new Image(Assets.CONS_ICONS);
        int left=iconInt * 7;
        int top=item instanceof Potion ? 0 : 8;
        bottomRightIcon.frame(left,top,7,8);
        add(bottomRightIcon);
      }
    }
 else {
      bottomRight.text(null);
    }
    layout();
  }
}

Fixed version (ground truth):
public void item(Item item){
  if (this.item == item) {
    updateText();
    return;
  }
  this.item=item;
  if (item == null) {
    active=false;
    icon.visible(false);
    updateText();
  }
 else {
    active=true;
    icon.visible(true);
    icon.view(item);
    updateText();
  }
}
Program: 164147
Project: 164147
Buggy source:
@Override public boolean doEquip(Hero hero){
  if (super.doEquip(hero)) {
    hero.HT+=level() * 5;
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
@Override public boolean doEquip(Hero hero){
  if (super.doEquip(hero)) {
    hero.HT+=level() * 5;
    hero.HP=Math.min(hero.HP,hero.HT);
    return true;
  }
 else {
    return false;
  }
}
Program: 164148
Project: 164148
Buggy source:
@Override public boolean isAlive(){
  return HP > 0 || Dungeon.level.mobs.contains(this);
}

Fixed version (ground truth):
@Override public boolean isAlive(){
  return Dungeon.level.mobs.contains(this);
}
Program: 164149
Project: 164149
Buggy source:
@Override public void damage(int dmg,Object src){
  boolean bleeding=(HP * 2 <= HT);
  super.damage(dmg,src);
  if ((HP * 2 <= HT) && !bleeding) {
    BossHealthBar.bleed(true);
    GLog.w(Messages.get(this,"String_Node_Str"));
    sprite.showStatus(CharSprite.NEGATIVE,Messages.get(this,"String_Node_Str"));
    ((GooSprite)sprite).spray(true);
    yell(Messages.get(this,"String_Node_Str"));
    spend(TICK);
  }
  LockedFloor lock=Dungeon.hero.buff(LockedFloor.class);
  if (lock != null)   lock.addTime(dmg * 2);
}

Fixed version (ground truth):
@Override public void damage(int dmg,Object src){
  boolean bleeding=(HP * 2 <= HT);
  super.damage(dmg,src);
  if ((HP * 2 <= HT) && !bleeding) {
    BossHealthBar.bleed(true);
    GLog.w(Messages.get(this,"String_Node_Str"));
    sprite.showStatus(CharSprite.NEGATIVE,Messages.get(this,"String_Node_Str"));
    ((GooSprite)sprite).spray(true);
    yell(Messages.get(this,"String_Node_Str"));
  }
  LockedFloor lock=Dungeon.hero.buff(LockedFloor.class);
  if (lock != null)   lock.addTime(dmg * 2);
}
Program: 164150
Project: 164150
Buggy source:
private boolean chain(int target){
  if (chainsUsed || enemy.properties().contains(Property.IMMOVABLE))   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(Messages.get(this,"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;
}

Fixed version (ground truth):
private boolean chain(int target){
  if (chainsUsed || enemy.properties().contains(Property.IMMOVABLE))   return false;
  Ballistica chain=new Ballistica(pos,target,Ballistica.PROJECTILE);
  if (chain.collisionPos != enemy.pos || chain.path.size() < 2 || 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(Messages.get(this,"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: 164151
Project: 164151
Buggy source:
@Override protected void onClick(){
  if (rec.gameFile.length() > 0) {
    parent.add(new WndRanking(rec.gameFile));
  }
 else {
    parent.add(new WndError(Messages.get(this,"String_Node_Str")));
  }
}

Fixed version (ground truth):
@Override protected void onClick(){
  if (rec.gameFile.length() > 0) {
    parent.add(new WndRanking(rec.gameFile));
  }
 else {
    parent.add(new WndError(Messages.get(RankingsScene.class,"String_Node_Str")));
  }
}
Program: 164152
Project: 164152
Buggy source:
@Override public boolean act(){
  if (target.pos != pos) {
    detach();
  }
  if (count == 5) {
    if (level <= healCurr * .025 * target.HT) {
      target.HP=Math.min(target.HT,target.HP + level);
      target.sprite.emitter().burst(Speck.factory(Speck.HEALING),1);
      detach();
    }
 else {
      target.HP=Math.min(target.HT,target.HP + (int)(healCurr * .025 * target.HT));
      level-=(healCurr * .025 * target.HT);
      if (healCurr < 6)       healCurr++;
      target.sprite.emitter().burst(Speck.factory(Speck.HEALING),1);
      if (target.HP == target.HT && target instanceof Hero) {
        ((Hero)target).resting=false;
      }
    }
    count=1;
  }
 else {
    count++;
  }
  if (level <= 0)   detach();
  spend(STEP);
  return true;
}

Fixed version (ground truth):
@Override public boolean act(){
  if (target.pos != pos) {
    detach();
  }
  if (count == 5) {
    if (level <= healCurr * .025 * target.HT) {
      target.HP=Math.min(target.HT,target.HP + level);
      target.sprite.emitter().burst(Speck.factory(Speck.HEALING),1);
      detach();
    }
 else {
      target.HP=Math.min(target.HT,target.HP + (int)(healCurr * .025 * target.HT));
      level-=(healCurr * .025 * target.HT);
      if (healCurr < 6)       healCurr++;
      target.sprite.emitter().burst(Speck.factory(Speck.HEALING),1);
    }
    if (target.HP == target.HT && target instanceof Hero) {
      ((Hero)target).resting=false;
    }
    count=1;
  }
 else {
    count++;
  }
  if (level <= 0)   detach();
  spend(STEP);
  return true;
}
Program: 164153
Project: 164153
Buggy source:
@Override public void call(){
  if (finalTarget == Dungeon.hero) {
    if (((float)finalTarget.HP / finalTarget.HT) >= 0.9f) {
      finalTarget.damage((finalTarget.HP - 1),trap);
    }
 else {
      finalTarget.damage(finalTarget.HP,trap);
    }
    Sample.INSTANCE.play(Assets.SND_CURSED);
    if (!finalTarget.isAlive()) {
      Dungeon.fail(GrimTrap.class);
      GLog.n(Messages.get(GrimTrap.class,"String_Node_Str"));
    }
  }
 else {
    finalTarget.damage(finalTarget.HP,this);
    Sample.INSTANCE.play(Assets.SND_BURNING);
  }
  finalTarget.sprite.emitter().burst(ShadowParticle.UP,10);
  if (!finalTarget.isAlive())   finalTarget.next();
}

Fixed version (ground truth):
@Override public void call(){
  if (!finalTarget.isAlive())   return;
  if (finalTarget == Dungeon.hero) {
    if (((float)finalTarget.HP / finalTarget.HT) >= 0.9f) {
      finalTarget.damage((finalTarget.HP - 1),trap);
    }
 else {
      finalTarget.damage(finalTarget.HP,trap);
    }
    Sample.INSTANCE.play(Assets.SND_CURSED);
    if (!finalTarget.isAlive()) {
      Dungeon.fail(GrimTrap.class);
      GLog.n(Messages.get(GrimTrap.class,"String_Node_Str"));
    }
  }
 else {
    finalTarget.damage(finalTarget.HP,this);
    Sample.INSTANCE.play(Assets.SND_BURNING);
  }
  finalTarget.sprite.emitter().burst(ShadowParticle.UP,10);
  if (!finalTarget.isAlive())   finalTarget.next();
}