Here you can find the source of bitboardToString(long bitboard)
Parameter | Description |
---|---|
bitboard | the bitboard to represent as a string. |
public static String bitboardToString(long bitboard)
//package com.java2s; //License from project: Open Source License public class Main { /**// w w w . j a v a2 s . c om * Converts a <i>bitboard</i>, not a board, to a string. The string will * look identical to the result of Board.toString, except that pieces are * instead shown as 'X'. * * @param bitboard * the bitboard to represent as a string. * @return a string representation of the bitboard. */ public static String bitboardToString(long bitboard) { String asBinary = Long.toBinaryString(bitboard); while (asBinary.length() != 64) asBinary = "0" + asBinary; String s = " a b c d e f g h\n"; s += " +---+---+---+---+---+---+---+---+\n 8 | "; for (int up = 7; up >= 0; up--) { for (int out = 0; out < 8; out++) { if (asBinary.charAt(63 - (up * 8 + out)) == '1') s += "X | "; else s += " | "; } s += (up + 1) + "\n +---+---+---+---+---+---+---+---+"; if (up != 0) s += "\n " + up + " | "; } s += "\n a b c d e f g h\n"; return s; } }