@Test(expected = NullPointerException.class) public void testToFENKeyNull() { toFENKey(null); }
public static String toFENKey(final Board pEtat) { if (pEtat == null) { throw new NullPointerException("Missing game state"); } final StringBuilder res = new StringBuilder(); for (int y = RANK_COUNT - 1; y >= 0; y--) { int vide = 0; for (int x = 0; x < FILE_COUNT; x++) { final Piece p = pEtat.getPieceAt(Square.valueOf(x, y)); if (p == null) { vide++; } else { if (vide > 0) { res.append((char) ('0' + vide)); vide = 0; } res.append(p.getFENLetter()); } } if (vide > 0) { res.append((char) ('0' + vide)); } if (y != 0) { res.append('/'); } } res.append(' '); if (pEtat.isWhiteActive()) { res.append('w'); } else { res.append('b'); } res.append(' '); boolean roque = false; if (pEtat.canCastleShort(true)) { res.append('K'); roque = true; } if (pEtat.canCastleLong(true)) { res.append('Q'); roque = true; } if (pEtat.canCastleShort(false)) { res.append('k'); roque = true; } if (pEtat.canCastleLong(false)) { res.append('q'); roque = true; } if (!roque) { res.append('-'); } res.append(' '); final Square enPassant = pEtat.getEnPassant(); if (enPassant != null) { res.append(enPassant.getFENString()); } else { res.append('-'); } return res.toString(); }
FENUtils { public static String toFENKey(final Board pEtat) { if (pEtat == null) { throw new NullPointerException("Missing game state"); } final StringBuilder res = new StringBuilder(); for (int y = RANK_COUNT - 1; y >= 0; y--) { int vide = 0; for (int x = 0; x < FILE_COUNT; x++) { final Piece p = pEtat.getPieceAt(Square.valueOf(x, y)); if (p == null) { vide++; } else { if (vide > 0) { res.append((char) ('0' + vide)); vide = 0; } res.append(p.getFENLetter()); } } if (vide > 0) { res.append((char) ('0' + vide)); } if (y != 0) { res.append('/'); } } res.append(' '); if (pEtat.isWhiteActive()) { res.append('w'); } else { res.append('b'); } res.append(' '); boolean roque = false; if (pEtat.canCastleShort(true)) { res.append('K'); roque = true; } if (pEtat.canCastleLong(true)) { res.append('Q'); roque = true; } if (pEtat.canCastleShort(false)) { res.append('k'); roque = true; } if (pEtat.canCastleLong(false)) { res.append('q'); roque = true; } if (!roque) { res.append('-'); } res.append(' '); final Square enPassant = pEtat.getEnPassant(); if (enPassant != null) { res.append(enPassant.getFENString()); } else { res.append('-'); } return res.toString(); } }
FENUtils { public static String toFENKey(final Board pEtat) { if (pEtat == null) { throw new NullPointerException("Missing game state"); } final StringBuilder res = new StringBuilder(); for (int y = RANK_COUNT - 1; y >= 0; y--) { int vide = 0; for (int x = 0; x < FILE_COUNT; x++) { final Piece p = pEtat.getPieceAt(Square.valueOf(x, y)); if (p == null) { vide++; } else { if (vide > 0) { res.append((char) ('0' + vide)); vide = 0; } res.append(p.getFENLetter()); } } if (vide > 0) { res.append((char) ('0' + vide)); } if (y != 0) { res.append('/'); } } res.append(' '); if (pEtat.isWhiteActive()) { res.append('w'); } else { res.append('b'); } res.append(' '); boolean roque = false; if (pEtat.canCastleShort(true)) { res.append('K'); roque = true; } if (pEtat.canCastleLong(true)) { res.append('Q'); roque = true; } if (pEtat.canCastleShort(false)) { res.append('k'); roque = true; } if (pEtat.canCastleLong(false)) { res.append('q'); roque = true; } if (!roque) { res.append('-'); } res.append(' '); final Square enPassant = pEtat.getEnPassant(); if (enPassant != null) { res.append(enPassant.getFENString()); } else { res.append('-'); } return res.toString(); } private  FENUtils(); }
FENUtils { public static String toFENKey(final Board pEtat) { if (pEtat == null) { throw new NullPointerException("Missing game state"); } final StringBuilder res = new StringBuilder(); for (int y = RANK_COUNT - 1; y >= 0; y--) { int vide = 0; for (int x = 0; x < FILE_COUNT; x++) { final Piece p = pEtat.getPieceAt(Square.valueOf(x, y)); if (p == null) { vide++; } else { if (vide > 0) { res.append((char) ('0' + vide)); vide = 0; } res.append(p.getFENLetter()); } } if (vide > 0) { res.append((char) ('0' + vide)); } if (y != 0) { res.append('/'); } } res.append(' '); if (pEtat.isWhiteActive()) { res.append('w'); } else { res.append('b'); } res.append(' '); boolean roque = false; if (pEtat.canCastleShort(true)) { res.append('K'); roque = true; } if (pEtat.canCastleLong(true)) { res.append('Q'); roque = true; } if (pEtat.canCastleShort(false)) { res.append('k'); roque = true; } if (pEtat.canCastleLong(false)) { res.append('q'); roque = true; } if (!roque) { res.append('-'); } res.append(' '); final Square enPassant = pEtat.getEnPassant(); if (enPassant != null) { res.append(enPassant.getFENString()); } else { res.append('-'); } return res.toString(); } private  FENUtils(); static Board toBoard(final String pFEN); static String toFEN(final Board pEtat); static String toFENKey(final Board pEtat); }
FENUtils { public static String toFENKey(final Board pEtat) { if (pEtat == null) { throw new NullPointerException("Missing game state"); } final StringBuilder res = new StringBuilder(); for (int y = RANK_COUNT - 1; y >= 0; y--) { int vide = 0; for (int x = 0; x < FILE_COUNT; x++) { final Piece p = pEtat.getPieceAt(Square.valueOf(x, y)); if (p == null) { vide++; } else { if (vide > 0) { res.append((char) ('0' + vide)); vide = 0; } res.append(p.getFENLetter()); } } if (vide > 0) { res.append((char) ('0' + vide)); } if (y != 0) { res.append('/'); } } res.append(' '); if (pEtat.isWhiteActive()) { res.append('w'); } else { res.append('b'); } res.append(' '); boolean roque = false; if (pEtat.canCastleShort(true)) { res.append('K'); roque = true; } if (pEtat.canCastleLong(true)) { res.append('Q'); roque = true; } if (pEtat.canCastleShort(false)) { res.append('k'); roque = true; } if (pEtat.canCastleLong(false)) { res.append('q'); roque = true; } if (!roque) { res.append('-'); } res.append(' '); final Square enPassant = pEtat.getEnPassant(); if (enPassant != null) { res.append(enPassant.getFENString()); } else { res.append('-'); } return res.toString(); } private  FENUtils(); static Board toBoard(final String pFEN); static String toFEN(final Board pEtat); static String toFENKey(final Board pEtat); static final String STANDART_STARTING_FEN; }