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

Examples of com.barrybecker4.game.twoplayer.go.board.elements.position.GoBoardPosition


     */
    public float getRunPotential(Location position, int rowInc, int colInc, int maxRow, int maxCol) {
        MutableIntLocation pos = new MutableIntLocation(position);
        float runPotential = 0;
        int breadth = (rowInc == 1) ? (maxRow - pos.getRow()) : (maxCol - pos.getCol());
        GoBoardPosition startSpace = (GoBoardPosition) board_.getPosition( pos );

        do {
            GoBoardPosition nextSpace = (GoBoardPosition) board_.getPosition( pos );
            GoBoardPosition firstSpace = nextSpace;
            boolean containsEnemy = false;
            int runLength = 0;
            boolean player1 = groupString_.isOwnedByPlayer1();
            while (inRun(pos, maxRow, maxCol, nextSpace, player1)) {
                if (containsEnemy(player1, nextSpace)) {
View Full Code Here


            return ""// avoids concurrent modification exception

        Location loc = getBoardRenderer().createLocation(e);
        StringBuilder sb = new StringBuilder( "<html><font=-3>" )// NON_NLS

        GoBoardPosition space = (GoBoardPosition) ((IRectangularBoard)controller_.getBoard()).getPosition( loc );
        if ( space != null && GameContext.getDebugMode() > 0 ) {
            String spaceText = space.getDescription();
            sb.append( spaceText);
            IGoString string = space.getString();
            IGoEye eye = space.getEye();
            if ( string != null ) {
                appendStringText(sb, spaceText, string);
            }
            // it might belong to both an eye and a string
            if (eye != null) {
View Full Code Here

     * @param g2 graphics context
     * @param position of the piece to render
     */
    @Override
    public void render( Graphics2D g2, BoardPosition position, int cellSize, int margin, Board board) {
        GoBoardPosition stonePos = (GoBoardPosition)position;
        if (GameContext.getDebugMode() > 0)  {
            drawTerritoryShading(g2, position, cellSize, margin);
        }

        GoStone stone = (GoStone)position.getPiece();
        if (stone != null) {
            boolean inAtari = stonePos.isInAtari((GoBoard)board);
            drawStone(g2, position, cellSize, margin, inAtari, stone);
        }
    }
View Full Code Here

        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 ) {
View Full Code Here

        super(viewer);

        GoController controller = (GoController) viewer.getController();
        if (!controller.getPlayers().allPlayersComputer()) {
            getRenderer().setDraggedShowPiece(
                    new GoBoardPosition(0, 0, null, new GoStone(controller.isPlayer1sTurn())));
            savedShowPiece_ = getRenderer().getDraggedShowPiece();
        }
    }
View Full Code Here

        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

            getRenderer().setDraggedShowPiece(null);
        }
        else if (controller.getPlayers().allPlayersHuman()) {
            // create a stone to show for the next players move
            getRenderer().setDraggedShowPiece(
                    new GoBoardPosition(loc.getRow(), loc.getCol(), null, new GoStone(!player1sTurn)));
        }
    }
View Full Code Here

    private Area calcGroupBorder( GoBoardPositionSet groupStones)  {
        if (groupStones == null || groupStones.isEmpty()) {
            return null// nothing to draw an area for.
        }

        GoBoardPosition firstStone = groupStones.iterator().next();

        if ( groupStones.size() == 1 ) {
            return createSingleStoneBorder(firstStone.getLocation());
        }

        return createMultiStoneBorder(firstStone.getLocation());
    }
View Full Code Here

        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);

        while ( !q.isEmpty() ) {
            GoBoardPosition stone = (GoBoardPosition) q.remove( 0 );
            qset.remove( stone );
            stone.setVisited( true );
            visitedSet.add(stone);
            GoBoardPositionSet nbrs = nbrAnalyzer.findGroupNeighbors( stone, true );
            for (GoBoardPosition nbrStone : nbrs) {
                // accumulate all the borders to arrive at the final group border
                area.add( new Area( getBorderBetween( stone, nbrStone ) ) );
View Full Code Here

    {
        GeneralPath border = new GeneralPath();
        float celld2 = cellSize_ / 2.0f;

        if ( s1.getRow() == s2.getRow() ) { // horizontal
            GoBoardPosition leftStone;
            GoBoardPosition rightStone;
            if ( s1.getCol() < s2.getCol() ) {
                leftStone = s1;
                rightStone = s2;
            }
            else {
                leftStone = s2;
                rightStone = s1;
            }
            float xleft = margin_ + ((float) leftStone.getCol() - BORDER_OFFSET) * cellSize_;
            float yleft = margin_ + ((float) leftStone.getRow() - BORDER_OFFSET) * cellSize_;
            float xright = margin_ + ((float) rightStone.getCol() - BORDER_OFFSET) * cellSize_;
            float yright = margin_ + ((float) rightStone.getRow() - BORDER_OFFSET) * cellSize_;
            border.moveTo( xleft, yleft + celld2 );
            border.quadTo( xleft - celld2, yleft + celld2, xleft - celld2, yleft );
            border.quadTo( xleft - celld2, yleft - celld2, xleft, yleft - celld2 );
            border.lineTo( xright, yright - celld2 );
            border.quadTo( xright + celld2, yright - celld2, xright + celld2, yright );
            border.quadTo( xright + celld2, yright + celld2, xright, yright + celld2 );
            border.closePath();
        }
        else { // vertical
            GoBoardPosition topStone;
            GoBoardPosition bottomStone;
            if ( s1.getRow() < s2.getRow() ) {
                topStone = s1;
                bottomStone = s2;
            }
            else {
                topStone = s2;
                bottomStone = s1;
            }
            float xtop = margin_ + ((float) topStone.getCol() - BORDER_OFFSET ) * cellSize_;
            float ytop = margin_ + ((float) topStone.getRow() - BORDER_OFFSET) * cellSize_;
            float xbottom = margin_ + ((float) bottomStone.getCol() - BORDER_OFFSET) * cellSize_;
            float ybottom = margin_ + ((float) bottomStone.getRow() - BORDER_OFFSET) * cellSize_;
            border.moveTo( xtop - celld2, ytop );
            border.quadTo( xtop - celld2, ytop - celld2, xtop, ytop - celld2 );
            border.quadTo( xtop + celld2, ytop - celld2, xtop + celld2, ytop );
            border.lineTo( xbottom + celld2, ybottom );
            border.quadTo( xbottom + celld2, ybottom + celld2, xbottom, ybottom + celld2 );
View Full Code Here

TOP

Related Classes of com.barrybecker4.game.twoplayer.go.board.elements.position.GoBoardPosition

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.