final public int SEE(Move m){
  final int kV=Evaluate.kV;
  final int square=m.to;
  if (square == pos.getEpSquare()) {
    captures[0]=Evaluate.pV;
  }
 else {
    captures[0]=Evaluate.pieceValue[pos.getPiece(square)];
    if (captures[0] == kV)     return kV;
  }
  int nCapt=1;
  pos.makeSEEMove(m,seeUi);
  boolean white=pos.whiteMove;
  int valOnSquare=Evaluate.pieceValue[pos.getPiece(square)];
  long occupied=pos.whiteBB | pos.blackBB;
  while (true) {
    int bestValue=Integer.MAX_VALUE;
    long atk;
    if (white) {
      atk=BitBoard.bPawnAttacks[square] & pos.pieceTypeBB[Piece.WPAWN] & occupied;
      if (atk != 0) {
        bestValue=Evaluate.pV;
      }
 else {
        atk=BitBoard.knightAttacks[square] & pos.pieceTypeBB[Piece.WKNIGHT] & occupied;
        if (atk != 0) {
          bestValue=Evaluate.nV;
        }
 else {
          long bAtk=BitBoard.bishopAttacks(square,occupied) & occupied;
          atk=bAtk & pos.pieceTypeBB[Piece.WBISHOP];
          if (atk != 0) {
            bestValue=Evaluate.bV;
          }
 else {
            long rAtk=BitBoard.rookAttacks(square,occupied) & occupied;
            atk=rAtk & pos.pieceTypeBB[Piece.WROOK];
            if (atk != 0) {
              bestValue=Evaluate.rV;
            }
 else {
              atk=(bAtk | rAtk) & pos.pieceTypeBB[Piece.WQUEEN];
              if (atk != 0) {
                bestValue=Evaluate.qV;
              }
 else {
                atk=BitBoard.kingAttacks[square] & pos.pieceTypeBB[Piece.WKING] & occupied;
                if (atk != 0) {
                  bestValue=kV;
                }
 else {
                  break;
                }
              }
            }
          }
        }
      }
    }
 else {
      atk=BitBoard.wPawnAttacks[square] & pos.pieceTypeBB[Piece.BPAWN] & occupied;
      if (atk != 0) {
        bestValue=Evaluate.pV;
      }
 else {
        atk=BitBoard.knightAttacks[square] & pos.pieceTypeBB[Piece.BKNIGHT] & occupied;
        if (atk != 0) {
          bestValue=Evaluate.nV;
        }
 else {
          long bAtk=BitBoard.bishopAttacks(square,occupied) & occupied;
          atk=bAtk & pos.pieceTypeBB[Piece.BBISHOP];
          if (atk != 0) {
            bestValue=Evaluate.bV;
          }
 else {
            long rAtk=BitBoard.rookAttacks(square,occupied) & occupied;
            atk=rAtk & pos.pieceTypeBB[Piece.BROOK];
            if (atk != 0) {
              bestValue=Evaluate.rV;
            }
 else {
              atk=(bAtk | rAtk) & pos.pieceTypeBB[Piece.BQUEEN];
              if (atk != 0) {
                bestValue=Evaluate.qV;
              }
 else {
                atk=BitBoard.kingAttacks[square] & pos.pieceTypeBB[Piece.BKING] & occupied;
                if (atk != 0) {
                  bestValue=kV;
                }
 else {
                  break;
                }
              }
            }
          }
        }
      }
    }
    captures[nCapt++]=valOnSquare;
    if (valOnSquare == kV)     break;
    valOnSquare=bestValue;
    occupied&=~(atk & -atk);
    white=!white;
  }
  pos.unMakeSEEMove(m,seeUi);
  int score=0;
  for (int i=nCapt - 1; i > 0; i--) {
    score=Math.max(0,captures[i] - score);
  }
  return captures[0] - score;
}

final public int SEE ( Move m ) { final int kV = Evaluate . kV ; final int square = m . to ; if ( square == pos . getEpSquare ( ) ) { captures [ 0 ] = Evaluate . pV ; } else { captures [ 0 ] = Evaluate . pieceValue [ pos . getPiece ( square ) ] ; if ( captures [ 0 ] == kV ) return kV ; } int nCapt = 1 ; pos . makeSEEMove ( m , seeUi ) ; boolean white = pos . whiteMove ; int valOnSquare = Evaluate . pieceValue [ pos . getPiece ( square ) ] ; long occupied = pos . whiteBB | pos . blackBB ; while ( true ) { int bestValue = Integer . MAX_VALUE ; long atk ; if ( white ) { atk = BitBoard . bPawnAttacks [ square ] & pos . pieceTypeBB [ Piece . WPAWN ] & occupied ; if ( atk != 0 ) { bestValue = Evaluate . pV ; } else { atk = BitBoard . knightAttacks [ square ] & pos . pieceTypeBB [ Piece . WKNIGHT ] & occupied ; if ( atk != 0 ) { bestValue = Evaluate . nV ; } else { long bAtk = BitBoard . bishopAttacks ( square , occupied ) & occupied ; atk = bAtk & pos . pieceTypeBB [ Piece . WBISHOP ] ; if ( atk != 0 ) { bestValue = Evaluate . bV ; } else { long rAtk = BitBoard . rookAttacks ( square , occupied ) & occupied ; atk = rAtk & pos . pieceTypeBB [ Piece . WROOK ] ; if ( atk != 0 ) { bestValue = Evaluate . rV ; } else { atk = ( bAtk | rAtk ) & pos . pieceTypeBB [ Piece . WQUEEN ] ; if ( atk != 0 ) { bestValue = Evaluate . qV ; } else { atk = BitBoard . kingAttacks [ square ] & pos . pieceTypeBB [ Piece . WKING ] & occupied ; if ( atk != 0 ) { bestValue = kV ; } else { break ; } } } } } } } else { atk = BitBoard . wPawnAttacks [ square ] & pos . pieceTypeBB [ Piece . BPAWN ] & occupied ; if ( atk != 0 ) { bestValue = Evaluate . pV ; } else { atk = BitBoard . knightAttacks [ square ] & pos . pieceTypeBB [ Piece . BKNIGHT ] & occupied ; if ( atk != 0 ) { bestValue = Evaluate . nV ; } else { long bAtk = BitBoard . bishopAttacks ( square , occupied ) & occupied ; atk = bAtk & pos . pieceTypeBB [ Piece . BBISHOP ] ; if ( atk != 0 ) { bestValue = Evaluate . bV ; } else { long rAtk = BitBoard . rookAttacks ( square , occupied ) & occupied ; atk = rAtk & pos . pieceTypeBB [ Piece . BROOK ] ; if ( atk != 0 ) { bestValue = Evaluate . rV ; } else { atk = ( bAtk | rAtk ) & pos . pieceTypeBB [ Piece . BQUEEN ] ; if ( atk != 0 ) { bestValue = Evaluate . qV ; } else { atk = BitBoard . kingAttacks [ square ] & pos . pieceTypeBB [ Piece . BKING ] & occupied ; if ( atk != 0 ) { bestValue = kV ; } else { break ; } } } } } } } captures [ nCapt ++ ] = valOnSquare ; if ( valOnSquare == kV ) break ; valOnSquare = bestValue ; occupied &= ~ ( atk & - atk ) ; white = ! white ; } pos . unMakeSEEMove ( m , seeUi ) ; int score = 0 ; for ( int i = nCapt - 1 ; i > 0 ; i -- ) { score = Math . max ( 0 , captures [ i ] - score ) ; } return captures [ 0 ] - score ; }
static exchange evaluation function .
