final public void computeTimeLimit(SearchParams sPar){
  minTimeLimit=-1;
  maxTimeLimit=-1;
  maxDepth=-1;
  maxNodes=-1;
  if (sPar.infinite) {
    minTimeLimit=-1;
    maxTimeLimit=-1;
    maxDepth=-1;
  }
 else   if (sPar.depth > 0) {
    maxDepth=sPar.depth;
  }
 else   if (sPar.mate > 0) {
    maxDepth=sPar.mate * 2 - 1;
  }
 else   if (sPar.moveTime > 0) {
    minTimeLimit=maxTimeLimit=sPar.moveTime;
  }
 else   if (sPar.nodes > 0) {
    maxNodes=sPar.nodes;
  }
 else {
    int moves=sPar.movesToGo;
    if (moves == 0) {
      moves=999;
    }
    moves=Math.min(moves,45);
    if (ponderMode) {
      final double ponderHitRate=0.35;
      moves=(int)Math.ceil(moves * (1 - ponderHitRate));
    }
    boolean white=pos.whiteMove;
    int time=white ? sPar.wTime : sPar.bTime;
    int inc=white ? sPar.wInc : sPar.bInc;
    final int margin=Math.min(1000,time * 9 / 10);
    int timeLimit=(time + inc * (moves - 1) - margin) / moves;
    minTimeLimit=(int)(timeLimit * 0.85);
    maxTimeLimit=(int)(minTimeLimit * (Math.max(2.5,Math.min(4.0,moves / 2))));
    minTimeLimit=clamp(minTimeLimit,1,time - margin);
    maxTimeLimit=clamp(maxTimeLimit,1,time - margin);
  }
}

final public void computeTimeLimit ( SearchParams sPar ) { minTimeLimit = - 1 ; maxTimeLimit = - 1 ; maxDepth = - 1 ; maxNodes = - 1 ; if ( sPar . infinite ) { minTimeLimit = - 1 ; maxTimeLimit = - 1 ; maxDepth = - 1 ; } else if ( sPar . depth > 0 ) { maxDepth = sPar . depth ; } else if ( sPar . mate > 0 ) { maxDepth = sPar . mate * 2 - 1 ; } else if ( sPar . moveTime > 0 ) { minTimeLimit = maxTimeLimit = sPar . moveTime ; } else if ( sPar . nodes > 0 ) { maxNodes = sPar . nodes ; } else { int moves = sPar . movesToGo ; if ( moves == 0 ) { moves = 999 ; } moves = Math . min ( moves , 45 ) ; if ( ponderMode ) { final double ponderHitRate = 0.35 ; moves = ( int ) Math . ceil ( moves * ( 1 - ponderHitRate ) ) ; } boolean white = pos . whiteMove ; int time = white ? sPar . wTime : sPar . bTime ; int inc = white ? sPar . wInc : sPar . bInc ; final int margin = Math . min ( 1000 , time * 9 / 10 ) ; int timeLimit = ( time + inc * ( moves - 1 ) - margin ) / moves ; minTimeLimit = ( int ) ( timeLimit * 0.85 ) ; maxTimeLimit = ( int ) ( minTimeLimit * ( Math . max ( 2.5 , Math . min ( 4.0 , moves / 2 ) ) ) ) ; minTimeLimit = clamp ( minTimeLimit , 1 , time - margin ) ; maxTimeLimit = clamp ( maxTimeLimit , 1 , time - margin ) ; } }
compute thinking time for current search .
