SgfParser { public List<List<Short>> parseGamesFromFile(File file, int maxBookDepth) { final List<List<Short>> games = new ArrayList<>(); String input = ""; try (Scanner s = new Scanner(file)) { while (s.hasNextLine()) { input += s.nextLine(); } input = input.replace("W[]", "W[tt]"); input = input.replace("B[]", "B[tt]"); final StringTokenizer stoken = new StringTokenizer(input, ")[];"); while (stoken.hasMoreTokens()) { final String token = stoken.nextToken(); if (token.equals("(")) { final List<Short> game = parseGame(stoken, maxBookDepth); if (game != null) { games.add(game); } } } return games; } catch (final FileNotFoundException e) { System.err.println("File not found!"); e.printStackTrace(); System.exit(1); } return null; } SgfParser(CoordinateSystem coords, boolean breakOnFirstPass); @SuppressWarnings("boxing") static void main(String[] args); void sgfToBoard(String filepath, Board board); void sgfToBoard(File file, Board board); List<Short> parseGameFromFile(File file); List<List<Short>> parseGamesFromFile(File file, int maxBookDepth); short sgfToPoint(String label);  }
@SuppressWarnings("boxing") @Test public void testSgfToMoves() { final List<List<Short>> games = parser.parseGamesFromFile(new File( "sgf-test-files/19/1977-02-27.sgf"), 500); assertEquals(1, games.size()); final List<Short> game = games.get(0); assertEquals(180, game.size()); assertEquals(coords.at("R16"), (short) game.get(0)); assertEquals(coords.at("N11"), (short) game.get(179)); }