private static boolean addBookLine(String line,List<Byte> binBook) throws ChessParseError {
  Position pos=TextIO.readFEN(TextIO.startPosFEN);
  UndoInfo ui=new UndoInfo();
  String[] strMoves=line.split(" ");
  for (  String strMove : strMoves) {
    int bad=0;
    if (strMove.endsWith("?")) {
      strMove=strMove.substring(0,strMove.length() - 1);
      bad=1;
    }
    Move m=TextIO.stringToMove(pos,strMove);
    if (m == null) {
      return false;
    }
    int prom=pieceToProm(m.promoteTo);
    int val=m.from + (m.to << 6) + (prom << 12)+ (bad << 15);
    binBook.add((byte)(val >> 8));
    binBook.add((byte)(val & 255));
    pos.makeMove(m,ui);
  }
  binBook.add((byte)0);
  binBook.add((byte)0);
  return true;
}

private static boolean addBookLine ( String line , List < Byte > binBook ) throws ChessParseError { Position pos = TextIO . readFEN ( TextIO . startPosFEN ) ; UndoInfo ui = new UndoInfo ( ) ; String [ ] strMoves = line . split ( " " ) ; for ( String strMove : strMoves ) { int bad = 0 ; if ( strMove . endsWith ( "?" ) ) { strMove = strMove . substring ( 0 , strMove . length ( ) - 1 ) ; bad = 1 ; } Move m = TextIO . stringToMove ( pos , strMove ) ; if ( m == null ) { return false ; } int prom = pieceToProm ( m . promoteTo ) ; int val = m . from + ( m . to << 6 ) + ( prom << 12 ) + ( bad << 15 ) ; binBook . add ( ( byte ) ( val > > 8 ) ) ; binBook . add ( ( byte ) ( val & 255 ) ) ; pos . makeMove ( m , ui ) ; } binBook . add ( ( byte ) 0 ) ; binBook . add ( ( byte ) 0 ) ; return true ; }
add a sequence of moves , starting from the initial position , to the binary opening book .
