Package com.barrybecker4.game.twoplayer.go.board

Examples of com.barrybecker4.game.twoplayer.go.board.GoBoard


    }

    @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

        initializeData();
    }

    @Override
    protected GoBoard createBoard() {
        return new GoBoard(boardOpts.size, boardOpts.numHandicaps);
    }
View Full Code Here

     * @return all possible reasonable next moves. We try to limit to reasonable moves as best we can, but that
     * is difficult without static evaluation. At least no illegal moves will be returned.
     */
    final MoveList generatePossibleMoves(TwoPlayerMove lastMove) {

        GoBoard board = (GoBoard) searchable_.getBoard();
        MoveList moveList = new MoveList();
        int nCols = board.getNumCols();
        int nRows = board.getNumRows();

        CandidateMoveAnalyzer candidateMoves = new CandidateMoveAnalyzer(board);

        boolean player1 = (lastMove == null) || !lastMove.isPlayer1();
        int lastMoveValue = (lastMove== null) ? 0 : lastMove.getValue();
View Full Code Here

     */
    @Override
    public void saveToFile( String fileName, AssertionError ae )
    {
        GameContext.log( 1, "saving state to :" + fileName );
        GoBoard b = (GoBoard) board_;

        try {
            Writer out = createWriter(fileName);
            //PrintWriter foo;
            // SGF header info
            out.write( "(;\n" );
            out.write( "FF[4]\n" );
            out.write( "GM[1]\n" );
            out.write( "CA[UTF-8]\n" );
            out.write( "ST[2]\n" );
            out.write( "RU[japanese]\n" );
            out.write( "SZ[" + b.getNumRows() + "]\n" );
            out.write( "PB[" + players.getPlayer1().getName() + "]\n" );
            out.write( "PW[" + players.getPlayer2().getName() + "]\n" );
            out.write( "KM[" + komi + "]\n" );
            out.write( "PC[US]\n" );
            out.write( "HA[" + b.getHandicap() + "]\n" );
            out.write( "GN[test1]\n" );
            // out.write("PC[US]"); ?? add the handicap stones if present

            writeMoves(b.getMoveList(), out);
            writeExceptionIfAny(ae, out);

            out.write( ')' );
            out.close();
        } catch (IOException ioe) {
View Full Code Here

    /**
     * remove the captured pieces from the board.
     */
    @Override
    public void removeFromBoard( Board board ) {
        GoBoard goBoard = (GoBoard) board;
        for (BoardPosition c : this) {
            GoBoardPosition capStone = (GoBoardPosition) c;
            GoBoardPosition stoneOnBoard =
                (GoBoardPosition) goBoard.getPosition(capStone.getLocation());
            stoneOnBoard.clear(goBoard);
        }

        adjustStringLiberties(goBoard);
    }
View Full Code Here

    /**
     * Restore the captured pieces on the board.
     */
    @Override
    public void restoreOnBoard( Board board )  {
        GoBoard goBoard = (GoBoard) board;
        super.modifyCaptures( goBoard, false );

        GameContext.log(3, "GoMove: restoring these captures: " + this);

        GoBoardPositionLists strings = getRestoredStringLists(goBoard)// XXX should remove
        adjustStringLiberties(goBoard);

        // XXX should remove next lines
        IGoGroup group = getRestoredGroup(strings, goBoard);

        assert ( group!=null ): "no group was formed when restoring "
                + this + " the list of strings was " + strings;
        goBoard.getGroups().add( group );
    }
View Full Code Here

     * first draw borders for the groups in the appropriate color, then draw the pieces for both players.
     */
    @Override
    protected void drawMarkers(Board board, PlayerList players, Graphics2D g2 ) {

        GoBoard b = (GoBoard) board;
        // draw the star point markers
        List starpoints = b.getHandicapPositions();
        Iterator it = starpoints.iterator();
        g2.setColor(Color.black);
        double rad = (float) cellSize / 21.0 + 0.46;
        while (it.hasNext()) {
            GoBoardPosition p = (GoBoardPosition)it.next();
            g2.fillOval(getMargin() + (int)(cellSize *(p.getCol()-0.505)-rad),
                        getMargin() +(int)(cellSize *(p.getRow()-0.505)-rad),
                        (int)(2.0 * rad + 1.7), (int)(2.0 * rad + 1.7));
        }

        // draw the group borders
        if ( GameContext.getDebugMode() > 0 ) {
            GoGroupRenderer groupRenderer = new GoGroupRenderer(b, COLORMAP, (float) cellSize, getMargin(), g2);

            GroupAnalyzerMap map = new GroupAnalyzerMap();
            for (IGoGroup group : b.getGroups()) {

                GroupAnalyzer analyzer = new GroupAnalyzer(group, map);
                groupRenderer.drawGroupDecoration(analyzer);
            }
        }
View Full Code Here

TOP

Related Classes of com.barrybecker4.game.twoplayer.go.board.GoBoard

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.