Examples of GoBoard


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

        initializeData();
    }

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

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

     * @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

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

     */
    @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

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

    /**
     * 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

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

    /**
     * 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

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

     * 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

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

        // all derived classes must check this to disable user clicks while the computer is thinking
        if (controller.isProcessing()) {
            return;
        }
        Location loc = getRenderer().createLocation(e);
        GoBoard board = (GoBoard) controller.getBoard();
        boolean player1sTurn = controller.isPlayer1sTurn();

        GameContext.log( 3, "BoardViewer: mousePressed: player1sTurn()=" + player1sTurn);

        GoMove m = new GoMove( loc, 0, new GoStone(player1sTurn));

        // if there is already a piece where the user clicked, or its
        // out of bounds, or its a suicide move, then return without doing anything
        GoBoardPosition stone = (GoBoardPosition) board.getPosition( loc );

         // if stone is null, then the user clicked out of bounds.
        if ( stone != null ) {
            processStonePlacement(loc, m, stone);
        }
View Full Code Here

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

     * Place the stone on the board.
     */
    private void processStonePlacement(Location loc, GoMove m, GoBoardPosition stone) {

        GoController controller = (GoController) viewer_.getController();
        GoBoard board = (GoBoard) controller.getBoard();
        boolean player1sTurn = controller.isPlayer1sTurn();

        if ( stone.isOccupied() ) {
            JOptionPane.showMessageDialog( null, GameContext.getLabel("CANT_PLAY_ON_STONE") );
            GameContext.log( 0, "BoardViewer: There is already a stone there: " + stone );
View Full Code Here

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

     * which does not allow dupes.
     * @return the border for a multi-stone group.
     */
    private synchronized Area createMultiStoneBorder(Location firstStoneLoc) {

        GoBoard boardCopy = board_.copy();

        List<BoardPosition> q = new ArrayList<BoardPosition>();
        GoBoardPositionSet qset = new GoBoardPositionSet();
        GoBoardPositionList visitedSet = new GoBoardPositionList();

        GoBoardPosition firstStone = (GoBoardPosition) boardCopy.getPosition(firstStoneLoc);
        q.add( firstStone );
        qset.add( firstStone );
        Area area = new Area();
        NeighborAnalyzer nbrAnalyzer = new NeighborAnalyzer(boardCopy);

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.