Examples of GoBoardPosition


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

        boardUpdater_ = new BoardUpdater(this, capCounts);
    }

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

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

     * 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

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

        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

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

        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

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

     */
    @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.elements.position.GoBoardPosition

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

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

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

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

    {
        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

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

        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

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

     * later we look for empty spots that are true for candidate moves
     */
    private void determineAdjacentCandidates() {
        for (int i = 1; i <= size_; i++ ) {
            for (int j = 1; j <= size_; j++ ) {
                GoBoardPosition pos = (GoBoardPosition) board_.getPosition(i,j);
                if ( pos.isOccupied() ) {
                    addCandidateMoves(pos);
                }
            }
        }
    }
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.