Examples of GoBoardPositionSet


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

    public void confirmAllStonesInGroupsClaimed(GoGroupSet groups) {

        NeighborAnalyzer na = new NeighborAnalyzer(board_);

        for (IGoGroup parentGroup : groups) {
            GoBoardPositionSet parentGroupStones = parentGroup.getStones();
            for (GoBoardPosition stone : parentGroupStones) {  // for each stone in that group
                // compute the group from this stone and confirm it matches the parent group
                GoBoardPositionList g = na.findGroupFromInitialPosition(stone);

                // perhaps we should do something more than check the size.
                if (g.size() != parentGroupStones.size()) {
                    groups.debugPrint(0, "Confirm stones in groups they Claim failed. \nGroups are:\n", true, true);
                    StringBuilder bldr = new StringBuilder();
                    bldr.append(board_.toString());
                    bldr.append("\n");
                    bldr.append("\n\nIt seems that using different seeds yields different groups:");
View Full Code Here

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

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

        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

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

        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

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

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

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

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

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

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

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

        return members_.contains(pos);
    }

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

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

            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

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

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