Examples of SGFNode


Examples of com.sgfj.SGFNode

    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.SGFNode

     * (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());

        } catch (Exception e) {
            e.printStackTrace();
            fail("No exceptions are expected.");
View Full Code Here

Examples of com.sgfj.SGFNode

    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);
            node = i.nextVariant(false);
            assertTrue((node.bits & SGFNode.GOOD_MOVE) == 0 && (node.bits & SGFNode.BAD_MOVE) != 0);
View Full Code Here

Examples of com.sgfj.SGFNode

    }

    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);
            assertTrue((node.bits & SGFNode.GOOD_MOVE) != 0 && (node.bits & SGFNode.BAD_MOVE) == 0);
            node = i.nextVariant(false);
            assertTrue((node.bits & SGFNode.GOOD_MOVE) == 0 && (node.bits & SGFNode.BAD_MOVE) != 0);
            node = i.next(true);
View Full Code Here

Examples of com.sgfj.SGFNode

    public void testParseHead() {
        try {
            String data = "(;GM[1]FF[4]CA[UTF-8]AP[CGoban:3]ST[2]RU[Japanese]SZ[9]HA[3]KM[5.50]PW[Белые]PB[Черные]AB[gc][cg][gg];W[ed]CR[ee]TR[cc][gc](;B[ec]CR[ec]LB[dd:A])(;B[eg]CR[eg];W[];B[ge]))";
            SGFParser reader = new SGFParser(data);
            SGFNode tree = reader.parseHead();
            assertNotNull("Emty tree received.", tree);

            assertNull(tree.iterator().next(false));
        } catch (Exception e) {
            e.printStackTrace();
            fail("No exceptions are expected.");
        }
    }
View Full Code Here

Examples of com.sgfj.SGFNode

    public void testParseUnicode() {
        try {
            String data = "(;GM[1]FF[4]CA[UTF-8]AP[CGoban:3]ST[2]RU[Japanese]PW[\u0403\u0490\u00ab\u043b\u0490])";
            SGFParser reader = new SGFParser(data);
            SGFNode tree = reader.parseHead();
            assertNotNull("Emty tree received.", tree);

            assertNull(tree.iterator().next(false));
        } catch (Exception e) {
            e.printStackTrace();
            fail("No exceptions are expected.");
        }
    }
View Full Code Here

Examples of com.sgfj.SGFNode

    }

    private void checkMoveHintsProperties() {
        if (game == null)
            return;
        SGFNode head = game.kifuHead();
        if ((head.bits & (SGFNode.BAD_MOVE | SGFNode.GOOD_MOVE)) == 0)
            SGFParser.parseMoveHintsProperties(head);
    }
View Full Code Here

Examples of com.sgfj.SGFNode

    private boolean setCursorToNextGoodMove() {
        SGFNodeIterator i = game.kifuLastMove().iterator();
        if (i.next(true) != null) {
            i.firstVariant(true);
            do {
                SGFNode node = i.current();
                if ((node.bits & SGFNode.GOOD_MOVE) != 0) {
                    return setCursor(node);
                }
            } while (i.nextVariant(true) != null);
            // no good moves found, set cursor to any move
View Full Code Here

Examples of com.sgfj.SGFNode

                                //#endif

                                if (game != null) {
                                    if (mode == probMode) {
                                        // skip first "Pass" moves, since we don't have "Pass" in problem mode
                                        SGFNode lastSetupNode = game.kifuFirstMove(true).iterator().prev(false);
                                        if (lastSetupNode != null) {
                                            try {
                                                while (game.kifuLastMove() != lastSetupNode && game.next())
                                                    // DO NOTHING
                                                    ;
View Full Code Here

Examples of com.sgfj.SGFNode

    }

    public DocumentedGame loadGame(InputStream is, int offset) throws Exception {
        is.skip(offset);
        SGFParser parser = new SGFParser(new InputStreamReader(is));
        SGFNode newTree = parser.parse();
        is.close();

/*    SGFCup parser = new SGFCup(new SGFLex(isr));
        parser.tree = new SGFTree(2048);
        try {
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.