Package com.tinygo.logic

Examples of com.tinygo.logic.DocumentedGame


            fail("Unexpected!");
        }
    }

    public void testNavigation2() {
        DocumentedGame game = new DocumentedGame(4);
        try {
            game.play(0, 0);
            try {
                game.play(0, 0);
            } catch (GameOverStoneException e) {
            }
            assertEquals(game.board.pos(0, 0), game.lastMove);
            assertEquals(Board.WHITE, game.colorToPlay);
            while (game.prev())
                // DO NOTHING
                ;
            game.next();
            game.next();
        } catch (Exception e) {
            e.printStackTrace();
            fail("Unexpected!");
        }
    }
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

            fail("Unexpected!");
        }
    }

    public void testVariants() {
        DocumentedGame game = new DocumentedGame(3);
        try {
            game.play(0, 0);
            assertTrue(game.prev());
            game.play(1, 1);
            assertTrue(game.prevVariant());
            game.play(2, 2);
            assertTrue(game.prev());
            assertTrue(game.nextVariant());
            assertTrue(game.prevVariant());
            assertTrue(game.next());

            byte[] data = {
                    Board.BLACK, Board.NONE, Board.NONE,
                    Board.NONE, Board.NONE, Board.NONE,
                    Board.NONE, Board.NONE, Board.WHITE
View Full Code Here

            fail("Unexpected!");
        }
    }

    public void testVariants2() {
        DocumentedGame game = new DocumentedGame(3);
        try {
            game.play(1, 1);
            game.play(0, 1);
            assertTrue(game.prev());
            game.play(1, 0);
            game.play(0, 1);
            assertTrue(game.prev());
            assertTrue(game.prev());
            assertTrue(game.next());
            assertTrue(game.next());

            byte[] data = {
                    Board.NONE, Board.WHITE, Board.NONE,
                    Board.BLACK, Board.BLACK, Board.NONE,
                    Board.NONE, Board.NONE, Board.NONE
View Full Code Here

            fail("Unexpected!");
        }
    }

    public void testInit() {
        DocumentedGame game = new DocumentedGame(4);
        try {
            game.play(0, 0);
            assertTrue(game.prev());
            game.play(1, 1);
            game.init(4);
            assertFalse(game.prev());
            assertFalse(game.next());
            assertFalse(game.prevVariant());
            assertFalse(game.nextVariant());
        } catch (Exception e) {
            e.printStackTrace();
            fail("Unexpected!");
        }
    }
View Full Code Here

            fail("Unexpected!");
        }
    }

    public void testPass() {
        DocumentedGame game = new DocumentedGame(4);
        try {
            game.play(0, 0);
            game.pass();
            assertEquals(Board.BLACK, game.colorToPlay);
            game.prev();
            assertEquals(Board.WHITE, game.colorToPlay);
            game.next();
            assertEquals(Board.BLACK, game.colorToPlay);
        } catch (Exception e) {
            e.printStackTrace();
            fail("Unexpected!");
        }
View Full Code Here

            fail("Unexpected!");
        }
    }

    public void testHandicap() {
        DocumentedGame game = new DocumentedGame(9);
        game.setHandicap(4);
        try {
            DocumentedGame newGame = new DocumentedGame(game.kifuHead());
            Board board = newGame.board;
            int pos;
            pos = board.hoshi(Board.HOSHI_NW);
            assertEquals(Board.BLACK, board.get(pos));
            pos = board.hoshi(Board.HOSHI_NE);
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.