Examples of GoBoardPositionList


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

                // if the empty space is already marked as being an eye, skip
                GoBoardPosition space = (GoBoardPosition) board_.getPosition( r, c );
                assert space != null : "pos r="+r +" c="+c;
                if ( !space.isVisited() && space.isUnoccupied() && !space.isInEye() ) {
                    GoBoardPositionList eyeSpaces =
                            nbrAnalyzer_.findStringFromInitialPosition( space, ownedByPlayer1,
                                                                 false, NeighborType.NOT_FRIEND,
                                                                 boundingBox_  );
                    excludedSpaceLists.add(eyeSpaces);
                    // make sure this is a real eye.
                    if ( confirmEye( eyeSpaces) ) {
                        GoEye eye =  new GoEye( eyeSpaces, board_, group_, groupAnalyzer);
                        eyes.add( eye );
                    }
                    else {
                        GameContext.log(3, eyeSpaces.toString("This list of stones was rejected as being an eye: "));
                    }
                }
            }
        }
        excludedSpaceLists.unvisitPositionsInLists();
View Full Code Here

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

    private void excludeSeed( GoBoardPosition space, boolean groupOwnership,
                              GoBoardPositionLists lists) {
        if ( !space.isVisited()
             && (space.isUnoccupied() || space.getPiece().isOwnedByPlayer1() != group_.isOwnedByPlayer1())) {
            // this will leave stones outside the group visited
            GoBoardPositionList exclusionList =
                    nbrAnalyzer_.findStringFromInitialPosition(space, groupOwnership, false,
                                                                NeighborType.NOT_FRIEND, boundingBox_);

            Iterator it = exclusionList.iterator();
            GroupAnalyzer groupAnalyzer = analyzerMap_.getAnalyzer(group_);

            while (it.hasNext()) {
                GoBoardPosition p = (GoBoardPosition)it.next();
                if (p.isOccupied()) {
                    // if its a very weak opponent (ie dead) then don't exclude it from the list
                    if (!groupAnalyzer.isTrueEnemy(p))  {
                        p.setVisited(false);
                        it.remove()// remove it from the list
                    }
                }
            }

            if ( exclusionList.size() > 0 ) {
                lists.add( exclusionList );
            }
        }
    }
View Full Code Here

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

        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:");
                    for (GoBoardPosition stone1 : parentGroupStones) {
                        GoBoardPositionList gg = na.findGroupFromInitialPosition(stone);
                        String title = "\nSEED STONE = "+ stone1 + " found groups of size " + gg.size();
                        bldr.append(gg.toString(title));
                    }
                    GameContext.log(0, bldr.toString());
                    GameContext.log(0,
                            g.toString("Calculated Group (seeded by ") + stone + "):"
                                + "\n is not equal to the expected parent group:\n" + parentGroup);
View Full Code Here

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

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

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

    private void addFluxGroups(GoGroupSet groups) {
        for ( int i = 1; i <= getBoard().getNumRows(); i++ )  {
           for ( int j = 1; j <= getBoard().getNumCols(); j++ ) {
               GoBoardPosition seed = (GoBoardPosition)getBoard().getPosition(i, j);
               if (seed.isOccupied() && !seed.isVisited()) {
                   GoBoardPositionList newGroup = nbrAnalyzer_.findGroupFromInitialPosition(seed, false);
                   GoGroup g = new GoGroup(newGroup);
                   groups.add(g);
               }
           }
        }
View Full Code Here

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

     * There may have been more than one string in the captureList
     * @return list of strings that were restored on the board.
     */
    private GoBoardPositionLists getRestoredStringLists(GoBoard b) {

        GoBoardPositionList restoredList = getRestoredList(b);
        GoBoardPositionLists strings = new GoBoardPositionLists();
        NeighborAnalyzer nbrAnalyzer = new NeighborAnalyzer(b);
        for (GoBoardPosition s : restoredList) {
            if (!s.isVisited()) {
                GoBoardPositionList string1 = nbrAnalyzer.findStringFromInitialPosition(s, false);
                strings.add(string1);
            }
        }
        return strings;
    }
View Full Code Here

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

    /**
     * @return list of captured stones that were restored on the board.
     */
    private GoBoardPositionList getRestoredList(GoBoard b) {

        GoBoardPositionList restoredList = new GoBoardPositionList();
        for (BoardPosition pos : this ) {
            GoBoardPosition capStone = (GoBoardPosition) pos;
            GoBoardPosition stoneOnBoard =
                    (GoBoardPosition) b.getPosition( capStone.getRow(), capStone.getCol() );
            stoneOnBoard.setVisited(false);    // make sure in virgin unvisited state

            // --adjustLiberties(stoneOnBoard, board);
            restoredList.add( stoneOnBoard );
        }
        return restoredList;
    }
View Full Code Here

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

    private void initStarPoints(int boardSize)
    {
        // initialize the list of handicap stones.
        // The number of these that actually get placed on the board
        // depends on the handicap
        starPoints_ = new GoBoardPositionList();
        int min = 4;
        // on a really small board we put the corner star points at 3-3.
        if (boardSize < 13)
            min = 3;
        int max = boardSize - (min-1);
View Full Code Here

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

            assert pos.isUnoccupied();
            if (!pos.isVisited()) {

                // don't go all the way to the borders (until the end of the game),
                // since otherwise we will likely get only one big empty region.
                GoBoardPositionList empties =
                        nbrAnalyzer_.findStringFromInitialPosition(pos, false, false, NeighborType.UNOCCUPIED, box);
                emptyLists.add(empties);

                GoBoardPositionSet nbrs = nbrAnalyzer_.findOccupiedNobiNeighbors(empties);
                float avg = calcAverageScore(nbrs);

                float score = avg * (float)nbrs.size() / Math.max(1, Math.max(nbrs.size(), empties.size()));
                assert (score <= 1.0 && score >= -1.0): "score="+score+" avg="+avg;

                for (GoBoardPosition space : empties) {
                    space.setScoreContribution(score);
                    diffScore += score;
View Full Code Here

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

     * @param stone stone to find string neighbors for.
     * @return list of string neighbors of specified position.
     */
    GoStringSet findStringNeighbors(GoBoardPosition stone) {
        GoStringSet stringNbrs = new GoStringSet();
        GoBoardPositionList nobiNbrs = new GoBoardPositionList();

        pushStringNeighbors(stone, true, nobiNbrs, false);

        // add strings only once
        for (GoBoardPosition nbr : nobiNbrs) {
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.