TextIO { public static String moveToString(Position pos, Move move, boolean longForm) { MoveGen.MoveList moves = MoveGen.instance.pseudoLegalMoves(pos); MoveGen.removeIllegal(pos, moves); return moveToString(pos, move, longForm, moves); }  static Position readFEN(String fen); static void fixupEPSquare(Position pos); static String toFEN(Position pos); static String moveToString(Position pos, Move move, boolean longForm); static String moveToUCIString(Move m); static Move uciStringToMove(String move); static Move stringToMove(Position pos, String strMove); static int getSquare(String s); static String squareToString(int square); static String asciiBoard(Position pos); static final String startPosFEN; }
@Test public void testMoveToString() throws ChessParseError { System.out.println("moveToString"); Position pos = TextIO.readFEN(TextIO.startPosFEN); assertEquals(TextIO.startPosFEN, TextIO.toFEN(pos)); Move move = new Move(Position.getSquare(4, 1), Position.getSquare(4, 3), Piece.EMPTY); boolean longForm = true; String result = TextIO.moveToString(pos, move, longForm); assertEquals("e2-e4", result); move = new Move(Position.getSquare(6, 0), Position.getSquare(5, 2), Piece.EMPTY); result = TextIO.moveToString(pos, move, longForm); assertEquals("Ng1-f3", result); move = new Move(Position.getSquare(4, 7), Position.getSquare(2, 7), Piece.EMPTY); result = TextIO.moveToString(pos, move, longForm); assertEquals("O-O-O", result); String fen = "1r3k2/2P5/8/8/8/4K3/8/8 w - - 0 1"; pos = TextIO.readFEN(fen); assertEquals(fen, TextIO.toFEN(pos)); move = new Move(Position.getSquare(2,6), Position.getSquare(1,7), Piece.WROOK); result = TextIO.moveToString(pos, move, longForm); assertEquals("c7xb8R+", result); move = new Move(Position.getSquare(2,6), Position.getSquare(2,7), Piece.WKNIGHT); result = TextIO.moveToString(pos, move, longForm); assertEquals("c7-c8N", result); move = new Move(Position.getSquare(2,6), Position.getSquare(2,7), Piece.WQUEEN); result = TextIO.moveToString(pos, move, longForm); assertEquals("c7-c8Q+", result); }