Examples of IGoString


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

        Iterator it = enemyNbrs.iterator();
        int numInAtari = 0;
        GoStringSet stringSet = new GoStringSet();
        while ( it.hasNext() ) {
            GoBoardPosition s = (GoBoardPosition) it.next();
            IGoString atariedString = s.getString();
            if (!stringSet.contains(atariedString) && atariedString.getNumLiberties(board) == 1 ) {
                numInAtari += atariedString.size();
            }
            stringSet.add(atariedString); // once its in the set we won't check it again.
        }
        return numInAtari;
    }
View Full Code Here

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

     /**
      * make it show an empty board position.
      */
    public void clear(GoBoard board) {
        IGoString string = getString();

        if (string != null)  {
            string.remove(this, board);
        } else {
            assert isUnoccupied();
        }
        clear();
    }
View Full Code Here

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

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

            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

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

        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

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

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

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

    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

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

    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

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

        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

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

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