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

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


        if ( lastMove == null ) return false;

        CaptureList captures = lastMove.getCaptures();
        if ( captures != null && captures.size() == 1 ) {
            GoBoardPosition capture = (GoBoardPosition) captures.getFirst();
            if ( capture.getRow() == row && capture.getCol() == col ) {
                GoBoardPosition lastStone =
                        (GoBoardPosition) board.getPosition( lastMove.getToRow(), lastMove.getToCol() );
                if ( lastStone.getNumLiberties( board ) == 1 && lastStone.getString().getMembers().size() == 1 ) {
                    GameContext.log( 2, "it is a takeback " );
                    return true;
                }
            }
        }
View Full Code Here


        boardUpdater_ = new BoardUpdater(this, capCounts);
    }

    @Override
    protected BoardPosition getPositionPrototype() {
        return new GoBoardPosition(1, 1, null, null);
    }
View Full Code Here

     * Make sure that all the positions on the board are reset to the unvisited state.
     */
    public void unvisitAll() {
        for ( int i = 1; i <= getNumRows(); i++ ) {
            for ( int j = 1; j <= getNumCols(); j++ ) {
                GoBoardPosition pos = (GoBoardPosition) getPosition( i, j );
                pos.setVisited(false);
            }
        }
    }
View Full Code Here

        int numStones = 0;

        // we should be able to just sum all the position scores now.
        for ( int i = 1; i <= getNumRows(); i++ )  {
           for ( int j = 1; j <= getNumCols(); j++ ) {
               GoBoardPosition pos = (GoBoardPosition)getPosition(i, j);
               if (pos.isOccupied() && pos.getPiece().isOwnedByPlayer1() == forPlayer1)  {
                  numStones++;
               }
           }
        }
        return numStones;
View Full Code Here

        for ( int i = 1; i <= rows; i++ ) {
            buf.append(i / 10);
            buf.append(i % 10);
            buf.append('|');
            for ( int j = 1; j <= cols; j++ ) {
                GoBoardPosition space = (GoBoardPosition) getPosition(i, j);
                if ( space.isOccupied() )     {
                    buf.append(space.getPiece().isOwnedByPlayer1()?'X':'O');
                }
                else {
                    buf.append(' ');
                }
            }
View Full Code Here

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

    /**
     * Update the liberties of the surrounding strings.
     */
    public void adjustStringLiberties(GoBoard board) {
        for (BoardPosition capture : this) {
            GoBoardPosition captured = (GoBoardPosition) capture;
            GoBoardPosition newLiberty = (GoBoardPosition) board.getPosition(captured.getLocation());
            board.adjustLiberties(newLiberty);
        }
    }
View Full Code Here

     */
    private GoBoardPositionList getRestoredList(GoBoard b) {

        GoBoardPositionList restoredList = new GoBoardPositionList();
        for (BoardPosition pos : this ) {
            GoBoardPosition capStone = (GoBoardPosition) pos;
            GoBoardPosition stoneOnBoard =
                    (GoBoardPosition) b.getPosition( capStone.getRow(), capStone.getCol() );
            stoneOnBoard.setVisited(false);    // make sure in virgin unvisited state

            // --adjustLiberties(stoneOnBoard, board);
            restoredList.add( stoneOnBoard );
        }
        return restoredList;
View Full Code Here

    {
        assert numHandicapStones_ <= starPoints_.size();
        List<Move> handicapMoves = new ArrayList<Move>(numHandicapStones_);

        for ( int i = 0; i < numHandicapStones_; i++ ) {
            GoBoardPosition hpos = starPoints_.get( i );

            GoMove m = new GoMove(hpos.getLocation(), 0, (GoStone)hpos.getPiece());
            handicapMoves.add(m);
        }
        return handicapMoves;
    }
View Full Code Here

        int max = boardSize - (min-1);
        int mid = (boardSize >> 1) + 1;

        // add the star points
        GoStone handicapStone = new GoStone(true, HANDICAP_STONE_HEALTH);
        starPoints_.add( new GoBoardPosition( min, min, null, handicapStone.copy()) );
        starPoints_.add( new GoBoardPosition( max, max, null, handicapStone.copy()) );
        starPoints_.add( new GoBoardPosition( min, max, null, handicapStone.copy()) );
        starPoints_.add( new GoBoardPosition( max, min, null, handicapStone.copy()) );
        starPoints_.add( new GoBoardPosition( min, mid, null, handicapStone.copy()) );
        starPoints_.add( new GoBoardPosition( max, mid, null, handicapStone.copy()) );
        starPoints_.add( new GoBoardPosition( mid, min, null, handicapStone.copy()) );
        starPoints_.add( new GoBoardPosition( mid, max, null, handicapStone.copy()) );
        starPoints_.add( new GoBoardPosition( mid, mid, null, handicapStone) );
    }
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.