Examples of GoBoardPositionList


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

    /**
     * I suppose, in very rare cases, there could be a same side stone among the enemy filled spaces in the eye.
     * @return the eye spaces that have enemy stones in them.
     */
    GoBoardPositionList findFilledSpaces(IGoEye eye) {
        GoBoardPositionList filledSpaces = new GoBoardPositionList();
        for (GoBoardPosition space : eye.getMembers()) {
            if (space.isOccupied()) {
                assert eye.isOwnedByPlayer1() != space.getPiece().isOwnedByPlayer1();
                filledSpaces.add(space);
            }
        }
        return filledSpaces;
    }
View Full Code Here

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

    /**
     *
     * @return the set of special spaces (vital or end) that have enemy stones in them.
     */
    GoBoardPositionList findSpecialFilledSpaces(EyeNeighborMap nbrMap, float[] specialPoints, IGoEye eye) {
        GoBoardPositionList specialFilledSpaces = new GoBoardPositionList();
        for (GoBoardPosition space : eye.getMembers()) {
            if (space.isOccupied()) {
                assert eye.isOwnedByPlayer1() != space.getPiece().isOwnedByPlayer1();
                if (nbrMap.isSpecialPoint(space, specialPoints)) {
                    specialFilledSpaces.add(space);
                }
            }
        }
        return specialFilledSpaces;
    }
View Full Code Here

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

    /**
     * When the eye type has the life property, we can only be alive or alive in atari.
     * @return either alive or alive in atari (rare)
     */
    EyeStatus handleSubtypeWithLifeProperty(IGoEye eye, GoBoard board) {
        GoBoardPositionList filledSpaces = findFilledSpaces(eye);
        if (eye.size() - filledSpaces.size() == 1 && eye.getGroup().getLiberties(board).size() == 1) {
            return EyeStatus.ALIVE_IN_ATARI;
        }
        return EyeStatus.ALIVE;
    }
View Full Code Here

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

     * if the box defined by those 2 positions contains the other 4 spaces, then case b, else a
     * @return the subtype E112233a or E112233b
     */
    private Eye7Type determineE1112234Subtype(EyeNeighborMap nbrMap) {

        GoBoardPositionList oneNbrPoints = new GoBoardPositionList();
        GoBoardPositionList otherPoints = new GoBoardPositionList();

        for (GoBoardPosition pos : nbrMap.keySet()) {
            if (nbrMap.getNumEyeNeighbors(pos) == 1)  {
               oneNbrPoints.add(pos);
            }
            else {
               otherPoints.add(pos);
            }
        }
        assert oneNbrPoints.size() == 3// hitting this
        Box bounds = new Box(oneNbrPoints.getFirst().getLocation(), oneNbrPoints.get(1).getLocation());
        bounds.expandBy(oneNbrPoints.get(2).getLocation());
View Full Code Here

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

        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 );
                    qset.add( nbrStone );
                }
            }
        }
        // mark all the stones in the group unvisited again.
        visitedSet.unvisitPositions();
        if (GameContext.getDebugMode() > 1) {
            new BoardValidator(boardCopy).confirmAllUnvisited();
        }
        return area;
    }
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.