Program: 86576
Project: 86576
Buggy source:
/** 
 * @param dt
 * @return true if blocked
 */
public boolean update(TimeStep timeStep){
  boolean isBlocked=false;
  this.movementDir.zeroOut();
  if (this.isAlive && !this.vel.isZero()) {
    if (currentState != State.WALKING && currentState != State.SPRINTING) {
      currentState=State.RUNNING;
    }
    int movementSpeed=calculateMovementSpeed();
    float dt=(float)timeStep.asFraction();
    float deltaX=(vel.x * movementSpeed * dt);
    float deltaY=(vel.y * movementSpeed * dt);
    float newX=pos.x + deltaX;
    float newY=pos.y + deltaY;
    if (Math.abs(pos.x - newX) > 2.5) {
      this.movementDir.x=vel.x;
    }
    if (Math.abs(pos.y - newY) > 2.5) {
      this.movementDir.y=vel.y;
    }
    Map map=game.getMap();
    boolean isBlockedByEntity=false;
    bounds.x=(int)newX;
    if (map.rectCollides(bounds,collisionHeightMask,xCollisionTilePos)) {
      isBlocked=collideX((int)newX,bounds.x);
      if (isBlocked) {
        bounds.x=(int)pos.x;
        newX=pos.x;
      }
    }
 else     if (collidesAgainstEntity(bounds) || collidesAgainstMapObject(bounds)) {
      bounds.x=(int)pos.x;
      newX=pos.x;
      isBlocked=true;
      isBlockedByEntity=true;
    }
    bounds.y=(int)newY;
    if (map.rectCollides(bounds,collisionHeightMask,yCollisionTilePos)) {
      isBlocked=collideY((int)newY,bounds.y);
      if (isBlocked) {
        bounds.y=(int)pos.y;
        newY=pos.y;
      }
    }
 else     if (collidesAgainstEntity(bounds) || collidesAgainstMapObject(bounds)) {
      bounds.y=(int)pos.y;
      newY=pos.y;
      isBlocked=true;
      isBlockedByEntity=true;
    }
    if (isBlocked) {
      if (!continueIfBlock()) {
        bounds.setLocation(pos);
        newX=pos.x;
        newY=pos.y;
      }
 else       if (!isBlockedByEntity) {
        if (deltaX != 0 && deltaY == 0) {
          newY=adjustY(xCollisionTilePos,deltaX,(int)(pos.x + deltaX),bounds.y);
        }
 else         if (deltaX == 0 && deltaY != 0) {
          newX=adjustX(yCollisionTilePos,deltaY,bounds.x,(int)(pos.y + deltaY));
        }
      }
    }
    pos.x=newX;
    pos.y=newY;
    vel.zeroOut();
    this.walkingTime=WALK_TIME;
  }
 else {
    if (this.walkingTime <= 0 && currentState != State.CROUCHING) {
      currentState=State.IDLE;
    }
    this.walkingTime-=timeStep.getDeltaTime();
  }
  return isBlocked;
}

Fixed version (ground truth):
/** 
 * @param dt
 * @return true if blocked
 */
public boolean update(TimeStep timeStep){
  boolean isBlocked=false;
  this.movementDir.zeroOut();
  if (this.isAlive && !this.vel.isZero()) {
    if (currentState != State.WALKING && currentState != State.SPRINTING) {
      currentState=State.RUNNING;
    }
    int movementSpeed=calculateMovementSpeed();
    float dt=(float)timeStep.asFraction();
    float deltaX=(vel.x * movementSpeed * dt);
    float deltaY=(vel.y * movementSpeed * dt);
    float newX=pos.x + deltaX;
    float newY=pos.y + deltaY;
    if (Math.abs(pos.x - newX) > 2.5) {
      this.movementDir.x=vel.x;
    }
    if (Math.abs(pos.y - newY) > 2.5) {
      this.movementDir.y=vel.y;
    }
    Map map=game.getMap();
    boolean isBlockedByEntity=false;
    bounds.x=(int)newX;
    if (map.rectCollides(bounds,collisionHeightMask,xCollisionTilePos)) {
      isBlocked=collideX((int)newX,bounds.x);
      if (isBlocked) {
        bounds.x=(int)pos.x;
        newX=pos.x;
      }
    }
 else     if (collidesAgainstEntity(bounds) || collidesAgainstMapObject(bounds)) {
      bounds.x=(int)pos.x;
      newX=pos.x;
      isBlocked=true;
      isBlockedByEntity=true;
    }
    bounds.y=(int)newY;
    if (map.rectCollides(bounds,collisionHeightMask,yCollisionTilePos)) {
      isBlocked=collideY((int)newY,bounds.y);
      if (isBlocked) {
        bounds.y=(int)pos.y;
        newY=pos.y;
      }
    }
 else     if (collidesAgainstEntity(bounds) || collidesAgainstMapObject(bounds)) {
      bounds.y=(int)pos.y;
      newY=pos.y;
      isBlocked=true;
      isBlockedByEntity=true;
    }
    if (isBlocked) {
      if (!continueIfBlock()) {
        bounds.setLocation(pos);
        newX=pos.x;
        newY=pos.y;
      }
 else       if (!isBlockedByEntity) {
        if (deltaX != 0 && deltaY == 0) {
          newY=adjustY(xCollisionTilePos,deltaX,(int)(pos.x + deltaX),bounds.y);
          if (checkCollision((int)newX,(int)newY)) {
            newY=pos.y;
          }
        }
 else         if (deltaX == 0 && deltaY != 0) {
          newX=adjustX(yCollisionTilePos,deltaY,bounds.x,(int)(pos.y + deltaY));
          if (checkCollision((int)newX,(int)newY)) {
            newX=pos.x;
          }
        }
      }
    }
    pos.x=newX;
    pos.y=newY;
    vel.zeroOut();
    this.walkingTime=WALK_TIME;
  }
 else {
    if (this.walkingTime <= 0 && currentState != State.CROUCHING) {
      currentState=State.IDLE;
    }
    this.walkingTime-=timeStep.getDeltaTime();
  }
  return isBlocked;
}