Package com.barrybecker4.common.concurrency

Examples of com.barrybecker4.common.concurrency.Worker


     */
    protected void parseSGFGameInfo( SGFGame game) {
        Enumeration e = game.getInfoTokens();
        int size = 13; // default unless specified
        while (e.hasMoreElements()) {
            InfoToken token = (InfoToken) e.nextElement();
            if (token instanceof SizeToken) {
                SizeToken sizeToken = (SizeToken)token;
                GameContext.log(2, "info token size ="+sizeToken.getSize());
                size = sizeToken.getSize();
            }
View Full Code Here


    {
        Enumeration trees = tree.getTrees();
        Enumeration leaves = tree.getLeaves();
        Enumeration tokens;
        while ( leaves != null && leaves.hasMoreElements() ) {
            SGFToken token;
            tokens = ((SGFLeaf) leaves.nextElement()).getTokens();

            boolean found = false;

            // While a move token hasn't been found, and there are more tokens to
View Full Code Here

        Enumeration e = game.getInfoTokens();
        int size = 13; // default unless specified
        while (e.hasMoreElements()) {
            InfoToken token = (InfoToken) e.nextElement();
            if (token instanceof SizeToken) {
                SizeToken sizeToken = (SizeToken)token;
                GameContext.log(2, "info token size ="+sizeToken.getSize());
                size = sizeToken.getSize();
            }
        }
        ((IRectangularBoard)controller_.getBoard()).setSize(size, size);
    }
View Full Code Here

    /**
     * create and show the server.
     */
    public static void main(String[] args) {

        CommandLineOptions options = new CommandLineOptions(args);

        if (verifyCmdLineOptions(options))  {
            String gameName = options.getValueForOption(GAME_OPTION);
            new OnlineGameServer(gameName, null);
        }
    }
View Full Code Here

    /**
     * create and show the server.
     */
    public static void main(String[] args) {

        CommandLineOptions options = new CommandLineOptions(args);

        if (OnlineGameServer.verifyCmdLineOptions(options)) {
            String gameName = options.getValueForOption(OnlineGameServer.GAME_OPTION);
            OnlineGameServerFrame frame = new OnlineGameServerFrame(gameName);
            frame.setVisible(true);
        }
    }
View Full Code Here

        puzzlePanel_.setShowCandidates(show);
    }

    public void generatePuzzle(final int delay, final int size) {

        Worker worker = new Worker() {

            @Override
            public Object construct() {
                puzzlePanel_.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

                SudokuGenerator generator = new SudokuGenerator(size, puzzlePanel_);
                generator.setDelay(delay);
                puzzlePanel_.generateNewPuzzle(generator);
                return true;
            }

            @Override
            public void finished() {
                puzzlePanel_.repaint();
                puzzlePanel_.setCursor(Cursor.getDefaultCursor());
            }
        };
        worker.start();
    }
View Full Code Here

        worker.start();
    }

    public void solvePuzzle(final int delay) {

        Worker worker = new Worker() {

            @Override
            public Object construct() {
                SudokuSolver solver = new SudokuSolver();
                solver.setDelay(delay);
                puzzlePanel_.startSolving(solver);
                return true;
            }

            @Override
            public void finished() {
                puzzlePanel_.repaint();
            }
        };
        worker.start();
    }
View Full Code Here

            generator.interrupt();
            // blocks until done working (which will be soon now that it has been interrupted)
            generateWorker.get();
        }

        generateWorker = new Worker() {

            @Override
            public Object construct() {
                generator = new MazeGenerator(mazePanel);
                mazePanel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
View Full Code Here

    public void solve(final int animationSpeed) {

        if (generateWorker.isWorking() || solver.isWorking()) return;

        Worker worker = new Worker() {

            @Override
            public Object construct() {

                mazePanel.setAnimationSpeed(animationSpeed);
                solver = new MazeSolver(mazePanel);
                solver.solve();
                return true;
            }

            @Override
            public void finished() {
                mazePanel.repaint();
            }
        };
        worker.start();
    }
View Full Code Here

     * @return true if the game is over
     * @throws AssertionError  if something bad happened while searching.
     */
     public boolean requestComputerMove(final boolean isPlayer1, final boolean synchronous) throws AssertionError {

         worker_ = new Worker() {

             private Move move_;

             @Override
             public Object construct() {
View Full Code Here

TOP

Related Classes of com.barrybecker4.common.concurrency.Worker

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.