Examples of GoBoardPosition


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

        profiler_.startUpdateGroupsAfterRemove();

        // first make sure that there are no references to obsolete groups.
        clearEyes();

        GoBoardPosition stone = (GoBoardPosition) (getBoard().getPosition(move.getToLocation()));

        IGoString stringThatItBelongedTo = stone.getString();
        // clearing a stone may cause a string to split into smaller strings
        stone.clear(getBoard());
        board_.adjustLiberties(stone);

        updateStringsAfterRemove( stone, stringThatItBelongedTo);
        restoreCaptures(move.getCaptures());
View Full Code Here

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

        GoBoardPositionSet nbrs =
            nbrAnalyzer_.getNobiNeighbors( stone, group.isOwnedByPlayer1(), NeighborType.FRIEND );

        if ( nbrs.size() > 1 ) {
            GoBoardPositionLists lists = new GoBoardPositionLists();
            GoBoardPosition firstNbr = nbrs.getOneMember();
            GoBoardPositionList stones = nbrAnalyzer_.findStringFromInitialPosition( firstNbr, false );
            lists.add( stones );
            for ( GoBoardPosition nbrStone : nbrs ) {
                if ( !nbrStone.isVisited() ) {
                    GoBoardPositionList stones1 = nbrAnalyzer_.findStringFromInitialPosition( nbrStone, false );
View Full Code Here

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

     */
    @Override
    public void update(GoMove move) {

        clearEyes();
        GoBoardPosition stone = (GoBoardPosition) (getBoard().getPosition(move.getToLocation()));

        board_.adjustLiberties(stone);

        GoCaptureList captures = determineCaptures(stone);
        move.setCaptures(captures);

        updateStringsAfterMove(stone);
        captures.removeFromBoard(getBoard());

        assert (stone.getString().getNumLiberties(getBoard()) > 0):
            "The placed stone " + stone + " has no liberties "+stone.getGroup() +"\n"+ getBoard().toString();
        updateGroupsAfterMove(stone);
        captureCounter_.updateCaptures(move, true);
    }
View Full Code Here

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

     * @param stone position where we just placed a stone.
     * @param nbrs neighbors
     */
    private void updateNeighborStringsAfterMove(GoBoardPosition stone, GoBoardPositionSet nbrs) {

        GoBoardPosition nbrStone = nbrs.getOneMember();
        GoString str = (GoString) nbrStone.getString();
        str.addMember( stone, getBoard() );
        getAllGroups().debugPrint( 3, "groups before merging:", true, true);

        if ( nbrs.size() > 1 ) {
            mergeStringsIfNeeded(str, nbrs);
View Full Code Here

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

        deadStones_.clear();

        for ( int row = 1; row <= board_.getNumRows(); row++ ) {
            for ( int col = 1; col <= board_.getNumCols(); col++ ) {
                GoBoardPosition space = (GoBoardPosition)board_.getPosition( row, col );
                if (space.isOccupied())  {
                    GoStone stone = (GoStone)space.getPiece();
                    int side = (stone.isOwnedByPlayer1() ? 1: -1);
                    GameContext.log(1, "life & death: "+space+" health="+stone.getHealth());
                    if (side*stone.getHealth() < 0)  {
                        // then the stone is more dead than alive, so mark it so
                        GameContext.log(0, "setting " + space + " to dead");
                        stone.setDead(true);
                        deadStones_.increment(space.getPiece().isOwnedByPlayer1());
                    }
                }
            }
        }
        GameContext.log(0, deadStones_.toString());
View Full Code Here

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

        // must remove these after iterating otherwise we get a ConcurrentModificationException
        string.getGroup().remove(string);
        string.getMembers().clear();

        Iterator it = stringMembers.iterator();
        GoBoardPosition stone;
        while ( it.hasNext() ) {
            stone = (GoBoardPosition) it.next();
            IGoString myString = stone.getString();
            if (myString != null && myString != string) {
                myString.remove(stone, board);
            }
            stone.setString(null);
            addMemberInternal(stone, board);
        }
        stringMembers.clear();
        libertyAnalyzer_.invalidate();
    }
View Full Code Here

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

    public String toString() {
        StringBuilder sb = new StringBuilder( getPrintPrefix() );
        sb.append(" UA=").append(isUnconditionallyAlive()).append(" ");
        Iterator it = getMembers().iterator();
        if ( it.hasNext() ) {
            GoBoardPosition p = (GoBoardPosition) it.next();
            sb.append( p.toString() );
        }
        while ( it.hasNext() ) {
            GoBoardPosition p = (GoBoardPosition) it.next();
            sb.append( ", " );
            sb.append( p.toString() );
        }
        sb.append( ')' );
        return sb.toString();
    }
View Full Code Here

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

     * Add back the groups that are in flux due to the changed position.
     */
    private void addFluxGroups(GoGroupSet groups) {
        for ( int i = 1; i <= getBoard().getNumRows(); i++ )  {
           for ( int j = 1; j <= getBoard().getNumCols(); j++ ) {
               GoBoardPosition seed = (GoBoardPosition)getBoard().getPosition(i, j);
               if (seed.isOccupied() && !seed.isVisited()) {
                   GoBoardPositionList newGroup = nbrAnalyzer_.findGroupFromInitialPosition(seed, false);
                   GoGroup g = new GoGroup(newGroup);
                   groups.add(g);
               }
           }
View Full Code Here

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

     * clear all the eyes from all the stones on the board
     */
    protected void clearEyes() {
        for ( int i = 1; i <= board_.getNumRows(); i++ ) {
            for ( int j = 1; j <= board_.getNumCols(); j++ ) {
                GoBoardPosition space = (GoBoardPosition)board_.getPosition(i, j);
                if ( space.isInEye() )     {
                    // remove reference to the owning group so it can be garbage collected.
                    space.getEye().clear();
                    space.setEye(null);
                }
            }
        }
    }
View Full Code Here

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
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.