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

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


     * @param samePlayerOnly if true then find group nbrs that are have same ownership as friendPlayer1
     * @return group neighbors for specified stone.
     */
    GoBoardPositionSet findGroupNeighbors(GoBoardPosition stone,
                                            boolean friendPlayer1, boolean samePlayerOnly) {
        GoBoardPositionList stack = new GoBoardPositionList();

        pushGroupNeighbors( stone, friendPlayer1, stack, samePlayerOnly );
        GoBoardPositionSet nbrStones = new GoBoardPositionSet();
        nbrStones.addAll( stack );

View Full Code Here


     * @return string from seed stone.
     */
    public GoBoardPositionList findStringFromInitialPosition( GoBoardPosition stone,  boolean friendOwnedByP1,
                                                     boolean returnToUnvisitedState, NeighborType type, Box box) {
        GoProfiler.getInstance().startFindStrings();
        GoBoardPositionList stones =
                stringNbrAnalyzer_.findStringFromInitialPosition(stone, friendOwnedByP1, returnToUnvisitedState,
                                                 type, box);
        GoProfiler.getInstance().stopFindStrings();

        return stones;
View Full Code Here

     * @return string from seed stone
     */
    GoBoardPositionList findStringFromInitialPosition(GoBoardPosition stone, boolean friendOwnedByP1,
                                                      boolean returnToUnvisitedState, NeighborType type,
                                                      Box box) {
        GoBoardPositionList stones = new GoBoardPositionList();

        GoBoardPositionList stack = new GoBoardPositionList();
        assert box.contains(stone.getLocation()) : "stone " +  stone + " not in " + box;

        assert ( !stone.isVisited() ): "stone="+stone;
        stack.add( 0, stone );
        while ( !stack.isEmpty() ) {
            GoBoardPosition s = stack.pop();
            if ( !s.isVisited() ) {
                s.setVisited( true );
                stones.add( s );
                pushStringNeighbors(s, friendOwnedByP1, stack, true, type,  box);
            }
View Full Code Here

    private Map<GoBoardPosition, GoBoardPositionList> createMap() {
        Map<GoBoardPosition, GoBoardPositionList> nbrMap = new HashMap<GoBoardPosition, GoBoardPositionList>();
        // we should probably be able to assume that the eye spaces_ are unvisited, but apparently not. assert instead?
        eye_.setVisited(false);

        GoBoardPositionList queue = new GoBoardPositionList();
        GoBoardPosition firstPos = eye_.getMembers().iterator().next();
        firstPos.setVisited(true);
        queue.add(firstPos);

        int count = processSearchQueue(queue, nbrMap);

        if (count != eye_.getMembers().size()) {
            throw new IllegalArgumentException("The eye string must not have been nobi connected because " +
View Full Code Here

     */
    private int processSearchQueue(GoBoardPositionList queue, Map<GoBoardPosition, GoBoardPositionList> nbrMap) {
        int count = 0;
        while (!queue.isEmpty()) {
            GoBoardPosition current = queue.remove(0);
            GoBoardPositionList nbrs = getEyeNobiNeighbors(current);
            nbrMap.put(current, nbrs);
            count++;
            for (GoBoardPosition space : nbrs)  {
                if (!space.isVisited()) {
                    space.setVisited(true);
View Full Code Here

     * @param space eye space to check
     * @return number of eye-space nobi neighbors.
     * these neighbors may either be blanks or dead stones of the opponent
     */
    private GoBoardPositionList getEyeNobiNeighbors(GoBoardPosition space) {
        GoBoardPositionList nbrs = new GoBoardPositionList();
        for (GoBoardPosition eyeSpace : eye_.getMembers()) {

            if ( space.isNeighbor( eyeSpace ))
                nbrs.add(eyeSpace);
        }
        return nbrs;
    }
View Full Code Here

                   return handleVitalPointCases(nbrMap, eye, 4);
                }
            case E122223 :
                return handleVitalPointCases(nbrMap, eye, 5);
            case E112224 :
                GoBoardPositionList endFilledSpaces = findSpecialFilledSpaces(nbrMap, getEndPoints(), eye);
                switch (endFilledSpaces.size()) {
                    case 0 return handleVitalPointCases(nbrMap, eye, 2);
                    case 1 return handleVitalPointCases(nbrMap, eye, 1); // replace with handleLifeProp? see page 122
                    default : assert false : "unexpected number of end spaces filled";
                }
                break;
View Full Code Here

     * 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 Eye6Type determineE112233Subtype(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() == 2 : "Did not get 2 one nbr points. Instead got "
                + oneNbrPoints.size()+ "\n nbrmap="+ nbrMap;
        Box bounds = new Box(oneNbrPoints.getFirst().getLocation(), oneNbrPoints.get(1).getLocation());
View Full Code Here

     * If all but one vital point has been filled, then we are unsettles - could be on eor two eyes.
     * If 2 or more vitals are still open, then we assume that this will become 2 eyes.
     * @return status of shape with numVitals vital points.
     */
    EyeStatus handleVitalPointCases(EyeNeighborMap nbrMap, IGoEye eye, final int numVitals)   {
        GoBoardPositionList vitalFilledSpaces = findSpecialFilledSpaces(nbrMap, getVitalPoints(), eye);
        int numFilledVitals = vitalFilledSpaces.size();
        assert numFilledVitals <= numVitals :
                "The number of filled vitals (" + numFilledVitals + ") " +
                "was greater than the total number of vitals ("+ numVitals + ") vitals="
                + Arrays.toString(getVitalPoints()) + " eye="+ eye;

View Full Code Here

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

TOP

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

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.