Examples of GoBoardPositionSet


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

    public int getNumEyeNeighbors(GoBoardPosition eyeSpace) {
        return getEyeNeighbors(eyeSpace).size();
    }

    public GoBoardPositionSet keySet() {
        return new GoBoardPositionSet(nbrMap_.keySet());
    }
View Full Code Here

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

     */
    private float boostRelativeHealthBasedOnWeakNbr(GoBoard board, float absoluteHealth) {

        // the default if there is no weakest group.
        float relativeHealth = absoluteHealth;
        GoBoardPositionSet groupStones = group_.getStones();
        WeakestGroupFinder finder = new WeakestGroupFinder(board, analyzerMap_);
        GoGroup weakestGroup = finder.findWeakestGroup(groupStones);

        if (weakestGroup != null)  {
            double proportionWithEnemyNbrs = findProportionWithEnemyNbrs(groupStones);

            double diff = absoluteHealth + analyzerMap_.getAnalyzer(weakestGroup).getAbsoluteHealth();
            // @@ should use a weight to help determine how much to give a boost.

            // must be bounded by -1 and 1
            relativeHealth =
                    (float) (Math.min(1.0, Math.max(-1.0, absoluteHealth + diff * proportionWithEnemyNbrs)));
        }
        groupStones.unvisitPositions();
        return relativeHealth;
    }
View Full Code Here

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

        GoGroupSet enemyNbrs = new GoGroupSet();
        NeighborAnalyzer nbrAnalyzer =  new NeighborAnalyzer(board);

        // for every stone in the group.
        for (GoBoardPosition stone : groupStones) {
            GoBoardPositionSet nbrs = nbrAnalyzer.findGroupNeighbors(stone, false);
            addEnemyNeighborsForStone(enemyNbrs, stone, nbrs, isPlayer1);
        }
        GoProfiler.getInstance().stopGetEnemyGroupNbrs();
        return enemyNbrs;
    }
View Full Code Here

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

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

    private synchronized Area createMultiStoneBorder(Location firstStoneLoc) {

        GoBoard boardCopy = board_.copy();

        List<BoardPosition> q = new ArrayList<BoardPosition>();
        GoBoardPositionSet qset = new GoBoardPositionSet();
        GoBoardPositionList visitedSet = new GoBoardPositionList();

        GoBoardPosition firstStone = (GoBoardPosition) boardCopy.getPosition(firstStoneLoc);
        q.add( firstStone );
        qset.add( firstStone );
        Area area = new Area();
        NeighborAnalyzer nbrAnalyzer = new NeighborAnalyzer(boardCopy);

        while ( !q.isEmpty() ) {
            GoBoardPosition stone = (GoBoardPosition) q.remove( 0 );
            qset.remove( stone );
            stone.setVisited( true );
            visitedSet.add(stone);
            GoBoardPositionSet nbrs = nbrAnalyzer.findGroupNeighbors( stone, true );
            for (GoBoardPosition nbrStone : nbrs) {
                // accumulate all the borders to arrive at the final group border
                area.add( new Area( getBorderBetween( stone, nbrStone ) ) );
                if ( !nbrStone.isVisited() && !qset.contains( nbrStone ) ) {
                    q.add( nbrStone );
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.