Package com.tinygo.logic

Examples of com.tinygo.logic.DocumentedGame


                    // Read and parse file in main thread. It's running too slow in parallel!
                    //display.callSerially(new Runnable() {
                        //public void run() {
                            //try {
                                DocumentedGame game = loadGame(is, offset);
                                //#ifdef debug
                                System.out.println("DONE");
                                //#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
                                                    ;
                                            } catch (GameException e) {
                                                // DO NOTHING
                                            }
View Full Code Here


        tree = parser.tree;*/
        if (newTree == null)
            return null;

        //System.out.println(SGFWriter.toString(tree));
        return new DocumentedGame(newTree);
    }
View Full Code Here

    public void mainMenuNewGame(String white, String black,
            String ruleSet, int size, int handicap, float komi,
            int ts, long mainTime, long byoYomiTime, int byoYomiAttr) {
        display.setCurrent(gobanCanvas);
        resetProblemEnum();
        game = new DocumentedGame(size, komi, ruleSet, white, black);
        game.setHandicap(handicap);
        setMode(playMode);
        setGame(game, true);
        timeSystem.init(ts, mainTime, byoYomiTime, byoYomiAttr);
        timeSystem.start(game.colorToPlay == Board.BLACK);
View Full Code Here

        if (srProb)
            probEnum.save(dout);
    }

    public void restore(DataInputStream din) throws IOException {
        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();
                    while (newGame.prevVariant())
                        // DO NOTHING
                        ;
                    while (varNumber-- > 0)
                        newGame.nextVariant();
                    if (depth > 0)
                        newGame.next();
                }
            }
        } catch (SGFException e) {
            //#ifdef debug
            e.printStackTrace();
View Full Code Here

                    // Read and parse file in main thread. It's running too slow in parallel!
                    //display.callSerially(new Runnable() {
                        //public void run() {
                            //try {
                                DocumentedGame game = loadGame(is, offset);
                                //#ifdef debug
                                System.out.println("DONE");
                                //#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
                                                    ;
                                            } catch (GameException e) {
                                                // DO NOTHING
                                            }
View Full Code Here

        tree = parser.tree;*/
        if (newTree == null)
            return null;

        //System.out.println(SGFWriter.toString(tree));
        return new DocumentedGame(newTree);
    }
View Full Code Here

    public void mainMenuNewGame(String white, String black,
            String ruleSet, int size, int handicap, float komi,
            int ts, long mainTime, long byoYomiTime, int byoYomiAttr) {
        display.setCurrent(gobanCanvas);
        resetProblemEnum();
        game = new DocumentedGame(size, komi, ruleSet, white, black);
        game.setHandicap(handicap);
        setMode(playMode);
        setGame(game, true);
        timeSystem.init(ts, mainTime, byoYomiTime, byoYomiAttr);
        timeSystem.start(game.colorToPlay == Board.BLACK);
View Full Code Here

        if (srProb)
            probEnum.save(dout);
    }

    public void restore(DataInputStream din) throws IOException {
        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();
                    while (newGame.prevVariant())
                        // DO NOTHING
                        ;
                    while (varNumber-- > 0)
                        newGame.nextVariant();
                    if (depth > 0)
                        newGame.next();
                }
            }
        } catch (SGFException e) {
            //#ifdef debug
            e.printStackTrace();
View Full Code Here

            SGFNodeIterator ni = tree.iterator();
            while (ni.next(true) != null)
                // DO NOTHING
                ;

            DocumentedGame game = new DocumentedGame(ni.current());
            //System.out.print(game.board.toString());
            assertEquals(wCaptures, game.whiteCaptures);
            assertEquals(bCaptures, game.blackCaptures);
            for (int pos = 0; pos < result.length; pos++) {
                SGFPoint p = game.board.xy(pos);
View Full Code Here

            fail("Unexpected!");
        }
    }

    public void testNavigation() {
        DocumentedGame game = new DocumentedGame(4);
        Board board = game.board;
        try {
            assertFalse(game.prev());
            assertFalse(game.next());

            SGFNode n2w, n3b_1, n3b_2;
            // test forward/backward navigation
            game.play(3, 3, Board.BLACK);
            game.play(0, 1, Board.WHITE);
            n2w = game.kifuLastMove();
            game.play(0, 2, Board.BLACK);
            n3b_1 = game.kifuLastMove();

            assertTrue(game.prev());
            assertSame(n2w, game.kifuLastMove());
            assertEquals(board.pos(0, 1), game.lastMove);
            assertEquals(Board.BLACK, game.colorToPlay);
            assertTrue(game.next());
            assertSame(n3b_1, game.kifuLastMove());
            assertEquals(board.pos(0, 2), game.lastMove);
            assertEquals(Board.WHITE, game.colorToPlay);
            assertFalse(game.next());

            // test variant navigation
            assertTrue(game.prev());
            game.play(0, 0, Board.BLACK); // variant to 0,2
            n3b_2 = game.kifuLastMove();
            assertEquals(board.pos(0, 0), game.lastMove);
            assertFalse(game.nextVariant());
            assertTrue(game.prevVariant());
            assertSame(n3b_1, game.kifuLastMove());
            assertEquals(board.pos(0, 2), game.lastMove);
            assertFalse(game.prevVariant());
            assertTrue(game.nextVariant());
            assertSame(n3b_2, game.kifuLastMove());
            assertEquals(board.pos(0, 0), game.lastMove);

            assertEquals(Board.WHITE, game.colorToPlay);

            // check if variant option is remembered
            assertFalse(game.nextVariant());
            assertTrue(game.prev());
            assertSame(n2w, game.kifuLastMove());
            assertTrue(game.next());
            assertSame(n3b_2, game.kifuLastMove());
            assertFalse(game.nextVariant());
        } catch (Exception e) {
            e.printStackTrace();
            fail("Unexpected!");
        }
    }
View Full Code Here

TOP

Related Classes of com.tinygo.logic.DocumentedGame

Copyright © 2018 www.massapicom. 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.