Examples of SGFParser


Examples of com.sgfj.SGFParser

    }

    public void testKifuFirstMove() {
        try {
            String data = "(;PW[White]PB[Me]AW[cb]AW[db]AW[eb]AW[bc]AW[cc]AW[cd]AW[dd]AW[ed]AW[fd]AW[gd]AW[de]AW[fe]AW[df]AW[ef]AB[bb]AB[fb]AB[hb]AB[ac]AB[dc]AB[ec]AB[fc]AB[gc]AB[bd]AB[hd]AB[be]AB[ce]AB[ge]AB[he]AB[cf]AB[ff]AB[hf]AB[cg]AB[dg]AB[eg]AB[fg];B[](;W[ca]CR[ca](;B[ea]CR[ea];W[ab]CR[ab](;B[aa]CR[aa];W[ba]CR[ba]C[RIGHT])(;B[ad]CR[ad];W[ba]CR[ba]C[RIGHT]))(;B[ad]CR[ad];W[ea]CR[ea]C[RIGHT])(;B[ab]CR[ab];W[ea]CR[ea]C[RIGHT]))(;W[ea]CR[ea];B[ca]CR[ca](;W[ab]CR[ab];B[aa]CR[aa])(;W[da]CR[da];B[ab]CR[ab])(;W[ba]CR[ba];B[ab]CR[ab]))(;W[ab]CR[ab];B[aa]CR[aa](;W[ca]CR[ca](;B[ea]CR[ea];W[ba]CR[ba]C[RIGHT])(;B[ad]CR[ad];W[ea]CR[ea]C[RIGHT]))(;W[ea]CR[ea];B[ca]CR[ca]))(;W[ba]CR[ba];B[ab]CR[ab](;W[ca]CR[ca];B[ea]CR[ea])(;W[ea]CR[ea];B[ca]CR[ca]))(;W[da]CR[da];B[ab]CR[ab]))";
            SGFParser parser = new SGFParser(data);
            SGFNode tree = parser.parse();
            DocumentedGame game = new DocumentedGame(tree);
            SGFNode node = game.kifuFirstMove(true);
            SGFMove move = node.getMoveProperty();
            assertEquals(SGFMove.WHITE, move.color);
            assertEquals(2, move.x);
View Full Code Here

Examples of com.sgfj.SGFParser

    }

    public void testCompressed() {
        try {
            String data = "(;SZ[3]AW[aa:cb]AB[bc][cc])";
            SGFParser parser = new SGFParser(data);
            SGFNode tree = parser.parse();
            DocumentedGame game = new DocumentedGame(tree);
            byte[] gold = {
                W, W, W,
                W, W, W,
                N, B, B
View Full Code Here

Examples of com.sgfj.SGFParser

            fail("Unexpected!");
        }
    }

    void checkData(String data, byte[][] gold, int[] wCapts, int[] bCapts) throws Exception {
        SGFParser parser = new SGFParser(data);
        SGFNode tree = parser.parse();
        DocumentedGame game = new DocumentedGame(tree);
        int node = 0;
        do {
            for (int pos = 0; pos < game.board.maxPos(); pos++) {
                //SGFPoint p = game.board.xy(pos);
View Full Code Here

Examples of com.sgfj.SGFParser

    public void processFile(String top, String subPath) throws FileNotFoundException, UnsupportedEncodingException {
        String filePath = subPath == null ? top : top + File.separator + subPath;

        FileInputStream fis = new FileInputStream(new File(filePath));
        InputStreamReader isr = new InputStreamReader(fis/*, "UTF8"*/);
        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

    /**
     * Test method for {@link com.sgfj.t.SGFParser#parse(java.io.Reader)}.
     */
    public void testParse() {
        try {
            SGFParser reader = new SGFParser(cgobanData);
            //FileInputStream is = new FileInputStream("data/1850-11-17-Shusaku-Ito.Showa.sgf");
            SGFNode tree = reader.parse();
            assertNotNull("Emty tree received.", tree);

            SGFNodeIterator i = tree.iterator();
            SGFPointProperty move;

View Full Code Here

Examples of com.sgfj.SGFParser

    public void testParseEmpty() {
        byte[] ba = new byte[] {};
        try {
            try {
                SGFParser reader = new SGFParser(new InputStreamReader(new ByteArrayInputStream(ba)));
                SGFNode n = reader.parse();
                assertNull(n);
            } catch (SGFEOFException e) {
            }
        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here

Examples of com.sgfj.SGFParser

     * Jago tends to add extra properties before root node.
     * (GE[life and death] ;FF[4]GM[1]...
     */
    public void testParseJagoSGF() {
        try {
            SGFParser reader = new SGFParser(jagoData);
            SGFNode tree = reader.parse();
            assertNotNull("Emty tree received.", tree);

            SGFProperty p;
            p = tree.getProperty(SGFPropertyName.FF);
            assertEquals(4, p.getInt());
View Full Code Here

Examples of com.sgfj.SGFParser

     */
    public void _testParseProblemRIGHTInTheMiddle() {
        // TODO: not passing
        try {
            String data = "(;SZ[19](;B[da]C[RIGHT];W[ab])(;B[ad]))";
            SGFParser parser = new SGFParser(data);
            SGFNode tree = parser.parseProblem();
            SGFNodeIterator i = tree.iterator();
            SGFNode node = i.current();
            assertTrue((node.bits & SGFNode.GOOD_MOVE) != 0 && (node.bits & SGFNode.BAD_MOVE) != 0);
            node = i.next(true);
            assertTrue((node.bits & SGFNode.GOOD_MOVE) != 0 && (node.bits & SGFNode.BAD_MOVE) == 0);
View Full Code Here

Examples of com.sgfj.SGFParser

        }
    }

    public void testParseProblem() {
        try {
            SGFParser reader = new SGFParser(problemData);
            SGFNode tree = reader.parseProblem();
            assertNotNull("Emty tree received.", tree);

            SGFNodeIterator i = tree.iterator();
            SGFNode node;
            node = i.next(true);
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.