Program: 49755
Project: 49755
Buggy source:
/** 
 * Search Root, PV and null window
 */
public int search(int nodeType,int depthRemaining,int alpha,int beta,boolean allowNullMove,int excludedMove) throws SearchFinishedException {
  if (System.currentTimeMillis() > thinkTo && foundOneMove) {
    throw new SearchFinishedException();
  }
  if (nodeType == NODE_PV || nodeType == NODE_ROOT) {
    pvPositionCounter++;
  }
 else {
    positionCounter++;
  }
  if (board.isDraw()) {
    return evaluateDraw();
  }
  alpha=Math.max(valueMatedIn(board.getMoveNumber() - initialPly),alpha);
  beta=Math.min(valueMateIn(board.getMoveNumber() - initialPly + 1),beta);
  if (alpha >= beta) {
    return alpha;
  }
  int ttMove=0;
  int ttScore=0;
  int score=0;
  ttProbe++;
  boolean foundTT=tt.search(board,excludedMove != 0);
  if (foundTT) {
    if (nodeType != NODE_ROOT && canUseTT(depthRemaining,alpha,beta)) {
      return tt.getScore();
    }
    ttMove=tt.getBestMove();
    ttScore=tt.getScore();
  }
  if (depthRemaining < PLY) {
    return quiescentSearch(0,alpha,beta);
  }
  int eval=-Evaluator.VICTORY;
  if (!board.getCheck()) {
    eval=eval(foundTT,true);
  }
  if (nodeType == NODE_NULL && config.getRazoring() && !board.getCheck() && ttMove == 0 && allowNullMove && depthRemaining < RAZOR_DEPTH && !valueIsMate(beta) && eval < beta - config.getRazoringMargin() && (board.pawns & ((board.whites & BitboardUtils.b2_u) | (board.blacks & BitboardUtils.b2_d))) == 0) {
    razoringProbe++;
    int rbeta=beta - config.getRazoringMargin();
    int v=quiescentSearch(0,rbeta - 1,rbeta);
    if (v < rbeta) {
      razoringHit++;
      return v;
    }
  }
  if (nodeType == NODE_NULL && config.getStaticNullMove() && allowNullMove && boardAllowNullMove() && depthRemaining < RAZOR_DEPTH && !valueIsMate(beta) && eval >= beta + config.getFutilityMargin()) {
    return eval - config.getFutilityMargin();
  }
  boolean mateThreat=false;
  if (nodeType == NODE_NULL && config.getNullMove() && allowNullMove && boardAllowNullMove() && depthRemaining > 3 * PLY && !valueIsMate(beta) && eval > beta - (depthRemaining >= 4 * PLY ? config.getNullMoveMargin() : 0)) {
    nullMoveProbe++;
    board.doMove(0,false);
    int R=3 * PLY + (depthRemaining >= 5 * PLY ? depthRemaining / (4 * PLY) : 0);
    if (eval - beta > CompleteEvaluator.PAWN) {
      R++;
    }
    score=-search(NODE_NULL,depthRemaining - R,-beta,-beta + 1,false,0);
    board.undoMove();
    if (score >= beta) {
      if (valueIsMate(score)) {
        score=beta;
      }
      if (depthRemaining < 6 * PLY || search(NODE_NULL,depthRemaining - 5 * PLY,beta - 1,beta,false,0) >= beta) {
        nullMoveHit++;
        return score;
      }
    }
 else {
      if (score < (-Evaluator.VICTORY + 100)) {
        mateThreat=true;
      }
    }
  }
  if (config.getIid() && ttMove == 0 && depthRemaining >= iidDepth[nodeType] && allowNullMove && !board.getCheck() && (nodeType != NODE_NULL || eval > beta - config.getIidMargin()) && excludedMove == 0) {
    int d=(nodeType == NODE_PV ? depthRemaining - 2 * PLY : depthRemaining >> 1);
    search(nodeType,d,alpha,beta,true,0);
    if (tt.search(board,false)) {
      ttMove=tt.getBestMove();
    }
  }
  boolean singularMoveExtension=nodeType != NODE_ROOT && ttMove != 0 && config.getExtensionsSingular() > 0 && depthRemaining >= singularMoveDepth[nodeType] && tt.getNodeType() == TranspositionTable.TYPE_FAIL_HIGH && tt.getDepthAnalyzed() >= depthRemaining - 3 * PLY && Math.abs(ttScore) < Evaluator.KNOWN_WIN;
  boolean futilityPrune=false;
  if (nodeType == NODE_NULL && !board.getCheck()) {
    if (depthRemaining <= PLY) {
      if (config.getFutility() && eval < beta - config.getFutilityMargin()) {
        futilityHit++;
        futilityPrune=true;
      }
    }
 else     if (depthRemaining <= 2 * PLY) {
      if (config.getAggressiveFutility() && eval < beta - config.getAggressiveFutilityMargin()) {
        aggressiveFutilityHit++;
        futilityPrune=true;
      }
    }
  }
  MoveIterator moveIterator=moveIterators[board.getMoveNumber() - initialPly];
  moveIterator.genMoves(ttMove);
  int movesDone=0;
  boolean validOperations=false;
  boolean checkEvasion=board.getCheck();
  int bestScore=-Evaluator.VICTORY;
  int move, bestMove=0;
  while ((move=moveIterator.next()) != 0) {
    int extension=0;
    int reduction=0;
    if (board.doMove(move,false)) {
      validOperations=true;
      if (move == excludedMove) {
        board.undoMove();
        continue;
      }
      extension+=extensions(move,mateThreat);
      if (singularMoveExtension && move == ttMove && extension < PLY && excludedMove == 0) {
        singularExtensionProbe++;
        board.undoMove();
        int seBeta=ttScore - config.getSingularExtensionMargin();
        int excScore=search(nodeType,depthRemaining >> 1,seBeta - 1,seBeta,false,move);
        board.doMove(move);
        if (excScore < seBeta) {
          singularExtensionHit++;
          extension+=config.getExtensionsSingular();
          if (extension > PLY) {
            extension=PLY;
          }
        }
      }
      boolean importantMove=nodeType == NODE_ROOT || extension != 0 || Move.isCapture(move) || Move.isPromotion(move) || Move.isCastling(move) || checkEvasion || move == ttMove || sortInfo.isKiller(move,board.getMoveNumber() - initialPly);
      if (futilityPrune && bestScore > -Evaluator.KNOWN_WIN && !importantMove) {
        board.undoMove();
        continue;
      }
      if (config.getLmr() && depthRemaining >= LMR_DEPTHS_NOT_REDUCED && !importantMove) {
        reduction+=getReduction(nodeType,depthRemaining,movesDone);
      }
      movesDone++;
      int lowBound=(alpha > bestScore ? alpha : bestScore);
      if ((nodeType == NODE_PV || nodeType == NODE_ROOT) && movesDone == 1) {
        score=-search(NODE_PV,depthRemaining + extension - PLY,-beta,-lowBound,true,0);
      }
 else {
        boolean doFullSearch=true;
        if (reduction > 0) {
          score=-search(NODE_NULL,depthRemaining - reduction - PLY,-lowBound - 1,-lowBound,true,0);
          doFullSearch=(score > lowBound);
        }
        if (doFullSearch) {
          score=-search(NODE_NULL,depthRemaining + extension - PLY,-lowBound - 1,-lowBound,true,0);
          if ((nodeType == NODE_PV || nodeType == NODE_ROOT) && score > lowBound && (nodeType == NODE_ROOT || score < beta)) {
            score=-search(NODE_PV,depthRemaining + extension - PLY,-beta,-lowBound,true,0);
          }
        }
      }
      board.undoMove();
      if (score > bestScore && (nodeType != NODE_ROOT || config.getRand() == 0 || (random.nextInt(100) > config.getRand()))) {
        bestMove=move;
        bestScore=score;
      }
      if (score >= beta) {
        break;
      }
    }
  }
  if (excludedMove == 0 && !validOperations) {
    bestScore=evaluateEndgame();
  }
  if (bestScore >= beta) {
    if (excludedMove == 0) {
      sortInfo.betaCutoff(bestMove,board.getMoveNumber() - initialPly);
    }
    if (nodeType == NODE_NULL) {
      nullCutNodes++;
    }
 else {
      pvCutNodes++;
    }
  }
 else {
    if (nodeType == NODE_NULL) {
      nullAllNodes++;
    }
 else {
      pvAllNodes++;
    }
  }
  tt.save(board,(byte)depthRemaining,bestMove,bestScore,alpha,beta,excludedMove != 0);
  return bestScore;
}

Fixed version (ground truth):
/** 
 * Search Root, PV and null window
 */
public int search(int nodeType,int depthRemaining,int alpha,int beta,boolean allowNullMove,int excludedMove) throws SearchFinishedException {
  if (System.currentTimeMillis() > thinkTo && foundOneMove) {
    throw new SearchFinishedException();
  }
  if (nodeType == NODE_PV || nodeType == NODE_ROOT) {
    pvPositionCounter++;
  }
 else {
    positionCounter++;
  }
  if (board.isDraw()) {
    return evaluateDraw();
  }
  alpha=Math.max(valueMatedIn(board.getMoveNumber() - initialPly),alpha);
  beta=Math.min(valueMateIn(board.getMoveNumber() - initialPly + 1),beta);
  if (alpha >= beta) {
    return alpha;
  }
  int ttMove=0;
  int ttScore=0;
  int score=0;
  ttProbe++;
  boolean foundTT=tt.search(board,excludedMove != 0);
  if (foundTT) {
    if (nodeType != NODE_ROOT && canUseTT(depthRemaining,alpha,beta)) {
      return tt.getScore();
    }
    ttMove=tt.getBestMove();
    ttScore=tt.getScore();
  }
  if (depthRemaining < PLY || board.getMoveNumber() - initialPly >= MAX_DEPTH - 1) {
    return quiescentSearch(0,alpha,beta);
  }
  int eval=-Evaluator.VICTORY;
  if (!board.getCheck()) {
    eval=eval(foundTT,true);
  }
  if (nodeType == NODE_NULL && config.getRazoring() && !board.getCheck() && ttMove == 0 && allowNullMove && depthRemaining < RAZOR_DEPTH && !valueIsMate(beta) && eval < beta - config.getRazoringMargin() && (board.pawns & ((board.whites & BitboardUtils.b2_u) | (board.blacks & BitboardUtils.b2_d))) == 0) {
    razoringProbe++;
    int rbeta=beta - config.getRazoringMargin();
    int v=quiescentSearch(0,rbeta - 1,rbeta);
    if (v < rbeta) {
      razoringHit++;
      return v;
    }
  }
  if (nodeType == NODE_NULL && config.getStaticNullMove() && allowNullMove && boardAllowNullMove() && depthRemaining < RAZOR_DEPTH && !valueIsMate(beta) && eval >= beta + config.getFutilityMargin()) {
    return eval - config.getFutilityMargin();
  }
  boolean mateThreat=false;
  if (nodeType == NODE_NULL && config.getNullMove() && allowNullMove && boardAllowNullMove() && depthRemaining > 3 * PLY && !valueIsMate(beta) && eval > beta - (depthRemaining >= 4 * PLY ? config.getNullMoveMargin() : 0)) {
    nullMoveProbe++;
    board.doMove(0,false);
    int R=3 * PLY + (depthRemaining >= 5 * PLY ? depthRemaining / (4 * PLY) : 0);
    if (eval - beta > CompleteEvaluator.PAWN) {
      R++;
    }
    score=-search(NODE_NULL,depthRemaining - R,-beta,-beta + 1,false,0);
    board.undoMove();
    if (score >= beta) {
      if (valueIsMate(score)) {
        score=beta;
      }
      if (depthRemaining < 6 * PLY || search(NODE_NULL,depthRemaining - 5 * PLY,beta - 1,beta,false,0) >= beta) {
        nullMoveHit++;
        return score;
      }
    }
 else {
      if (score < (-Evaluator.VICTORY + 100)) {
        mateThreat=true;
      }
    }
  }
  if (config.getIid() && ttMove == 0 && depthRemaining >= iidDepth[nodeType] && allowNullMove && !board.getCheck() && (nodeType != NODE_NULL || eval > beta - config.getIidMargin()) && excludedMove == 0) {
    int d=(nodeType == NODE_PV ? depthRemaining - 2 * PLY : depthRemaining >> 1);
    search(nodeType,d,alpha,beta,true,0);
    if (tt.search(board,false)) {
      ttMove=tt.getBestMove();
    }
  }
  boolean singularMoveExtension=nodeType != NODE_ROOT && ttMove != 0 && config.getExtensionsSingular() > 0 && depthRemaining >= singularMoveDepth[nodeType] && tt.getNodeType() == TranspositionTable.TYPE_FAIL_HIGH && tt.getDepthAnalyzed() >= depthRemaining - 3 * PLY && Math.abs(ttScore) < Evaluator.KNOWN_WIN;
  boolean futilityPrune=false;
  if (nodeType == NODE_NULL && !board.getCheck()) {
    if (depthRemaining <= PLY) {
      if (config.getFutility() && eval < beta - config.getFutilityMargin()) {
        futilityHit++;
        futilityPrune=true;
      }
    }
 else     if (depthRemaining <= 2 * PLY) {
      if (config.getAggressiveFutility() && eval < beta - config.getAggressiveFutilityMargin()) {
        aggressiveFutilityHit++;
        futilityPrune=true;
      }
    }
  }
  MoveIterator moveIterator=moveIterators[board.getMoveNumber() - initialPly];
  moveIterator.genMoves(ttMove);
  int movesDone=0;
  boolean validOperations=false;
  boolean checkEvasion=board.getCheck();
  int bestScore=-Evaluator.VICTORY;
  int move, bestMove=0;
  while ((move=moveIterator.next()) != 0) {
    int extension=0;
    int reduction=0;
    if (board.doMove(move,false)) {
      validOperations=true;
      if (move == excludedMove) {
        board.undoMove();
        continue;
      }
      extension+=extensions(move,mateThreat);
      if (singularMoveExtension && move == ttMove && extension < PLY && excludedMove == 0) {
        singularExtensionProbe++;
        board.undoMove();
        int seBeta=ttScore - config.getSingularExtensionMargin();
        int excScore=search(nodeType,depthRemaining >> 1,seBeta - 1,seBeta,false,move);
        board.doMove(move);
        if (excScore < seBeta) {
          singularExtensionHit++;
          extension+=config.getExtensionsSingular();
          if (extension > PLY) {
            extension=PLY;
          }
        }
      }
      boolean importantMove=nodeType == NODE_ROOT || extension != 0 || Move.isCapture(move) || Move.isPromotion(move) || Move.isCastling(move) || checkEvasion || move == ttMove || sortInfo.isKiller(move,board.getMoveNumber() - initialPly);
      if (futilityPrune && bestScore > -Evaluator.KNOWN_WIN && !importantMove) {
        board.undoMove();
        continue;
      }
      if (config.getLmr() && depthRemaining >= LMR_DEPTHS_NOT_REDUCED && !importantMove) {
        reduction+=getReduction(nodeType,depthRemaining,movesDone);
      }
      movesDone++;
      int lowBound=(alpha > bestScore ? alpha : bestScore);
      if ((nodeType == NODE_PV || nodeType == NODE_ROOT) && movesDone == 1) {
        score=-search(NODE_PV,depthRemaining + extension - PLY,-beta,-lowBound,true,0);
      }
 else {
        boolean doFullSearch=true;
        if (reduction > 0) {
          score=-search(NODE_NULL,depthRemaining - reduction - PLY,-lowBound - 1,-lowBound,true,0);
          doFullSearch=(score > lowBound);
        }
        if (doFullSearch) {
          score=-search(NODE_NULL,depthRemaining + extension - PLY,-lowBound - 1,-lowBound,true,0);
          if ((nodeType == NODE_PV || nodeType == NODE_ROOT) && score > lowBound && (nodeType == NODE_ROOT || score < beta)) {
            score=-search(NODE_PV,depthRemaining + extension - PLY,-beta,-lowBound,true,0);
          }
        }
      }
      board.undoMove();
      if (score > bestScore && (nodeType != NODE_ROOT || config.getRand() == 0 || (random.nextInt(100) > config.getRand()))) {
        bestMove=move;
        bestScore=score;
      }
      if (score >= beta) {
        break;
      }
    }
  }
  if (excludedMove == 0 && !validOperations) {
    bestScore=evaluateEndgame();
  }
  if (bestScore >= beta) {
    if (excludedMove == 0) {
      sortInfo.betaCutoff(bestMove,board.getMoveNumber() - initialPly);
    }
    if (nodeType == NODE_NULL) {
      nullCutNodes++;
    }
 else {
      pvCutNodes++;
    }
  }
 else {
    if (nodeType == NODE_NULL) {
      nullAllNodes++;
    }
 else {
      pvAllNodes++;
    }
  }
  tt.save(board,(byte)depthRemaining,bestMove,bestScore,alpha,beta,excludedMove != 0);
  return bestScore;
}