Examples of SGFParser


Examples of com.sgfj.SGFParser

        String filePath = subPath == null ? top : top + File.separator + subPath;

        FileInputStream fis = new FileInputStream(new File(filePath));
        InputStreamReader isr;
        isr = new InputStreamReader(fis);
        SGFParser parser = new SGFParser(isr);

        while (true) {
            int offset = parser.getCharsConsumed();

            // parse file to get tree
            SGFNode tree = null;
            try {
                tree = parser.parse();
            } catch (SGFEOFException e) {
                // DO NOTHING
                break;
            } catch (SGFParseError e) {
                System.out.println("Parse error " + filePath + ":" + e.getMessage());
View Full Code Here

Examples of com.sgfj.SGFParser

       [wtkrun]     at java.io.InputStreamReader.skip(+12)
         */
        is.skip(offset);
        InputStreamReader isr = new InputStreamReader(is/*, "UTF8"*/);
        //isr.skip(offset); // FIXME: Why this doesn't work?
        SGFParser parser = new SGFParser(isr);
        SGFNode newTree = parser.parse();
        is.close();

/*    SGFCup parser = new SGFCup(new SGFLex(isr));
        parser.tree = new SGFTree(2048);
        try {
View Full Code Here

Examples of com.sgfj.SGFParser

        DocumentedGame newGame = null;
        try {
            String sgf = din.readUTF();

            if (sgf.length() > 0) {
                SGFParser parser = new SGFParser(sgf);
                SGFNode newTree = parser.parse();
                newGame = new DocumentedGame(newTree);

                int depth = din.readShort();
                while (depth-- > 0) {
                    int varNumber = din.readShort();
View Full Code Here

Examples of com.sgfj.SGFParser

       [wtkrun]     at java.io.InputStreamReader.skip(+12)
         */
        is.skip(offset);
        InputStreamReader isr = new InputStreamReader(is/*, "UTF8"*/);
        //isr.skip(offset); // FIXME: Why this doesn't work?
        SGFParser parser = new SGFParser(isr);
        SGFNode newTree = parser.parse();
        is.close();

/*    SGFCup parser = new SGFCup(new SGFLex(isr));
        parser.tree = new SGFTree(2048);
        try {
View Full Code Here

Examples of com.sgfj.SGFParser

        DocumentedGame newGame = null;
        try {
            String sgf = din.readUTF();

            if (sgf.length() > 0) {
                SGFParser parser = new SGFParser(sgf);
                SGFNode newTree = parser.parse();
                newGame = new DocumentedGame(newTree);

                int depth = din.readShort();
                while (depth-- > 0) {
                    int varNumber = din.readShort();
View Full Code Here

Examples of com.sgfj.SGFParser

                N, B, B, W, W, N, B, W, N, N, N, N, W, B, B, N, N, N, N
        };
        int wCaptures = 44;
        int bCaptures = 39;

        SGFParser reader = new SGFParser(sgfData);
        SGFNode tree = null;
        try {
            tree = reader.parse();
        } catch (Exception e) {
            e.printStackTrace();
            fail("Unexpected!");
        }
        assertNotNull("Emty tree received.", tree);
View Full Code Here

Examples of com.sgfj.SGFParser

    }

    public void testCgobanSGF() {
        try {
            String data = "(;GM[1]FF[3]SZ[4]HA[0](;AW[bb]PL[2](;W[cc])(;W[aa])))";
            SGFParser parser = new SGFParser(data);
            SGFNode tree = parser.parse();
            DocumentedGame game = new DocumentedGame(tree);
            game.next();
            assertEquals(game.board.get(1, 1), Board.WHITE);
            assertEquals(Board.WHITE, game.colorToPlay);
            game.next();
View Full Code Here

Examples of com.sgfj.SGFParser

    }

    public void testUndoAdd() {
        try {
            String data = "(;GM[1]FF[3]SZ[4]HA[0];AW[bb]AB[aa]PL[2];W[cc]))";
            SGFParser parser = new SGFParser(data);
            SGFNode tree = parser.parse();
            DocumentedGame game = new DocumentedGame(tree);
            game.next();
            assertEquals(Board.BLACK, game.board.get(0, 0));
            assertEquals(Board.WHITE, game.board.get(1, 1));
            assertEquals(Board.NONE, game.board.get(2, 2));
View Full Code Here

Examples of com.sgfj.SGFParser

    }

    public void testUndoAddEmpty() {
        try {
            String data = "(;GM[1]FF[3]SZ[4]HA[0];AW[bb]AB[aa]PL[2];W[cc]AE[aa]))";
            SGFParser parser = new SGFParser(data);
            SGFNode tree = parser.parse();
            DocumentedGame game = new DocumentedGame(tree);
            game.next();
            assertEquals(Board.BLACK, game.board.get(0, 0));
            assertEquals(Board.WHITE, game.board.get(1, 1));
            assertEquals(Board.NONE, game.board.get(2, 2));
View Full Code Here

Examples of com.sgfj.SGFParser

    }

    public void testWhiteToPlay() {
        try {
            String data = "(;GM[1]FF[3]SZ[4]HA[0];W[cc])";
            SGFParser parser = new SGFParser(data);
            SGFNode tree = parser.parse();
            DocumentedGame game = new DocumentedGame(tree);
            assertEquals(Board.WHITE, game.colorToPlay);
            game.next();
            assertEquals(game.board.get(2, 2), Board.WHITE);

            data = "(;PW[White]PB[Black];AB[pn](;B[rr];W[rs](;B[sr])(;B[ss];W[sr])(;B[qr];W[sr])(;B[rq];W[sr]))(;B[rs];W[rr])(;B[sr];W[rr])(;B[ss];W[rr]))";
            parser = new SGFParser(data);
            tree = parser.parse();
            game = new DocumentedGame(tree);
            assertEquals(SGFMove.BLACK, game.colorToPlay);
            game.next();
            assertEquals(SGFMove.BLACK, game.colorToPlay);
            game.next();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.