/** * Test load all sg ffiles. * * @throws IOException Signals that an I/O exception has occurred. */ public void testLoadAllSGFfiles() throws IOException { Stack<String> files = new Stack<String>(); files.push("sgf/2004-12"); int count = 0; while (files.size() > 0 && count <= 10) { String filename = files.pop(); File file = new File(filename); count++; if (DEBUG) System.err.println("examining \"" + filename + "\""); if (file.exists()) { if (!file.isDirectory()) { // System.err.println("\"" + filename + "\" is not a // directory, parsing as an SGF file"); Game game = Game.loadFromFile(file); if (game.getSize() == 19) { Iterator<Move> i = game.getMoves(); Move move = null; BoardI board = new SmallerBoard(game.getSize()); // System.err.println("board size is: \"" + // goGame.getSize() // + "\""); while (i.hasNext()) { move = i.next(); assertNotNull(move); // System.err.print("move: \"" + move + "\""); // assertTrue("" + board + "\n" + // move.toString(),board.isLegalMove(move)); board = board.newBoard(move); // System.err.println(" board size is: \"" + // board.getSize() + "\""); } // System.err.println(); } } else { if (DEBUG) System.err.println("\"" + filename + "\" is a directory"); if (!file.getName().contains(".svn")) { String[] children = file.list(); for (int i = 0; i < children.length; i++) { // System.err.println("pushing \"" + children[i] + // "\""); files.push(filename + "/" + children[i]); } } } } } }
/** * Test load simple gnugo. * * @throws IOException Signals that an I/O exception has occurred. */ public void testLoadSimpleGnugo() throws IOException { Game game = Game.loadFromFile(new File("sgf/testing/simpleGnuGo.sgf")); Iterator<Move> i = game.getMoves(); Move move = null; BoardI board = new SmallerBoard(game.getSize()); while (i.hasNext()) { move = i.next(); assertNotNull(move); board = board.newBoard(move); } // System.err.println(g); }