public static final String asciiBoard(Position pos){
  StringBuilder ret=new StringBuilder(400);
  String nl=String.format(Locale.US,"%n");
  ret.append("    +----+----+----+----+----+----+----+----+");
  ret.append(nl);
  for (int y=7; y >= 0; y--) {
    ret.append("    |");
    for (int x=0; x < 8; x++) {
      ret.append(' ');
      int p=pos.getPiece(Position.getSquare(x,y));
      if (p == Piece.EMPTY) {
        boolean dark=Position.darkSquare(x,y);
        ret.append(dark ? ".. |" : "   |");
      }
 else {
        ret.append(Piece.isWhite(p) ? ' ' : '*');
        String pieceName=pieceToChar(p);
        if (pieceName.length() == 0)         pieceName="P";
        ret.append(pieceName);
        ret.append(" |");
      }
    }
    ret.append(nl);
    ret.append("    +----+----+----+----+----+----+----+----+");
    ret.append(nl);
  }
  return ret.toString();
}

public static final String asciiBoard ( Position pos ) { StringBuilder ret = new StringBuilder ( 400 ) ; String nl = String . format ( Locale . US , "%n" ) ; ret . append ( "    +----+----+----+----+----+----+----+----+" ) ; ret . append ( nl ) ; for ( int y = 7 ; y >= 0 ; y -- ) { ret . append ( "    |" ) ; for ( int x = 0 ; x < 8 ; x ++ ) { ret . append ( ' ' ) ; int p = pos . getPiece ( Position . getSquare ( x , y ) ) ; if ( p == Piece . EMPTY ) { boolean dark = Position . darkSquare ( x , y ) ; ret . append ( dark ? ".. |" : "   |" ) ; } else { ret . append ( Piece . isWhite ( p ) ? ' ' : '*' ) ; String pieceName = pieceToChar ( p ) ; if ( pieceName . length ( ) == 0 ) pieceName = "P" ; ret . append ( pieceName ) ; ret . append ( " |" ) ; } } ret . append ( nl ) ; ret . append ( "    +----+----+----+----+----+----+----+----+" ) ; ret . append ( nl ) ; } return ret . toString ( ) ; }
create an ascii representation of a position .
