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

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


     */
    public boolean isSuicidal( GoBoard board ) {
        GoBoardPosition stone = (GoBoardPosition) board.getPosition( getToRow(), getToCol() );

        NeighborAnalyzer na = new NeighborAnalyzer(board);
        GoBoardPositionSet nobiNbrs = na.getNobiNeighbors(stone, false, NeighborType.ANY);
        GoBoardPositionSet occupiedNbrs = new GoBoardPositionSet();
        for (GoBoardPosition pos : nobiNbrs) {
            if (pos.isOccupied()) {
                occupiedNbrs.add(pos);
            }
        }

        return !hasLiberties(occupiedNbrs, nobiNbrs) && partOfDeadString(occupiedNbrs, board);
    }
View Full Code Here


        if (getNumCaptures() == 1) {
            //GoBoardPosition capture = (GoBoardPosition) getCaptures().getFirst();
            GoBoardPosition pos = (GoBoardPosition) board.getPosition(getToLocation());

            NeighborAnalyzer nbrAnal = new NeighborAnalyzer(board);
            GoBoardPositionSet enemyNbrs = nbrAnal.getNobiNeighbors(pos, isPlayer1(), NeighborType.ENEMY);
            int numEnemyNbrs = enemyNbrs.size();

            if (numEnemyNbrs == 3
                    || board.isOnEdge(pos) && numEnemyNbrs == 2
                    || board.isInCorner(pos) && numEnemyNbrs == 1) {
                return true;
View Full Code Here

        if ( isPassingMove() )
            return 0; // a pass cannot cause an atari

        GoBoardPosition pos = (GoBoardPosition)board.getPosition( getToRow(), getToCol() );
        NeighborAnalyzer na = new NeighborAnalyzer(board);
        GoBoardPositionSet enemyNbrs = na.getNobiNeighbors( pos, NeighborType.ENEMY );
        Iterator it = enemyNbrs.iterator();
        int numInAtari = 0;
        GoStringSet stringSet = new GoStringSet();
        while ( it.hasNext() ) {
            GoBoardPosition s = (GoBoardPosition) it.next();
            IGoString atariedString = s.getString();
View Full Code Here

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

     */
    private GoCaptureList determineCaptures(GoBoardPosition stone) {

        profiler_.startFindCaptures();
        assert ( stone != null );
        GoBoardPositionSet nbrs = nbrAnalyzer_.getNobiNeighbors( stone, NeighborType.ENEMY );
        GoCaptureList captureList = new GoCaptureList();
        // keep track of the strings captured so we don't capture the same one twice
        GoStringSet capturedStrings = new GoStringSet();

        for (GoBoardPosition enbr : nbrs) {
View Full Code Here

     */
    private void updateStringsAfterMove( GoBoardPosition stone )  {

        profiler_.startUpdateStringsAfterMove();

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

        if ( nbrs.size() == 0 ) {
            // there are no strongly connected neighbors, create a new string
            new GoString( stone, getBoard())// stone points to the new string
        }
        else {
            updateNeighborStringsAfterMove(stone, nbrs);
View Full Code Here

        return members_.contains(pos);
    }

    @Override
    protected void initializeMembers() {
        members_ = new GoBoardPositionSet();
    }
View Full Code Here

            GameContext.log(1, "Warning: merging " + string + " into itself");
            // its a self join
            return;
        }

        GoBoardPositionSet stringMembers = new GoBoardPositionSet();
        stringMembers.addAll(string.getMembers());
        // 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

        if (board == null) {
            return cachedLiberties_;
        }

        GoBoardPositionSet liberties = new GoBoardPositionSet();
        for (IGoString str : getMembers()) {
            liberties.addAll(str.getLiberties(board));
        }
        cachedLiberties_ = liberties;
        return liberties;
    }
View Full Code Here

    /**
     * @return a list of the stones in this group.
     */
    @Override
    public GoBoardPositionSet getStones() {
        GoBoardPositionSet stones = new GoBoardPositionSet();
        for (IGoString string : getMembers()) {
            stones.addAll(string.getMembers());
        }
        return stones;
    }
View Full Code Here

TOP

Related Classes of com.barrybecker4.game.twoplayer.go.board.elements.position.GoBoardPositionSet

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.