Program: 166695
Project: 166695
Buggy source:
@Override public void update(Effect nextEffect){
  if (active) {
    executed=false;
    if (path == null || path.size() <= 0 && !executed_going) {
      for (int i=0; i < 5; i++) {
        if (executed) {
          break;
        }
      }
    }
    if (needpizza) {
      hungry--;
      if (hungry < 0) {
        hungry=20;
        nar.addInput("String_Node_Str");
      }
    }
    if (Hauto.goalInputPeriodic) {
      lastgoaltime--;
      if (lastgoaltime < 0) {
        lastgoaltime=20;
        nar.addInput(Hauto.lastWish);
      }
    }
  }
  lasttarget=space.target;
  space.current=new PVector(x,y);
  if (nextEffect == null) {
    path=Grid2DSpace.Shortest_Path(space,this,space.current,space.target);
    actions.clear();
    if (path == null) {
      executed_going=false;
    }
{
      if (inventorybag != null) {
        inventorybag.x=(int)space.current.x;
        inventorybag.y=(int)space.current.y;
        inventorybag.cx=(int)space.current.x;
        inventorybag.cy=(int)space.current.y;
      }
      if (inventorybag == null || !(inventorybag instanceof Key)) {
        keyn=-1;
      }
      if (path == null || path.size() <= 1) {
        space.target=null;
        active=true;
        executed_going=false;
        if (!"String_Node_Str".equals(goal)) {
          GridObject obi=null;
          if (!"String_Node_Str".equals(opname)) {
            for (            GridObject gridi : space.objects) {
              if (gridi instanceof LocalGridObject && ((LocalGridObject)gridi).doorname.equals(goal) && ((LocalGridObject)gridi).x == (int)space.current.x && ((LocalGridObject)gridi).y == (int)space.current.y) {
                obi=gridi;
                break;
              }
            }
          }
          if (obi != null || cells.readCells[(int)space.current.x][(int)space.current.y].name.equals(goal)) {
            if ("String_Node_Str".equals(opname)) {
              if (inventorybag != null && inventorybag instanceof LocalGridObject) {
                LocalGridObject ob=(LocalGridObject)inventorybag;
                ob.x=(int)space.current.x;
                ob.y=(int)space.current.y;
                space.objects.add(ob);
              }
              inventorybag=(LocalGridObject)obi;
              if (obi != null) {
                space.objects.remove(obi);
                if (inventorybag.doorname.startsWith("String_Node_Str")) {
                  keyn=Integer.parseInt(inventorybag.doorname.replaceAll("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str"));
                  for (int i=0; i < cells.h; i++) {
                    for (int j=0; j < cells.w; j++) {
                      if (Hauto.doornumber(cells.readCells[i][j]) == keyn) {
                        cells.readCells[i][j].is_solid=false;
                        cells.writeCells[i][j].is_solid=false;
                      }
                    }
                  }
                }
              }
              nar.addInput("String_Node_Str" + goal + "String_Node_Str");
            }
 else             if ("String_Node_Str".equals(opname)) {
              for (int i=0; i < cells.h; i++) {
                for (int j=0; j < cells.w; j++) {
                  if (cells.readCells[i][j].name.equals(goal)) {
                    if (cells.readCells[i][j].logic == Logic.SWITCH) {
                      cells.readCells[i][j].logic=Logic.OFFSWITCH;
                      cells.writeCells[i][j].logic=Logic.OFFSWITCH;
                      cells.readCells[i][j].charge=0.0f;
                      cells.writeCells[i][j].charge=0.0f;
                      if (ComplexFeedback)                       nar.addInput("String_Node_Str" + goal + "String_Node_Str");
                    }
                  }
                }
              }
            }
 else             if ("String_Node_Str".equals(opname)) {
              for (int i=0; i < cells.h; i++) {
                for (int j=0; j < cells.w; j++) {
                  if (cells.readCells[i][j].name.equals(goal)) {
                    if (cells.readCells[i][j].logic == Logic.OFFSWITCH) {
                      cells.readCells[i][j].logic=Logic.SWITCH;
                      cells.writeCells[i][j].logic=Logic.SWITCH;
                      cells.readCells[i][j].charge=1.0f;
                      cells.writeCells[i][j].charge=1.0f;
                      if (ComplexFeedback)                       nar.addInput("String_Node_Str" + goal + "String_Node_Str");
                    }
                  }
                }
              }
            }
            if ("String_Node_Str".equals(opname)) {
              executed_going=false;
              if (!goal.equals(lastgone)) {
                nar.addInput("String_Node_Str" + goal + "String_Node_Str");
              }
              lastgone=goal;
              if (true) {
                int x=0;
                int y=0;
                for (                GridObject obj : space.objects) {
                  if (obj instanceof GridAgent) {
                    GridAgent ag=(GridAgent)obj;
                    x=ag.x;
                    y=ag.y;
                  }
                }
                GridObject ToRemove=null;
                for (                GridObject obj : space.objects) {
                  if (obj instanceof Pizza) {
                    LocalGridObject obo=(LocalGridObject)obj;
                    if (obo.x == x && obo.y == y) {
                      ToRemove=obj;
                    }
                  }
                }
                if (ToRemove != null) {
                  space.objects.remove(ToRemove);
                }
                hungry=20;
                nar.addInput("String_Node_Str");
              }
              active=true;
            }
          }
        }
        opname="String_Node_Str";
      }
 else {
        executed_going=true;
        active=false;
        int numSteps=Math.min(10,path.size());
        float cx=x;
        float cy=y;
        for (int i=1; i < numSteps; i++) {
          PVector next=path.get(i);
          int dx=(int)(next.x - cx);
          int dy=(int)(next.y - cy);
          if ((dx == 0) && (dy == 1)) {
            turn(UP);
            forward(1);
          }
          if ((dx == 1) && (dy == 0)) {
            turn(RIGHT);
            forward(1);
          }
          if ((dx == -1) && (dy == 0)) {
            turn(LEFT);
            forward(1);
          }
          if ((dx == 0) && (dy == -1)) {
            turn(DOWN);
            forward(1);
          }
          cx=next.x;
          cy=next.y;
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override public void update(Effect nextEffect){
  if (active) {
    executed=false;
    if (path == null || path.size() <= 0 && !executed_going) {
      for (int i=0; i < 5; i++) {
        if (executed) {
          break;
        }
      }
    }
    if (needpizza) {
      hungry--;
      if (hungry < 0) {
        hungry=20;
        nar.addInput("String_Node_Str");
      }
    }
    if (Hauto.goalInputPeriodic) {
      lastgoaltime--;
      if (lastgoaltime < 0) {
        lastgoaltime=20;
        nar.addInput(Hauto.lastWish);
      }
    }
  }
  lasttarget=space.target;
  space.current=new PVector(x,y);
  if (nextEffect == null) {
    path=Grid2DSpace.Shortest_Path(space,this,space.current,space.target);
    actions.clear();
    if (path == null) {
      executed_going=false;
    }
{
      if (inventorybag != null) {
        inventorybag.x=(int)space.current.x;
        inventorybag.y=(int)space.current.y;
        inventorybag.cx=(int)space.current.x;
        inventorybag.cy=(int)space.current.y;
      }
      if (inventorybag == null || !(inventorybag instanceof Key)) {
        keyn=-1;
      }
      if (path == null || path.size() <= 1) {
        space.target=null;
        active=true;
        executed_going=false;
        if (!"String_Node_Str".equals(goal)) {
          GridObject obi=null;
          if (!"String_Node_Str".equals(opname)) {
            for (            GridObject gridi : space.objects) {
              if (gridi instanceof LocalGridObject && ((LocalGridObject)gridi).doorname.equals(goal) && ((LocalGridObject)gridi).x == (int)space.current.x && ((LocalGridObject)gridi).y == (int)space.current.y) {
                obi=gridi;
                break;
              }
            }
          }
          if (obi != null || cells.readCells[(int)space.current.x][(int)space.current.y].name.equals(goal)) {
            if ("String_Node_Str".equals(opname)) {
              if (inventorybag != null && inventorybag instanceof LocalGridObject) {
                LocalGridObject ob=(LocalGridObject)inventorybag;
                ob.x=(int)space.current.x;
                ob.y=(int)space.current.y;
                space.objects.add(ob);
              }
              inventorybag=(LocalGridObject)obi;
              if (obi != null) {
                space.objects.remove(obi);
                if (inventorybag.doorname.startsWith("String_Node_Str")) {
                  keyn=Integer.parseInt(inventorybag.doorname.replaceAll("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str"));
                  for (int i=0; i < cells.h; i++) {
                    for (int j=0; j < cells.w; j++) {
                      if (Hauto.doornumber(cells.readCells[i][j]) == keyn) {
                        cells.readCells[i][j].is_solid=false;
                        cells.writeCells[i][j].is_solid=false;
                      }
                    }
                  }
                }
              }
              nar.addInput("String_Node_Str" + goal + "String_Node_Str");
            }
 else             if ("String_Node_Str".equals(opname)) {
              for (int i=0; i < cells.h; i++) {
                for (int j=0; j < cells.w; j++) {
                  if (cells.readCells[i][j].name.equals(goal)) {
                    if (cells.readCells[i][j].logic == Logic.SWITCH) {
                      cells.readCells[i][j].logic=Logic.OFFSWITCH;
                      cells.writeCells[i][j].logic=Logic.OFFSWITCH;
                      cells.readCells[i][j].charge=0.0f;
                      cells.writeCells[i][j].charge=0.0f;
                      if (ComplexFeedback)                       nar.addInput("String_Node_Str" + goal + "String_Node_Str");
                    }
                  }
                }
              }
            }
 else             if ("String_Node_Str".equals(opname)) {
              for (int i=0; i < cells.h; i++) {
                for (int j=0; j < cells.w; j++) {
                  if (cells.readCells[i][j].name.equals(goal)) {
                    if (cells.readCells[i][j].logic == Logic.OFFSWITCH) {
                      cells.readCells[i][j].logic=Logic.SWITCH;
                      cells.writeCells[i][j].logic=Logic.SWITCH;
                      cells.readCells[i][j].charge=1.0f;
                      cells.writeCells[i][j].charge=1.0f;
                      if (ComplexFeedback)                       nar.addInput("String_Node_Str" + goal + "String_Node_Str");
                    }
                  }
                }
              }
            }
            if ("String_Node_Str".equals(opname)) {
              executed_going=false;
              if (!goal.equals(lastgone)) {
                nar.addInput("String_Node_Str" + goal + "String_Node_Str");
              }
              lastgone=goal;
              if (true) {
                int x=0;
                int y=0;
                for (                GridObject obj : space.objects) {
                  if (obj instanceof GridAgent) {
                    GridAgent ag=(GridAgent)obj;
                    x=ag.x;
                    y=ag.y;
                  }
                }
                GridObject ToRemove=null;
                boolean atePizza=false;
                for (                GridObject obj : space.objects) {
                  if (obj instanceof Pizza) {
                    LocalGridObject obo=(LocalGridObject)obj;
                    if (obo.x == x && obo.y == y) {
                      ToRemove=obj;
                      atePizza=true;
                    }
                  }
                }
                if (ToRemove != null) {
                  space.objects.remove(ToRemove);
                }
                if (atePizza) {
                  hungry=20;
                  nar.addInput("String_Node_Str");
                }
              }
              active=true;
            }
          }
        }
        opname="String_Node_Str";
      }
 else {
        executed_going=true;
        active=false;
        int numSteps=Math.min(10,path.size());
        float cx=x;
        float cy=y;
        for (int i=1; i < numSteps; i++) {
          PVector next=path.get(i);
          int dx=(int)(next.x - cx);
          int dy=(int)(next.y - cy);
          if ((dx == 0) && (dy == 1)) {
            turn(UP);
            forward(1);
          }
          if ((dx == 1) && (dy == 0)) {
            turn(RIGHT);
            forward(1);
          }
          if ((dx == -1) && (dy == 0)) {
            turn(LEFT);
            forward(1);
          }
          if ((dx == 0) && (dy == -1)) {
            turn(DOWN);
            forward(1);
          }
          cx=next.x;
          cy=next.y;
        }
      }
    }
  }
}