Package com.barrybecker4.puzzle.sudoku.model.board

Examples of com.barrybecker4.puzzle.sudoku.model.board.Cell


    }

    @Override
    protected NewGameDialog createNewGameDialog(Component parent, GameViewModel viewer )
    {
        return new GalacticNewGameDialog( parent, viewer );
    }
View Full Code Here


    }

    @Override
    protected GameOptionsDialog createOptionsDialog(Component parent, GameController controller )
    {
        return new GalacticOptionsDialog( parent, controller );
    }
View Full Code Here

     * display a dialog at the end of the game showing who won and other relevant
     * game specific information.
     */
    @Override
    public void showWinnerDialog() {
        GalacticTallyDialog tallyDialog = new GalacticTallyDialog(parent_, (GalacticController)controller_);
        tallyDialog.showDialog();
    }
View Full Code Here

     */
    private void showOrdersDialog(GalacticController gc) {

        GalacticPlayer currentPlayer = (GalacticPlayer)gc.getCurrentPlayer();

        OrdersDialog ordersDialog =
                new OrdersDialog(null, currentPlayer, gc.getNumberOfYearsRemaining());
        Point p = getParent().getLocationOnScreen();

        // offset the dlg so the Galaxy grid is visible as a reference
        ordersDialog.setLocation((int)(p.getX()+0.7*getParent().getWidth()), (int)(p.getY()+getParent().getHeight()/3.0));

        boolean canceled = ordersDialog.showDialog();
        if ( !canceled ) { // newGame a game with the newly defined options
            currentPlayer.setOrders( ordersDialog.getOrders() );
            gc.advanceToNextPlayer();
        }
    }
View Full Code Here

        ParameterArray initialGuess = new TantrixPath(board);
        assert(initialGuess.size() > 0) : "The random path should have some tiles!";
        long startTime = System.currentTimeMillis();

        Optimizer optimizer = new Optimizer(this);
        optimizer.setListener(this);

        ParameterArray solution =
            optimizer.doOptimization(strategy, initialGuess, SOLVED_THRESH);

        solution_ =
            new TantrixBoard(((TantrixPath)solution).getTilePlacements(), board.getPrimaryColor());

        TilePlacementList moves;
View Full Code Here

     * @return list of moves to a solution.
     */
    @Override
    public TilePlacementList solve()  {

        ParameterArray initialGuess = new TantrixPath(board);
        assert(initialGuess.size() > 0) : "The random path should have some tiles!";
        long startTime = System.currentTimeMillis();

        Optimizer optimizer = new Optimizer(this);
        optimizer.setListener(this);

        ParameterArray solution =
            optimizer.doOptimization(strategy, initialGuess, SOLVED_THRESH);

        solution_ =
            new TantrixBoard(((TantrixPath)solution).getTilePlacements(), board.getPrimaryColor());

View Full Code Here

     */
    private void checkAndSetUniqueValues() {

        for (int row = 0; row < board.getEdgeLength(); row++) {
            for (int col = 0; col < board.getEdgeLength(); col++) {
                Cell cell = board.getCell(row, col);
                Candidates cands = cell.getCandidates();
                if (cands!=null && cands.size() == 1) {
                    int unique = cands.getFirst();
                    cell.setValue(unique);
                }
            }
        }
    }
View Full Code Here

        if (position == board.getNumCells())  {
            // board completely solved now
            return true;
        }

        Cell cell = board.getCell(position);
        ValuesList shuffledValues = ValuesList.getShuffledCandidates(cell.getCandidates());

        refresh();

        for (int value : shuffledValues) {

            cell.setValue(value);
            totalCt++;
            if (generateSolution(board, position + 1)) {
                return true;
            }
            cell.clearValue();
        }

        return false;
    }
View Full Code Here

    /**
     * @param pos  position to try removing.
     */
    private void tryRemovingValue(int pos, Board board, SudokuSolver solver) {
        Cell cell = board.getCell(pos);
        int value = cell.getValue();
        cell.clearValue();

        if (ppanel_ != null && delay_ > 0) {
            ppanel_.repaint();
        }

        Board copy = new Board(board)// try to avoid this
        if (!solver.solvePuzzle(copy, ppanel_)) {
            // put it back since it cannot be solved without this positions value
            cell.setOriginalValue(value);
        }
    }
View Full Code Here

        for (Location location : userEnteredValues.keySet())  {
            assert location != null;
            UserValue userValue = userEnteredValues.get(location);

            Cell cell = solvedPuzzle.getCell(location.getRow(), location.getCol());
            boolean valid = userValue.getValue() == cell.getValue();
            userValue.setValid(valid);
        }
    }
View Full Code Here

TOP

Related Classes of com.barrybecker4.puzzle.sudoku.model.board.Cell

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.