Program: 153029
Project: 153029
Buggy source:
private void do_movement(Unit entity,AIController c,FlockRulesCalculator flock){
  float xcomp=0;
  float ycomp=0;
  float start_x=entity.getX();
  float start_y=entity.getY();
  calculateFlocking(entity,c,flock,m_flock_dir);
  xcomp=m_flock_dir.x;
  ycomp=m_flock_dir.y;
  if (!flock.hasLeader(entity)) {
    Unit enemy=entity.getTarget();
    if (enemy != null) {
      float goal_x=enemy.getX();
      float goal_y=enemy.getY();
      start_point.set(start_x,start_y);
      end_point.set(goal_x,goal_y);
      if (m_tester != null && !m_tester.isLineOfSightClear(start_point,end_point)) {
        PointF start=getClosestNode(start_point);
        PointF end=getClosestNode(end_point);
        ArrayList<PointF> path=null;
        if (start != null && end != null) {
          m_pathfinder.clearPath();
          m_pathfinder.findPath(start,end);
        }
        path=m_pathfinder.getPath();
        path.add(end_point);
        if (path.size() > 1) {
          PointF goal_point=path.get(0);
          if (path.size() > 1 && m_tester.isLineOfSightClear(start_point,path.get(1))) {
            goal_point=path.get(1);
          }
          goal_x=goal_point.x;
          goal_y=goal_point.y;
        }
      }
      float angle=MathUtils.getAngle(entity.getX(),entity.getY(),goal_x,goal_y);
      float objectiveweighting=getObjectiveWeighting();
      xcomp+=objectiveweighting * FloatMath.cos(angle);
      ycomp+=objectiveweighting * FloatMath.sin(angle);
    }
  }
  float wanteddir=MathUtils.getAngle(0,0,xcomp,ycomp);
  float wantedchange=MathUtils.normalizeAngle(wanteddir,entity.getHeading()) - entity.getHeading();
  float actualchange=wantedchange;
  float maxvelchange=getMaxVelChange();
  if (actualchange > maxvelchange) {
    actualchange=maxvelchange;
  }
  if (actualchange < -1.0f * maxvelchange) {
    actualchange=-1.0f * maxvelchange;
  }
  float heading=entity.getHeading() + actualchange;
  boolean clear=false;
  int tries=0;
  while (!clear) {
    if (tries > 150) {
      break;
    }
    float s_x=start_x + 3.0f * FloatMath.cos(heading);
    float s_y=start_y + 3.0f * FloatMath.sin(heading);
    float stickoffsetx=6.0f * FloatMath.cos(heading - MathUtils.PI / 2.0f);
    float stickoffsety=6.0f * FloatMath.sin(heading - MathUtils.PI / 2.0f);
    float leftx1=s_x + stickoffsetx;
    float lefty1=s_y + stickoffsety;
    float leftx2=leftx1 + 12.0f * FloatMath.cos(heading + MathUtils.PI / 6.0f);
    float lefty2=lefty1 + 12.0f * FloatMath.sin(heading + MathUtils.PI / 6.0f);
    float rightx1=s_x - stickoffsetx;
    float righty1=s_y - stickoffsety;
    float rightx2=rightx1 + 12.0f * FloatMath.cos(heading - MathUtils.PI / 6.0f);
    float righty2=righty1 + 12.0f * FloatMath.sin(heading - MathUtils.PI / 6.0f);
    if (m_tester.isLineOfSightClear(leftx1,lefty1,leftx2,lefty2) && m_tester.isLineOfSightClear(rightx1,righty1,rightx2,righty2)) {
      clear=true;
    }
 else {
      heading+=.05f * (actualchange > 0 ? 1 : -1);
      tries++;
    }
  }
  entity.setVelocity(getMaxVel(),heading);
}

Fixed version (ground truth):
private void do_movement(Unit entity,AIController c,FlockRulesCalculator flock){
  float xcomp=0;
  float ycomp=0;
  float start_x=entity.getX();
  float start_y=entity.getY();
  calculateFlocking(entity,c,flock,m_flock_dir);
  xcomp=m_flock_dir.x;
  ycomp=m_flock_dir.y;
  if (!flock.hasLeader(entity)) {
    Unit enemy=entity.getTarget();
    if (enemy != null) {
      float goal_x=enemy.getX();
      float goal_y=enemy.getY();
      start_point.set(start_x,start_y);
      end_point.set(goal_x,goal_y);
      if (m_tester != null && !m_tester.isLineOfSightClear(start_point,end_point)) {
        PointF start=getClosestNode(start_point);
        PointF end=getClosestNode(end_point);
        ArrayList<PointF> path=null;
        if (start != null && end != null) {
          m_pathfinder.clearPath();
          m_pathfinder.findPath(start,end);
        }
        path=m_pathfinder.getPath();
        path.add(end_point);
        if (path.size() > 1) {
          PointF goal_point=path.get(0);
          if (path.size() > 1 && m_tester.isLineOfSightClear(start_point,path.get(1))) {
            goal_point=path.get(1);
          }
          goal_x=goal_point.x;
          goal_y=goal_point.y;
        }
      }
      float angle=MathUtils.getAngle(entity.getX(),entity.getY(),goal_x,goal_y);
      float objectiveweighting=getObjectiveWeighting();
      xcomp+=objectiveweighting * FloatMath.cos(angle);
      ycomp+=objectiveweighting * FloatMath.sin(angle);
    }
  }
  float wanteddir=MathUtils.getAngle(0,0,xcomp,ycomp);
  float wantedchange=MathUtils.normalizeAngle(wanteddir,entity.getHeading()) - entity.getHeading();
  float actualchange=wantedchange;
  float maxvelchange=getMaxVelChange();
  if (actualchange > maxvelchange) {
    actualchange=maxvelchange;
  }
  if (actualchange < -1.0f * maxvelchange) {
    actualchange=-1.0f * maxvelchange;
  }
  float heading=entity.getHeading() + actualchange;
  boolean clear=false;
  int tries=0;
  while (!clear) {
    if (tries > 150) {
      break;
    }
    float s_x=start_x + 3.0f * FloatMath.cos(heading);
    float s_y=start_y + 3.0f * FloatMath.sin(heading);
    float stickoffsetx=6.0f * FloatMath.cos(heading - MathUtils.PI / 2.0f);
    float stickoffsety=6.0f * FloatMath.sin(heading - MathUtils.PI / 2.0f);
    float leftx1=s_x + stickoffsetx;
    float lefty1=s_y + stickoffsety;
    float leftx2=leftx1 + 12.0f * FloatMath.cos(heading + MathUtils.PI / 6.0f);
    float lefty2=lefty1 + 12.0f * FloatMath.sin(heading + MathUtils.PI / 6.0f);
    float rightx1=s_x - stickoffsetx;
    float righty1=s_y - stickoffsety;
    float rightx2=rightx1 + 12.0f * FloatMath.cos(heading - MathUtils.PI / 6.0f);
    float righty2=righty1 + 12.0f * FloatMath.sin(heading - MathUtils.PI / 6.0f);
    if (m_tester != null && m_tester.isLineOfSightClear(leftx1,lefty1,leftx2,lefty2) && m_tester.isLineOfSightClear(rightx1,righty1,rightx2,righty2)) {
      clear=true;
    }
 else {
      heading+=.05f * (actualchange > 0 ? 1 : -1);
      tries++;
    }
  }
  entity.setVelocity(getMaxVel(),heading);
}