Keywords: chess database application, candidate move selector, current position, extract, pgn, chesspresso, create, board, usage, greatest. Powered by TextRank.
Chesspresso is a great library for processing chess games stored in PGN format. One of the greatest uses I have found for chesspresso is using it to extract FENs of the current position on the board. I’ve used this for example to create a candidate move selector in a chess database application. Here is a an example usage to extract the FENs from a game PGN given as a String:
ByteArrayInputStream bis = new ByteArrayInputStream(singleGame.getBytes()); PGNReader pgnReader = new PGNReader(bis, ""); Game game; game = pgnReader.parseGame(); if (game == null) return null; game.gotoStart(); Move[] mainLine = game.getMainLine(); for (int i = 0; i < mainLine.length; i++) { Move move = mainLine[i]; String fen = game.getPosition().getFEN(); System.out.println(fen); game.getPosition().doMove(move); }
120 words
Powered by TF-IDF/Cosine similarity
First published on 2018-05-09
Generated on 13 Dec 2024 at 12:12 AM
Mobile optimized version. Desktop version.