Examples of IGoGroup


Examples of com.barrybecker4.game.twoplayer.go.board.elements.group.IGoGroup

     * @param stone that was removed.
     * @param string that the stone belonged to.
     */
    private void splitStringsIfNeeded(GoBoardPosition stone, IGoString string) {

        IGoGroup group = string.getGroup();
        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 );
                    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.group.IGoGroup

        GoBoardPositionLists strings = getRestoredStringLists(goBoard)// XXX should remove
        adjustStringLiberties(goBoard);

        // XXX should remove next lines
        IGoGroup group = getRestoredGroup(strings, goBoard);

        assert ( group!=null ): "no group was formed when restoring "
                + this + " the list of strings was " + strings;
        goBoard.getGroups().add( group );
    }
View Full Code Here

Examples of com.barrybecker4.game.twoplayer.go.board.elements.group.IGoGroup

     * @return the group that was restored when the captured stones were replaced on the board.
     */
    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.group.IGoGroup

     *  info is not guaranteed to be updated yet.
     */
    @Override
    public boolean isEnemy(GoBoardPosition pos)
    {
        IGoGroup g = getGroup();
        assert (g != null): "group for "+ this +" is null";
        if (pos.isUnoccupied()) {
            return false;
        }
        GoStone stone = (GoStone)pos.getPiece();

        assert (g.isOwnedByPlayer1() == isOwnedByPlayer1()):
                 "Bad group ownership for eye="+ this +". Owning Group="+g;
        return (stone.isOwnedByPlayer1() != isOwnedByPlayer1()); // && !weaker);
    }
View Full Code Here

Examples of com.barrybecker4.game.twoplayer.go.board.elements.group.IGoGroup

     * @param space check to see if this space is part of a false eye.
     * @return true if htis is a false eye.
     */
    private boolean isFalseEye( GoBoardPosition space )
    {
        IGoGroup ourGroup = eye_.getGroup();
        boolean groupP1 = ourGroup.isOwnedByPlayer1();
        Set nbrs = nbrAnalyzer_.getNobiNeighbors( space, groupP1, NeighborType.FRIEND );

        if ( nbrs.size() >= 2 ) {

            int numOppDiag = getNumOpponentDiagonals(space, groupP1);
View Full Code Here

Examples of com.barrybecker4.game.twoplayer.go.board.elements.group.IGoGroup

                territoryEstimate -= val;  // will be positive
            }
        }
        else { // occupied
            GamePiece piece = pos.getPiece();
            IGoGroup group = pos.getGroup();
            assert(piece != null);
            if (group != null) {
                // add credit for probable captured stones.
                double relHealth = analyzerMap_.getAnalyzer(group).getRelativeHealth(board_, isEndOfGame);
                if (forPlayer1 && !piece.isOwnedByPlayer1() && relHealth >= 0) {
View Full Code Here

Examples of com.barrybecker4.game.twoplayer.go.board.elements.group.IGoGroup

     */
    private float calcAverageScore(GoBoardPositionSet stones) {
        float totalScore = 0;

        for (GoBoardPosition stone : stones) {
            IGoGroup group = stone.getString().getGroup();
            boolean useCached = false;
            totalScore += analyzerMap_.getAnalyzer(group).getRelativeHealth(board_, useCached);
        }
        return totalScore/stones.size();
    }
View Full Code Here

Examples of com.barrybecker4.game.twoplayer.go.board.elements.group.IGoGroup

    /**
     * draw debugging information about the group like its border and eye shapes.
     */
    public void drawGroupDecoration(GroupAnalyzer groupAnalyzer) {

        IGoGroup group = groupAnalyzer.getGroup();
        GroupRegion cachedRegion = hmRegionCache_.get(group);

        if ( !groupAnalyzer.isValid() || cachedRegion == null || cellSize_ != cachedRegion.cellSize ) {

            // the colormap will show red if close to dead,
            // so reverse the health value for the other player
            double h = (groupAnalyzer.getRelativeHealth(board_, true));
            if (!group.isOwnedByPlayer1())  {
                h = -h;
            }

            cachedRegion = new GroupRegion();
            cachedRegion.borderArea = calcGroupBorder( group.getStones() );
            cachedRegion.borderColor = colormap_.getColorForValue( h );
            cachedRegion.cellSize = cellSize_;

            // cache these new values (until something changes again)
            hmRegionCache_.put(group, cachedRegion);
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.