Program: 166710
Project: 166710
Buggy source:
public TestChamber(NAR nar,boolean showWindow){
  super();
  int w=50;
  int h=50;
  int water_threshold=30;
  Hauto cells=new Hauto(w,h,nar);
  cells.forEach(0,0,w,h,new CellFunction(){
    @Override public void update(    Cell c){
      float smoothness=20f;
      c.material=Material.GrassFloor;
      double n=SimplexNoise.noise(c.state.x / smoothness,c.state.y / smoothness);
      if ((n * 64) > water_threshold) {
        c.material=Material.Water;
      }
      c.setHeight((int)(Math.random() * 24 + 1));
    }
  }
);
  Maze.buildMaze(cells,3,3,23,23);
  space=new Grid2DSpace(cells,nar);
  space.FrameRate=0;
  space.automataPeriod=automataPeriod / gridUpdatePeriod;
  space.agentPeriod=agentPeriod / gridUpdatePeriod;
  TestChamber into=this;
  nar.memory.event.on(Events.FrameEnd.class,new EventObserver(){
    private long lastDrawn=0;
    @Override public void event(    Class event,    Object... arguments){
      if (nar.time() % gridUpdatePeriod == 0) {
        space.update(into);
        long now=System.nanoTime();
        if (now - lastDrawn > guiUpdateTime * 1e6) {
          space.redraw();
          lastDrawn=now;
        }
      }
    }
  }
);
  if (showWindow)   space.newWindow(1000,800,true);
  cells.forEach(16,16,18,18,new Hauto.SetMaterial(Material.DirtFloor));
  GridAgent a=new GridAgent(17,17,nar){
    @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=250;
            nar.addInput("String_Node_Str");
          }
        }
      }
      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 (path != null) {
          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.size() <= 1) {
            active=true;
            executed_going=false;
            if (!"String_Node_Str".equals(goal) && space.current.equals(space.target)) {
              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"));
                      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;
                          }
                        }
                      }
                    }
                  }
                }
 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;
                        }
                      }
                    }
                  }
                }
 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 ("String_Node_Str".equals(opname)) {
                  executed_going=false;
                  nar.addInput("String_Node_Str" + goal + "String_Node_Str");
                  if (goal.startsWith("String_Node_Str")) {
                    GridObject ToRemove=null;
                    for (                    GridObject obj : space.objects) {
                      if (obj instanceof LocalGridObject) {
                        LocalGridObject obo=(LocalGridObject)obj;
                        if (obo.doorname.equals(goal)) {
                          ToRemove=obj;
                        }
                      }
                    }
                    if (ToRemove != null) {
                      space.objects.remove(ToRemove);
                    }
                    hungry=500;
                    nar.addInput("String_Node_Str" + goal + "String_Node_Str");
                  }
                  active=true;
                }
              }
            }
            opname="String_Node_Str";
            nar.memory.setEnabled(true);
          }
 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;
            }
          }
        }
      }
    }
  }
;
  Goto wu=new Goto(this,"String_Node_Str");
  nar.memory.addOperator(wu);
  Pick wa=new Pick(this,"String_Node_Str");
  nar.memory.addOperator(wa);
  Activate waa=new Activate(this,"String_Node_Str");
  nar.memory.addOperator(waa);
  Deactivate waaa=new Deactivate(this,"String_Node_Str");
  nar.memory.addOperator(waaa);
  space.add(a);
}

Fixed version (ground truth):
public TestChamber(NAR nar,boolean showWindow){
  super();
  int w=50;
  int h=50;
  int water_threshold=30;
  Hauto cells=new Hauto(w,h,nar);
  cells.forEach(0,0,w,h,new CellFunction(){
    @Override public void update(    Cell c){
      float smoothness=20f;
      c.material=Material.GrassFloor;
      double n=SimplexNoise.noise(c.state.x / smoothness,c.state.y / smoothness);
      if ((n * 64) > water_threshold) {
        c.material=Material.Water;
      }
      c.setHeight((int)(Math.random() * 24 + 1));
    }
  }
);
  Maze.buildMaze(cells,3,3,23,23);
  space=new Grid2DSpace(cells,nar);
  space.FrameRate=0;
  space.automataPeriod=automataPeriod / gridUpdatePeriod;
  space.agentPeriod=agentPeriod / gridUpdatePeriod;
  TestChamber into=this;
  nar.memory.event.on(Events.FrameEnd.class,new EventObserver(){
    private long lastDrawn=0;
    @Override public void event(    Class event,    Object... arguments){
      if (nar.time() % gridUpdatePeriod == 0) {
        space.update(into);
        long now=System.nanoTime();
        if (now - lastDrawn > guiUpdateTime * 1e6) {
          space.redraw();
          lastDrawn=now;
        }
      }
    }
  }
);
  if (showWindow)   space.newWindow(1000,800,true);
  cells.forEach(16,16,18,18,new Hauto.SetMaterial(Material.DirtFloor));
  GridAgent a=new GridAgent(17,17,nar){
    @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=250;
            nar.addInput("String_Node_Str");
          }
        }
      }
      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 (path != null) {
          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.size() <= 1) {
            active=true;
            executed_going=false;
            if (!"String_Node_Str".equals(goal) && space.current.equals(space.target)) {
              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").replaceAll("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;
                          }
                        }
                      }
                    }
                  }
                }
 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;
                        }
                      }
                    }
                  }
                }
 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 ("String_Node_Str".equals(opname)) {
                  executed_going=false;
                  nar.addInput("String_Node_Str" + goal + "String_Node_Str");
                  if (goal.startsWith("String_Node_Str")) {
                    GridObject ToRemove=null;
                    for (                    GridObject obj : space.objects) {
                      if (obj instanceof LocalGridObject) {
                        LocalGridObject obo=(LocalGridObject)obj;
                        if (obo.doorname.equals(goal)) {
                          ToRemove=obj;
                        }
                      }
                    }
                    if (ToRemove != null) {
                      space.objects.remove(ToRemove);
                    }
                    hungry=500;
                    nar.addInput("String_Node_Str" + goal + "String_Node_Str");
                  }
                  active=true;
                }
              }
            }
            opname="String_Node_Str";
            nar.memory.setEnabled(true);
          }
 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;
            }
          }
        }
      }
    }
  }
;
  Goto wu=new Goto(this,"String_Node_Str");
  nar.memory.addOperator(wu);
  Pick wa=new Pick(this,"String_Node_Str");
  nar.memory.addOperator(wa);
  Activate waa=new Activate(this,"String_Node_Str");
  nar.memory.addOperator(waa);
  Deactivate waaa=new Deactivate(this,"String_Node_Str");
  nar.memory.addOperator(waaa);
  space.add(a);
}