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

Examples of com.barrybecker4.game.twoplayer.go.board.elements.string.IGoString


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


            GoBoardPositionList stones = nbrAnalyzer_.findStringFromInitialPosition( firstNbr, false );
            lists.add( stones );
            for ( GoBoardPosition nbrStone : nbrs ) {
                if ( !nbrStone.isVisited() ) {
                    GoBoardPositionList stones1 = nbrAnalyzer_.findStringFromInitialPosition( nbrStone, false );
                    IGoString newString = new GoString( stones1, getBoard() );
                    group.addMember(newString);
                    lists.add( stones1 );
                }
            }
            lists.unvisitPositionsInLists();
View Full Code Here

        for (GoBoardPosition enbr : nbrs) {

            assert (enbr.isOccupied()): "enbr=" + enbr;

            IGoString str = enbr.getString();
            assert ( str.isOwnedByPlayer1() != stone.getPiece().isOwnedByPlayer1()):
                    "The "+str+" is not an enemy of "+stone;
            assert ( str.size() > 0 ) : "Sting has 0 stones:" + str;

            if ( str.getNumLiberties(getBoard()) == 0 && !capturedStrings.contains(str) ) {
                capturedStrings.add( str );
                // we need to add copies so that when the original stones on the board are
                // changed we don't change the captures.
                captureList.addCaptures(str.getMembers());
            }
        }
        profiler_.stopFindCaptures();
        return  captureList;
    }
View Full Code Here

     */
    private void mergeStringsIfNeeded(GoString str, GoBoardPositionSet nbrs) {

        for (GoBoardPosition nbrStone: nbrs ) {
            // if its the same string then there is nothing to merge
            IGoString nbrString = nbrStone.getString();
            if ( str != nbrString )   {
                str.merge(nbrString, getBoard());
            }
        }
    }
View Full Code Here

    private IGoGroup getRestoredGroup(List<GoBoardPositionList> strings, GoBoard b) {
        // ?? form new group, or check group nbrs to see if we can add to an existing one.
        boolean firstString = true;
        IGoGroup group = null;
        for  (GoBoardPositionList stringList : strings) {
            IGoString string = new GoString( stringList, b );
            if ( firstString ) {
                group = new GoGroup( string );
                firstString = false;
            }
            else {
                group.addMember(string);
            }
            string.setVisited(false);
        }
        return group;
    }
View Full Code Here

    private void assimilateStone(GoBoardPositionList stones, GoBoardPosition stone) {
        assert stone.getPiece().isOwnedByPlayer1() == ownedByPlayer1_ :
                "Stones in group must all be owned by the same player. stones=" + stones;
        // actually this is ok - sometimes happens legitimately
        // assert isFalse(stone.isVisited(), stone+" is marked visited in "+stones+" when it should not be.");
        IGoString string = stone.getString();
        assert (string != null) : "There is no owning string for " + stone;
        if (!getMembers().contains(string)) {
            assert (ownedByPlayer1_ == string.isOwnedByPlayer1()) : string + "ownership not the same as " + this;
            //string.confirmOwnedByOnlyOnePlayer();
            getMembers().add(string);
        }
        string.setGroup(this);
    }
View Full Code Here

        StringBuilder sb = new StringBuilder( " GROUP {" + newline );
        Iterator it = getMembers().iterator();
        // print the member strings
        if ( it.hasNext() ) {
            IGoString p = (IGoString) it.next();
            sb.append("    ").append(p.toString());
        }
        while ( it.hasNext() ) {
            IGoString p = (IGoString) it.next();
            sb.append(',').append(newline).append("    ").append(p.toString());
        }
        sb.append(newline).append('}');
        return sb.toString();
    }
View Full Code Here

     * verify that we contain no empty strings.
     */
    public void confirmNoEmptyStrings() {
        for (Object g : this)  {
            for (Object s : ((IGoSet) g).getMembers()) {
                IGoString string = (IGoString) s;
                assert (string.size() > 0): "There is an empty string in " + string.getGroup();
            }
        }
    }
View Full Code Here

    /**
     * @param stone verify that this stone has a valid string and a group in the board's member list.
     */
    public void confirmStoneInValidGroup(GoBoardPosition stone) {
        IGoString str = stone.getString();
        assert ( str!=null) : stone + " does not belong to any string!" ;
        IGoGroup g = str.getGroup();
        boolean valid = false;
        Iterator gIt = this.iterator();
        IGoGroup g1;
        while ( !valid && gIt.hasNext() ) {
            g1 = (IGoGroup) gIt.next();
View Full Code Here

        GoStringSet strings = new GoStringSet();
        for ( int i = 1; i <= board_.getNumRows(); i++ )  {
            for ( int j = 1; j <= board_.getNumCols(); j++ ) {
                GoBoardPosition pos = (GoBoardPosition)board_.getPosition(i, j);
                if (pos.isOccupied()) {
                    IGoString existingString = strings.findStringContainingPosition(pos);
                    if (existingString == null) {
                        GoString str = new GoString(findStringFromInitialPosition(pos, true), board_);
                        strings.add(str);
                        pos.setString(str);
                    }
View Full Code Here

TOP

Related Classes of com.barrybecker4.game.twoplayer.go.board.elements.string.IGoString

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.